Cleanup the way stylesheets and scripts are injected into pages by modules.
							parent
							
								
									45d536f524
								
							
						
					
					
						commit
						b5abf2c640
					
				| 
						 | 
				
			
			@ -1,12 +1,3 @@
 | 
			
		|||
<link rel="stylesheet" href="{{ url_for('.static', filename='css/browser.css') }}" />
 | 
			
		||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/codemirror/codemirror.css') }}" />
 | 
			
		||||
<script src="{{ url_for('static', filename='js/codemirror/codemirror.js') }}"></script>
 | 
			
		||||
<script src="{{ url_for('static', filename='js/codemirror/mode/sql.js') }}"></script>
 | 
			
		||||
<link rel="stylesheet" href="{{ url_for('.static', filename='css/aciTree/css/aciTree.css') }}" />
 | 
			
		||||
<script src="{{ url_for('.static', filename='js/aciTree/jquery.aciPlugin.min.js') }}"></script>
 | 
			
		||||
<script src="{{ url_for('.static', filename='js/aciTree/jquery.aciTree.min.js') }}"></script>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<div id="container" class="browser-pane-container">
 | 
			
		||||
 | 
			
		||||
  <div class="pane ui-layout-west browser-browser-pane">
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,7 +10,7 @@
 | 
			
		|||
"""A blueprint module implementing the core pgAdmin browser."""
 | 
			
		||||
MODULE_NAME = 'browser'
 | 
			
		||||
 | 
			
		||||
from flask import Blueprint, current_app, render_template
 | 
			
		||||
from flask import Blueprint, current_app, render_template, url_for
 | 
			
		||||
from flaskext.gravatar import Gravatar
 | 
			
		||||
from flask.ext.security import login_required
 | 
			
		||||
from flask.ext.login import current_user
 | 
			
		||||
| 
						 | 
				
			
			@ -45,7 +45,19 @@ def index():
 | 
			
		|||
    edit_items = [ ]
 | 
			
		||||
    tools_items = [ ]
 | 
			
		||||
    help_items = [ ]
 | 
			
		||||
    js_code = ''
 | 
			
		||||
    stylesheets = [ ]
 | 
			
		||||
    scripts = [ ]
 | 
			
		||||
        
 | 
			
		||||
    # Add browser stylesheets
 | 
			
		||||
    stylesheets.append(url_for('static', filename='css/codemirror/codemirror.css'))
 | 
			
		||||
    stylesheets.append(url_for('browser.static', filename='css/browser.css'))
 | 
			
		||||
    stylesheets.append(url_for('browser.static', filename='css/aciTree/css/aciTree.css'))
 | 
			
		||||
    
 | 
			
		||||
    # Add browser scripts
 | 
			
		||||
    scripts.append(url_for('static', filename='js/codemirror/codemirror.js'))
 | 
			
		||||
    scripts.append(url_for('static', filename='js/codemirror/mode/sql.js'))
 | 
			
		||||
    scripts.append(url_for('browser.static', filename='js/aciTree/jquery.aciPlugin.min.js'))
 | 
			
		||||
    scripts.append(url_for('browser.static', filename='js/aciTree/jquery.aciTree.min.js'))
 | 
			
		||||
    
 | 
			
		||||
    for module in modules:
 | 
			
		||||
        # Get the edit menu items
 | 
			
		||||
| 
						 | 
				
			
			@ -63,10 +75,14 @@ def index():
 | 
			
		|||
        # Get the help menu items
 | 
			
		||||
        if 'browser' in dir(module) and 'get_help_menu_items' in dir(module.browser):
 | 
			
		||||
            help_items.extend(module.browser.get_help_menu_items())
 | 
			
		||||
            
 | 
			
		||||
        # Get any Javascript code
 | 
			
		||||
        if 'browser' in dir(module) and 'get_javascript_code' in dir(module.browser):
 | 
			
		||||
            js_code += (module.browser.get_javascript_code())
 | 
			
		||||
        
 | 
			
		||||
        # Get any stylesheets
 | 
			
		||||
        if 'browser' in dir(module) and 'get_stylesheets' in dir(module.browser):
 | 
			
		||||
            stylesheets += module.browser.get_stylesheets()
 | 
			
		||||
                    
 | 
			
		||||
        # Get any scripts
 | 
			
		||||
        if 'browser' in dir(module) and 'get_scripts' in dir(module.browser):
 | 
			
		||||
            scripts += module.browser.get_scripts()
 | 
			
		||||
 | 
			
		||||
    file_items = sorted(file_items, key=lambda k: k['priority'])
 | 
			
		||||
    edit_items = sorted(edit_items, key=lambda k: k['priority'])
 | 
			
		||||
