Commit 4fd821b0 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add the dbui configuration plugins_paths.

parent 43e5a68e
...@@ -182,33 +182,44 @@ def debug(): ...@@ -182,33 +182,44 @@ def debug():
""" """
from plugin_dbui import get_file_paths, get_script_path from plugin_dbui import get_file_paths, get_script_path
lst = []
plugin = PluginManager("dbui").dbui plugin = PluginManager("dbui").dbui
plugins_paths = plugin.plugins_paths
# css files # css
response.files.extend(get_file_paths(plugin.extjs_css, ext='.css')) for plg in plugins_paths:
response.files.extend(get_file_paths(plugin.dbui_css, ext='.css')) path =plugins_paths[plg]["css"]
response.files.extend(get_file_paths(plugin.ace_css, ext='.css')) if path is not None:
response.files.extend(get_file_paths(plugin.app_css, ext='.css')) lst.extend(get_file_paths(path, ext='.css'))
lst.extend(get_file_paths(plugin.app_css, ext='.css'))
# debug version of the javascript libraries # debug version of the javascript libraries
response.files.extend(get_file_paths(plugin.ace_debug, ext='.js')) for plg in plugins_paths:
response.files.extend(get_file_paths(plugin.mathjax_libmin, ext='.js')) path =plugins_paths[plg]["debug"]
response.files.extend(get_file_paths(plugin.extjs_debug, ext='.js', alpha=False)) if path is not None:
response.files.extend(get_file_paths(plugin.dbui_debug, ext='.js')) if plg == "extjs":
response.files.extend(get_file_paths(plugin.app_debug, ext='.js')) lst.extend(get_file_paths(path, ext='.js', alpha=False))
else:
lst.extend(get_file_paths(path, ext='.js'))
lst.extend(get_file_paths(plugin.app_debug, ext='.js'))
# language files # language
response.files.extend(get_file_paths(plugin.extjs_lg, ext='.js')) for plg in plugins_paths:
response.files.extend(get_file_paths(plugin.dbui_lg, ext='.js')) path =plugins_paths[plg]["lg"]
response.files.extend(get_file_paths(plugin.app_lg, ext='.js')) if path is not None:
lst.extend(get_file_paths(path, ext='.js'))
lst.extend(get_file_paths(plugin.app_lg, ext='.js'))
# URL for the dbui configuration activating the debug # URL for the dbui configuration activating the debug
# mode on the client side # mode on the client side
response.files.append(plugin.dbui_conf_debug) lst.append(plugin.dbui_conf_debug)
# main script which can be defined in many different ways # main script which can be defined in many different ways
pscript = get_script_path(plugin) pscript = get_script_path(plugin)
response.files.append(pscript) lst.append(pscript)
# switch ON the debug mode on the server side # switch ON the debug mode on the server side
session.debug = True session.debug = True
...@@ -216,8 +227,15 @@ def debug(): ...@@ -216,8 +227,15 @@ def debug():
# select the view # select the view
response.view = 'plugin_dbui/index.html' response.view = 'plugin_dbui/index.html'
# return the plugin configuration parameter as well as the response # convert path into HTML
return dict(plugin=plugin) fwlib = ""
for el in lst:
if el.endswith(".css"):
fwlib += '<link rel="stylesheet" type="text/css" href="%s"/>\n\t\t' % el
else:
fwlib +='<script type="text/javascript" src="%s"></script>\n\t\t' %el
return dict(fwlib=fwlib)
def documentations(): def documentations():
...@@ -349,39 +367,56 @@ def index(): ...@@ -349,39 +367,56 @@ def index():
""" """
from plugin_dbui import get_file_paths, get_script_path from plugin_dbui import get_file_paths, get_script_path
lst = []
plugin = PluginManager("dbui").dbui plugin = PluginManager("dbui").dbui
plugins_paths = plugin.plugins_paths
# css files # css
response.files.extend(get_file_paths(plugin.extjs_css, ext='.css')) for plg in plugins_paths:
response.files.extend(get_file_paths(plugin.dbui_css, ext='.css')) path =plugins_paths[plg]["css"]
response.files.extend(get_file_paths(plugin.ace_css, ext='.css')) if path is not None:
response.files.extend(get_file_paths(plugin.app_css, ext='.css')) lst.extend(get_file_paths(path, ext='.css'))
lst.extend(get_file_paths(plugin.app_css, ext='.css'))
# compressed version of the javascript libraries # compressed version of the javascript libraries
response.files.extend(get_file_paths(plugin.ace_libmin, ext='.js')) for plg in plugins_paths:
path =plugins_paths[plg]["libmin"]
if path is not None:
if plg == "extjs":
lst.extend(get_file_paths(path, ext='.js', alpha=False))
else:
lst.extend(get_file_paths(path, ext='.js'))
lst.extend(get_file_paths(plugin.app_libmin, ext='.js'))
response.files.extend(get_file_paths(plugin.mathjax_libmin, ext='.js')) # language
response.files.extend(get_file_paths(plugin.extjs_libmin, ext='.js', alpha=False)) for plg in plugins_paths:
response.files.extend(get_file_paths(plugin.dbui_libmin, ext='.js')) path =plugins_paths[plg]["lg"]
response.files.extend(get_file_paths(plugin.app_libmin, ext='.js')) if path is not None:
lst.extend(get_file_paths(path, ext='.js'))
# language files lst.extend(get_file_paths(plugin.app_lg, ext='.js'))
response.files.extend(get_file_paths(plugin.extjs_lg, ext='.js'))
response.files.extend(get_file_paths(plugin.dbui_lg, ext='.js'))
response.files.extend(get_file_paths(plugin.app_lg, ext='.js'))
# URL for dbui configuration script # URL for dbui configuration script
response.files.append(plugin.dbui_conf) lst.append(plugin.dbui_conf)
# main script which can be defined in many different ways # main script which can be defined in many different ways
pscript = get_script_path(plugin) pscript = get_script_path(plugin)
response.files.append(pscript) lst.append(pscript)
# switch off the debug mode on the server side # switch off the debug mode on the server side
session.debug = False session.debug = False
# return the plugin configuration parameter as well as the response # convert path into HTML
return dict(plugin=plugin) fwlib = ""
for el in lst:
if el.endswith(".css"):
fwlib += '<link rel="stylesheet" type="text/css" href="%s"/>\n\t\t' % el
else:
fwlib +='<script type="text/javascript" src="%s"></script>\n\t\t' %el
return dict(fwlib=fwlib)
def latex2pdf(): def latex2pdf():
......
...@@ -6,6 +6,7 @@ import copy ...@@ -6,6 +6,7 @@ import copy
import plugin_dbui as dbui import plugin_dbui as dbui
from collections import OrderedDict
from gluon import current from gluon import current
from gluon.storage import Storage from gluon.storage import Storage
from gluon.tools import PluginManager from gluon.tools import PluginManager
...@@ -23,39 +24,45 @@ defaults = Storage( ...@@ -23,39 +24,45 @@ defaults = Storage(
app_script=None, app_script=None,
app_script_dir=None, app_script_dir=None,
# dbui library # dbui URL
dbui_conf="/%s/plugin_dbui/dbui_conf", dbui_conf="/%s/plugin_dbui/dbui_conf",
dbui_conf_debug="/%s/plugin_dbui/dbui_conf?debug", dbui_conf_debug="/%s/plugin_dbui/dbui_conf?debug",
dbui_css=[
"static/plugin_dbui/resources/css/kde-oxygen.css",
"static/plugin_dbui/resources/css/dbui.css"],
dbui_debug="static/plugin_dbui/src/Dbui.js",
dbui_lg="static/plugin_dbui/locale/dbui-lang-%s.js",
dbui_libmin="static/plugin_dbui/dbui-min.js",
dbui_script="static/plugin_dbui/main.js", dbui_script="static/plugin_dbui/main.js",
# ACE library # paths for plugins ace, dbui, extjs and mathjax
ace_css="static/plugin_ace/css/editor.css", # Warning the order of the plugins matter
ace_debug="static/plugin_ace/src-noconflict/ace.js", # since extjs has to be called before dbui
ace_libmin="static/plugin_ace/src-min-noconflict/ace.js", plugins_paths=OrderedDict([
(
# EXT JS library "ace", {
extjs_css="static/plugin_extjs/build/classic/theme-classic/resources/theme-classic-all.css", "css": "static/plugin_ace/css/editor.css",
"debug": "static/plugin_ace/src-noconflict/ace.js",
extjs_debug=[ "lg": None,
"static/plugin_extjs/build/ext-all-debug.js", "libmin": "static/plugin_ace/src-min-noconflict/ace.js"}
"static/plugin_extjs/build/classic/theme-classic/theme-classic-debug.js"], ), (
"extjs", {
extjs_libmin=[ "css": "static/plugin_extjs/build/classic/theme-classic/resources/theme-classic-all.css",
"static/plugin_extjs/build/ext-all.js", "debug": ["static/plugin_extjs/build/ext-all-debug.js",
"static/plugin_extjs/build/classic/theme-classic/theme-classic.js"], "static/plugin_extjs/build/classic/theme-classic/theme-classic-debug.js"],
"lg": "static/plugin_extjs/build/classic/locale/locale-%s.js",
extjs_lg="static/plugin_extjs/build/classic/locale/locale-%s.js", "libmin": ["static/plugin_extjs/build/ext-all.js",
"static/plugin_extjs/build/classic/theme-classic/theme-classic.js"]}
# MATHJAX library ), (
mathjax_libmin="static/plugin_mathjax/MathJax.js") "dbui", {
"css": ["static/plugin_dbui/resources/css/kde-oxygen.css",
"static/plugin_dbui/resources/css/dbui.css"],
"debug": "static/plugin_dbui/src/Dbui.js",
"lg": "static/plugin_dbui/locale/dbui-lang-%s.js",
"libmin": "static/plugin_dbui/dbui-min.js"}
), (
"mathjax", {
"css": None,
"debug": "static/plugin_mathjax/MathJax.js",
"lg": None,
"libmin": "static/plugin_mathjax/MathJax.js"}
)
])
)
class Dbui(object): class Dbui(object):
...@@ -124,54 +131,34 @@ class Dbui(object): ...@@ -124,54 +131,34 @@ class Dbui(object):
the User Interface. The default is the User Interface. The default is
``/myapp/plugin_dbui/dbui_conf?debug``. ``/myapp/plugin_dbui/dbui_conf?debug``.
dbui_css (str or list):
Relative path to CSS files for the dbui library:
``static/plugin_dbui/resources/css``.
dbui_debug (str of list)
Relative path to the debug version of the dbui library:
``static/plugin_dbui/dbui-debug.js``.
dbui_lg (str or list):
Relative path to languages files for the dbui library:
``static/plugin_dbui/locale/dbui-lang-fr.js``.
dbui_libmin (str of list):
Relative path to the minified version of the dbui library:
``static/plugin_dbui/dbui-min.js``
dbui_script (str): dbui_script (str):
Default script to run the application: Default script to run the application:
``static/plugin_dbui/main.js``. It is recommended to use ``static/plugin_dbui/main.js``. It is recommended to use
the option ``app_script``. the option ``app_script``.
ace_css (str of list): plugins_paths (dict):
Relative path to the CSS file for the ACE library: Key is the name of the plugin while value is a dictionary
``static/plugin_ace/css/editor.css``, with 4 keys:
ace_debug (str of list):
Relative path to the debug version of the ACE library:
``static/plugin_ace/src-noconflict/ace.js``.
ace_libmin (str of list): * css (str or list or None):
Relative path to the minified version of the ACE library: relative path to CSS files for plugin:
``static/plugin_ace/src-min-noconflict/ace.js``. ``static/plugin_key/resources/css``
extjs_css (str of list): * debug (str or list or None):
Relative path to the CSS files for the Ext JS library. relative path to the debug version of the plugin
library: ``static/plugin_key/dbui-debug.js``.
extjs_debug (str of list): * lg (str or list or None):
Relative path to the debug version of the Ext JS library. relative path to languages files for the plugin
library: ``static/plugin_key/locale/key-lang-fr.js``.
extjs_libmin (str of list): * libmin (str or list or None):
Relative path to the minified version of the Ext JS library. relative path to languages files for the plugin
library: ``static/plugin_key/locale/key-lang-fr.js``.
extjs_lg (str of list): By default, plugins *ace*, *dbui*, *extjs* and *mathjax* are
Relative path to the language files for the Ext JS library. configure. It is possible to add others plugins.
mathjax_libmin (str of list):
Relative path to the minified version of the MathJax library:
``static/plugin_mathjax/MathJax.js``.
""" """
plugin = PluginManager("dbui").dbui plugin = PluginManager("dbui").dbui
...@@ -182,9 +169,13 @@ class Dbui(object): ...@@ -182,9 +169,13 @@ class Dbui(object):
# update values depending on language # update values depending on language
lg = get_language() lg = get_language()
plugins_paths = plugin.plugins_paths
paths_dbui = plugins_paths["dbui"]
paths_dbui["lg"] = paths_dbui["lg"] % lg
plugin.dbui_lg = plugin.dbui_lg % lg paths_extjs = plugins_paths["extjs"]
plugin.extjs_lg = plugin.extjs_lg % lg paths_extjs["lg"] = paths_extjs["lg"] % lg
# update values depending on the application # update values depending on the application
application = current.request.application application = current.request.application
......
...@@ -25,11 +25,7 @@ ...@@ -25,11 +25,7 @@
</script> </script>
<!-- Framework library and style files --> <!-- Framework library and style files -->
{{for el in response.files: {{=XML(fwlib)}}
if el.endswith('.css'):}}<link rel="stylesheet" type="text/css" href="{{=el}}"/>
{{else:}}<script type="text/javascript" src="{{=el}}"></script>
{{pass
pass}}
</head> </head>
<body> <body>
<div id='appmain'></div> <div id='appmain'></div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment