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