| 
						 | 
				
			
			@ -74,7 +90,7 @@ def index():
 | 
			
		|||
    help_items = sorted(help_items, key=lambda k: k['priority'])
 | 
			
		||||
    
 | 
			
		||||
    # Get the layout settings
 | 
			
		||||
    layout_settings = {}
 | 
			
		||||
    layout_settings = { }
 | 
			
		||||
    layout_settings['sql_size'] = get_setting('Browser/SQLPane/Size', default=250)
 | 
			
		||||
    layout_settings['sql_closed'] = get_setting('Browser/SQLPane/Closed', default="false")
 | 
			
		||||
    layout_settings['browser_size'] = get_setting('Browser/BrowserPane/Size', default=250)
 | 
			
		||||
| 
						 | 
				
			
			@ -86,5 +102,6 @@ def index():
 | 
			
		|||
                           edit_items=edit_items, 
 | 
			
		||||
                           tools_items=tools_items, 
 | 
			
		||||
                           help_items=help_items,
 | 
			
		||||
                           js_code = js_code,
 | 
			
		||||
                           stylesheets = stylesheets,
 | 
			
		||||
                           scripts = scripts,
 | 
			
		||||
                           layout_settings = layout_settings)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,4 @@
 | 
			
		|||
alertify.defaults.transition = "zoom";
 | 
			
		||||
alertify.defaults.theme.ok = "btn btn-primary";
 | 
			
		||||
alertify.defaults.theme.cancel = "btn btn-danger";
 | 
			
		||||
alertify.defaults.theme.input = "form-control";
 | 
			
		||||
| 
						 | 
				
			
			@ -14,41 +14,42 @@
 | 
			
		|||
        <meta name="dcterms.rights" content="All rights reserved">
 | 
			
		||||
        <meta name="dcterms.dateCopyrighted" content="2014 - 2015">
 | 
			
		||||
 | 
			
		||||
        <!-- Base template stylesheets -->
 | 
			
		||||
        <link rel="stylesheet" href="{{ url_for('static', filename='css/jquery-layout/layout-default.css') }}" />
 | 
			
		||||
        {% if config.DEBUG %}<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap.css') }}" />{% else %}<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap.min.css') }}" />{% endif %}
 | 
			
		||||
        {% if config.DEBUG %}<link rel="stylesheet" href="{{ url_for('static', filename='css/alertifyjs/alertify.css') }}" />{% else %}<link rel="stylesheet" href="{{ url_for('static', filename='css/alertifyjs/alertify.min.css') }}" />{% endif %}
 | 
			
		||||
        {% if config.DEBUG %}<link rel="stylesheet" href="{{ url_for('static', filename='css/alertifyjs/themes/bootstrap.css') }}" />{% else %}<link rel="stylesheet" href="{{ url_for('static', filename='css/alertifyjs/themes/bootstrap.min.css') }}" />{% endif %}
 | 
			
		||||
        {% if config.DEBUG %}<link rel="stylesheet" href="{{ url_for('static', filename='css/jquery-ui/jquery-ui.css') }}" />{% else %}<link rel="stylesheet" href="{{ url_for('static', filename='css/jquery-ui/jquery-ui.min.css') }}" />{% endif %}
 | 
			
		||||
        <style>
 | 
			
		||||
            body {
 | 
			
		||||
                padding-top: 50px;
 | 
			
		||||
                padding-bottom: 20px;
 | 
			
		||||
            }
 | 
			
		||||
        </style>
 | 
			
		||||
        {% if config.DEBUG %}<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap-theme.min.css') }}">{% else %}<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap-theme.min.css') }}">{% endif %}
 | 
			
		||||
        <link rel="stylesheet" href="{{ url_for('static', filename='css/overrides.css') }}">
 | 
			
		||||
 | 
			
		||||
        {% if stylesheets is defined %}
 | 
			
		||||
        <!-- View specified stylesheets -->
 | 
			
		||||
        {% for stylesheet in stylesheets %}
 | 
			
		||||
        <link rel="stylesheet" href="{{ stylesheet }}">
 | 
			
		||||
        {% endfor %}
 | 
			
		||||
        {% endif %}
 | 
			
		||||
        
 | 
			
		||||
        <!-- Base template scripts -->
 | 
			
		||||
        <script src="{{ url_for('static', filename='js/modernizr-2.6.2-respond-1.1.0.min.js') }}"></script>
 | 
			
		||||
        {% if config.DEBUG %}<script src="{{ url_for('static', filename='js/jquery-1.11.2.js') }}">{% else %}<script src="{{ url_for('static', filename='js/jquery-1.11.2.min.js') }}">{% endif %}</script>
 | 
			
		||||
        {% if config.DEBUG %}<script src="{{ url_for('static', filename='js/bootstrap.js') }}">{% else %}<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}">{% endif %}</script>
 | 
			
		||||
        {% if config.DEBUG %}<script src="{{ url_for('static', filename='js/alertifyjs/alertify.js') }}">{% else %}<script src="{{ url_for('static', filename='js/alertifyjs/alertify.min.js') }}">{% endif %}</script>
 | 
			
		||||
        <script src="{{ url_for('static', filename='js/alertifyjs/pgadmin.defaults.js') }}"></script>
 | 
			
		||||
        {% if config.DEBUG %}<script src="{{ url_for('static', filename='js/jquery-ui/jquery-ui.js') }}">{% else %}<script src="{{ url_for('static', filename='js/jquery-ui/jquery-ui.min.js') }}">{% endif %}</script>
 | 
			
		||||
        {% if config.DEBUG %}<script src="{{ url_for('static', filename='js/jquery-layout/jquery.layout.js') }}">{% else %}<script src="{{ url_for('static', filename='js/jquery-layout/jquery.layout.min.js') }}">{% endif %}</script>
 | 
			
		||||
        <script src="{{ url_for('static', filename='js/jquery-layout/plugins/jquery.layout.state.js') }}"></script>
 | 
			
		||||
        {% if scripts is defined %}
 | 
			
		||||
        <!-- View specified scripts -->
 | 
			
		||||
        {% for script in scripts %}
 | 
			
		||||
        <script src="{{ script }}"></script>
 | 
			
		||||
        {% endfor %}
 | 
			
		||||
        {% endif %}
 | 
			
		||||
    </head>
 | 
			
		||||
    <body>
 | 
			
		||||
        <!--[if lt IE 7]>
 | 
			
		||||
            <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
 | 
			
		||||
        <![endif]-->
 | 
			
		||||
 | 
			
		||||
        {% if config.DEBUG %}<script src="{{ url_for('static', filename='js/jquery-1.11.2.js') }}">{% else %}<script src="{{ url_for('static', filename='js/jquery-1.11.2.min.js') }}">{% endif %}</script>
 | 
			
		||||
        {% if config.DEBUG %}<script src="{{ url_for('static', filename='js/bootstrap.js') }}">{% else %}<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}">{% endif %}</script>
 | 
			
		||||
        {% if config.DEBUG %}<script src="{{ url_for('static', filename='js/alertifyjs/alertify.js') }}">{% else %}<script src="{{ url_for('static', filename='js/alertifyjs/alertify.min.js') }}">{% endif %}</script>
 | 
			
		||||
        {% if config.DEBUG %}<script src="{{ url_for('static', filename='js/jquery-ui/jquery-ui.js') }}">{% else %}<script src="{{ url_for('static', filename='js/jquery-ui/jquery-ui.min.js') }}">{% endif %}</script>
 | 
			
		||||
        {% if config.DEBUG %}<script src="{{ url_for('static', filename='js/jquery-layout/jquery.layout.js') }}">{% else %}<script src="{{ url_for('static', filename='js/jquery-layout/jquery.layout.min.js') }}">{% endif %}</script>
 | 
			
		||||
        <script src="{{ url_for('static', filename='js/jquery-layout/plugins/jquery.layout.state.js') }}"></script>
 | 
			
		||||
        
 | 
			
		||||
        <script>
 | 
			
		||||
            alertify.defaults.transition = "zoom";
 | 
			
		||||
            alertify.defaults.theme.ok = "btn btn-primary";
 | 
			
		||||
            alertify.defaults.theme.cancel = "btn btn-danger";
 | 
			
		||||
            alertify.defaults.theme.input = "form-control";
 | 
			
		||||
        </script>
 | 
			
		||||
 | 
			
		||||
        {% block body %}{% endblock %}
 | 
			
		||||
 | 
			
		||||
    </body>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,7 +22,6 @@ def get_file_menu_items():
 | 
			
		|||
            {'name': 'Test Notifier', 'priority': 600, 'url': '#', 'onclick': 'test_notifier()'},
 | 
			
		||||
           ]
 | 
			
		||||
    
 | 
			
		||||
def get_javascript_code():
 | 
			
		||||
    """Render from the template and return any Javascript code snippets required
 | 
			
		||||
    in the browser"""
 | 
			
		||||
    return render_template("test/browser.js")
 | 
			
		||||
def get_scripts():
 | 
			
		||||
    """Return a list of script URLs to include in the rendered page header"""
 | 
			
		||||
    return [ url_for('test.static', filename='js/test.js') ]
 | 
			
		||||
| 
						 | 
				
			
			@ -1,13 +1,11 @@
 | 
			
		|||
{#
 | 
			
		||||
##########################################################################
 | 
			
		||||
#
 | 
			
		||||
# pgAdmin 4 - PostgreSQL Tools
 | 
			
		||||
#
 | 
			
		||||
# Copyright (C) 2013 - 2014, The pgAdmin Development Team
 | 
			
		||||
# This software is released under the PostgreSQL Licence
 | 
			
		||||
#
 | 
			
		||||
##########################################################################
 | 
			
		||||
#}
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
// pgAdmin 4 - PostgreSQL Tools
 | 
			
		||||
//
 | 
			
		||||
// Copyright (C) 2013 - 2014, The pgAdmin Development Team
 | 
			
		||||
// This software is released under the PostgreSQL Licence
 | 
			
		||||
//
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
function test_alert() {
 | 
			
		||||
    alertify.alert(
 | 
			
		||||
		Loading…
	
		Reference in New Issue