Commit 23008829 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add configuration parameters to dbui for about, documentation and license.

parent b55ea6a8
...@@ -184,20 +184,26 @@ def documentations_table(): ...@@ -184,20 +184,26 @@ def documentations_table():
trJS = T("Javascript API") trJS = T("Javascript API")
trPy = T("Python API") trPy = T("Python API")
# documentation of the application
apath, lpath = get_reference_paths() apath, lpath = get_reference_paths()
path_exists = lambda x: x and os.path.exists(os.path.join(apath, x))
f = lambda x: x.replace("static/", "")
# documentation of the application
userdoc = "" userdoc = ""
if os.path.exists(os.path.join(apath, 'static/docs/database.png')): path_db_schema = plugin.app_db_schema
userdoc = a % (URL('static', 'docs/database.png'), T("Data base scheme")) if path_exists(path_db_schema):
userdoc = a % (URL('static', f(path_db_schema)), T("Data base scheme"))
pydoc = "" pydoc = ""
if os.path.exists(os.path.join(apath, 'static/docs/api/index.html')): path_html_api = plugin.app_html_api
pydoc = a % (URL('static', 'docs/api/index.html'), trPy) if path_exists(path_html_api):
pydoc = a % (URL('static', f(path_html_api)), trPy)
jsdoc = "" jsdoc = ""
if os.path.exists(os.path.join(apath, 'static/docs/jsduck/index.html')): path_html_jsduck = plugin.app_html_jsduck
jsdoc = a % (URL('static', 'docs/jsduck/index.html'), trJS) if path_exists(path_html_jsduck):
jsdoc = a % (URL('static', f(path_html_jsduck)), trJS)
# configuration of the Ext.data.Store for the documentation # configuration of the Ext.data.Store for the documentation
cfg = Store() cfg = Store()
...@@ -291,10 +297,12 @@ def documentations_list(): ...@@ -291,10 +297,12 @@ def documentations_list():
/user /user
Returns: Returns:
empty dict. dict:
the configuration of the plugin dbui
""" """
return dict() plugin = PluginManager("dbui").dbui
return dict(plugin=plugin)
def index(): def index():
......
...@@ -6,6 +6,7 @@ import plugin_dbui as dbui ...@@ -6,6 +6,7 @@ import plugin_dbui as dbui
from callbacks import country_delete, country_insert, country_update from callbacks import country_delete, country_insert, country_update
from datetime import datetime from datetime import datetime
from gluon.tools import PluginManager
#............................................................................. #.............................................................................
# #
...@@ -24,10 +25,18 @@ T.lazy = False # immediate translation ...@@ -24,10 +25,18 @@ T.lazy = False # immediate translation
plg_dbui = dbui.Dbui plg_dbui = dbui.Dbui
plg_dbui.initialise_paths( plg_dbui.initialise_paths(
app_about="static/plugin_dbui/ABOUT.html",
# app_css=None, # app_css=None,
# app_js=None, app_db_schema=None,
app_changelog="static/plugin_dbui/CHANGELOG",
app_git="https://gitlab.in2p3.fr/w2pext/plugin_dbui.git", app_git="https://gitlab.in2p3.fr/w2pext/plugin_dbui.git",
app_html_api="static/plugin_dbui/docs/api/index.html",
app_html_jsduck="static/plugin_dbui/docs/jsduck/index.html",
app_html_reference="static/plugin_dbui/docs/reference/index.html",
app_html_user=None,
# app_libmin=None, # app_libmin=None,
app_pdf_api="static/plugin_dbui/docs/pdf/dbui_api.pdf",
app_pdf_reference="static/plugin_dbui/docs/pdf/dbui_reference.pdf",
app_script="static/app.js", app_script="static/app.js",
app_script_dir="static/scripts", app_script_dir="static/scripts",
# dbui_libmin="static/plugin_dbui/dbui-debug.js" # dbui_libmin="static/plugin_dbui/dbui-debug.js"
......
...@@ -59,11 +59,12 @@ gridNode.add_children(db.tables, func=to_grid) ...@@ -59,11 +59,12 @@ gridNode.add_children(db.tables, func=to_grid)
# HELP # HELP
# #
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
plugin = PluginManager("dbui").dbui
loader = dict(autoLoad=True, loader = dict(autoLoad=True,
renderer='html', renderer='html',
scripts=False, scripts=False,
url=URL('plugin_dbui', 'about')) url=URL('static', plugin.app_about.replace("static/", "")))
aboutLeaf = \ aboutLeaf = \
Panel(loader=loader, plugins=['pPanelLoaderException'], autoScroll=True) Panel(loader=loader, plugins=['pPanelLoaderException'], autoScroll=True)
......
...@@ -12,23 +12,43 @@ from gluon.storage import Storage ...@@ -12,23 +12,43 @@ from gluon.storage import Storage
from gluon.tools import PluginManager from gluon.tools import PluginManager
from helper import get_language from helper import get_language
myapp = current.request.application
defaults = Storage( defaults = Storage(
# application # application
app_about="static/ABOUT.html",
app_css=None, app_css=None,
app_changelog="static/CHANGELOG",
app_db_schema="static/docs/database.png",
app_debug=None, app_debug=None,
app_git=None, app_git=None,
app_lg=None, app_lg=None,
app_license=None,
app_libmin=None, app_libmin=None,
app_script=None, app_script=None,
app_script_dir=None, app_script_dir=None,
app_html_api="static/docs/api/index.html",
app_html_jsduck="static/docs/jsduck/index.html",
app_html_user="static/docs/user/index.html",
app_html_reference="static/docs/reference/index.html",
app_pdf_api="static/docs/pdf/%s_api.pdf" % myapp,
app_pdf_reference="static/docs/pdf/%s_reference.pdf" % myapp,
app_pdf_user="static/docs/pdf/%s_user.pdf" % myapp,
# dbui URL # dbui URL
dbui_conf="/%s/plugin_dbui/dbui_conf", dbui_conf="/%s/plugin_dbui/dbui_conf" % myapp,
dbui_conf_debug="/%s/plugin_dbui/dbui_conf?debug", dbui_conf_debug="/%s/plugin_dbui/dbui_conf?debug" % myapp,
dbui_script="static/plugin_dbui/main.js", dbui_script="static/plugin_dbui/main.js",
# dbui documentation and license
dbui_html_api="static/plugin_dbui/docs/api/index.html",
dbui_html_jsduck="static/plugin_dbui/docs/jsduck/index.html",
dbui_html_reference="static/plugin_dbui/docs/reference/index.html",
dbui_license="static/plugin_dbui/LICENCE_UK.html",
dbui_pdf_api=None,
dbui_pdf_reference=None,
# paths for plugins ace, dbui, extjs and mathjax # paths for plugins ace, dbui, extjs and mathjax
# Warning the order of the plugins matter # Warning the order of the plugins matter
# since extjs has to be called before dbui # since extjs has to be called before dbui
...@@ -89,56 +109,136 @@ class Dbui(object): ...@@ -89,56 +109,136 @@ class Dbui(object):
Args: Args:
app_about (str):
relative path to the ABOUT file,
*e.g.* ``static/ABOUT.html``.
app_css (str or list): app_css (str or list):
Relative path to CSS files for the application, relative path to CSS files for the application,
*e.g.* ``static/myapp/ressources/css``. Default is ``None`` *e.g.* ``static/myapp/ressources/css``. Default is ``None``
app_changelog (str):
relative path to the CHANGELOG,
*e.g.* ``static/CHANGELOG``.
app_db_schema (str):
relative path to the database schema,
*e.g.* ``static/docs/database.png``.
app_debug (str or list): app_debug (str or list):
Relative path to the debug version for the application library, relative path to the debug version for the application library,
*e.g.* ``static/myapp/src`` or ``static/myapp/myapp-debug.js``. *e.g.* ``static/myapp/src`` or ``static/myapp/myapp-debug.js``.
Default is ``None`` Default is ``None``
app_git (str): app_git (str):
The URL of the git repository for the application, the URL of the git repository for the application,
*e.g.* https://gitlab.in2p3.fr/w2pext/plugin_dbui.git *e.g.* ``https://gitlab.in2p3.fr/w2pext/plugin_dbui.git``
Default is ``None``. Default is ``None``.
app_lg(str or list): app_lg(str or list):
Relative path to languages files for the application, relative path to languages files for the application,
*e.g.* static/myapp/locale/myapp-lang-fr.js. *e.g.* ``static/myapp/locale/myapp-lang-fr.js``.
Default is ``None``. Default is ``None``.
app_html_api (str):
relative path to the documentation for the python api,
*e.g.* ``static/docs/api/index.html``.
The format is HTML.
app_html_jsduck (str):
relative path to the documentation for the javascript api,
*e.g.* ``static/docs/jsduck/index.html``.
The format is HTML.
app_html_reference (str):
relative path to the documentation for developers,
*e.g.* ``static/docs/reference/index.html``.
The format is HTML.
app_html_user (str):
relative path to the documentation for users,
*e.g.* ``static/docs/user/index.html``.
The format is HTML.
app_libmin (str or list): app_libmin (str or list):
Relative path to the minified version for the application relative path to the minified version for the application
library, *e.g.* static/myapp-min.js. library, *e.g.* ``static/myapp-min.js``.
app_license (str):
relative path to the license for the application.
app_pdf_api (str):
relative path to the documentation for the python api,
*e.g.* ``static/docs/pdf/myapp_api.pdf``.
The format is PDF.
app_pdf_reference (str):
relative path to the documentation for developers,
*e.g.* ``static/docs/pdf/myapp_reference.pdf``.
The format is PDF.
app_pdf_user (str):
relative path to the documentation for user,
*e.g.* ``static/docs/pdf/myapp_user.pdf``.
The format is PDF.
app_script (str): app_script (str):
Relative path to the main script to run the application, relative path to the main script to run the application,
*e.g.* static/myapp.js *e.g.* ``static/myapp.js``.
app_script_dir (str): app_script_dir (str):
Relative path to a directory containing a collection relative path to a directory containing a collection
of JavaScript, *e.g* static/scripts. of JavaScript, *e.g* ``static/scripts``.
The script named *foo* can be run via the URL: The script named *foo* can be run via the URL:
``https://myverver/myapp?script=foo``. The default is ``None``. ``https://myverver/myapp?script=foo``. The default is ``None``.
dbui_conf (str): dbui_conf (str):
The ULR returning the configuration for the User Interface. the ULR returning the configuration for the User Interface.
The default is ``/myapp/plugin_dbui/dbui_conf``, The default is ``/myapp/plugin_dbui/dbui_conf``,
dbui_conf_debug (str): dbui_conf_debug (str):
The URL returning the debug version of the configuration for the URL returning the debug version of the configuration for
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_html_api (str):
relative path to the documentation for the python api.
*e.g.* ``static/plugin_dbui/docs/api/index.html``.
The format is HTML.
dbui_html_jsduck (str):
relative path to the documentation for the javascript api,
*e.g.* ``static/plugin_dbui/docs/jsduck/index.html``.
The format is HTML.
dbui_html_reference (str):
relative path to the documentation for developers,
*e.g.* ``static/plugin_dbui/docs/reference/index.html``.
The format is HTML.
dbui_license (str):
relative path to the license for the plugin dbui,
*e.g* ``static/plugin_dbui/LICENCE_UK.html``.
dbui_pdf_api (str):
relative path to the documentation for the python api,
*e.g.* ``static/plugin_dbui/docs/pdf/dbui_api.pdf``.
The format is PDF.
dbui_pdf_reference (str):
relative path to the documentation for developers,
*e.g.* ``static/plugin_dbui/docs/pdf/dbui_reference.pdf``.
The format is PDF.
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``.
the option ``app_script``. It is used when the option ``app_script`` is not defined.
plugins_paths (dict): plugins_paths (dict):
Key is the name of the plugin while value is a dictionary contains paths defining javascript libraries for plugins.
with 4 keys: The key is the name of the plugin while the value is a
dictionary with 4 keys:
* css (str or list or None): * css (str or list or None):
relative path to CSS files for plugin: relative path to CSS files for plugin:
...@@ -157,7 +257,12 @@ class Dbui(object): ...@@ -157,7 +257,12 @@ class Dbui(object):
library: ``static/plugin_key/locale/key-lang-fr.js``. library: ``static/plugin_key/locale/key-lang-fr.js``.
By default, plugins *ace*, *dbui*, *extjs* and *mathjax* are By default, plugins *ace*, *dbui*, *extjs* and *mathjax* are
configure. It is possible to add others plugins. configure.
Note:
It is possible to register others plugins by adding them
to the plugins_paths dictionary. There libraries will be
laod properly by the controller ``plugin_dbui/index``.
""" """
...@@ -177,12 +282,6 @@ class Dbui(object): ...@@ -177,12 +282,6 @@ class Dbui(object):
paths_extjs = plugins_paths["extjs"] paths_extjs = plugins_paths["extjs"]
paths_extjs["lg"] = paths_extjs["lg"] % lg paths_extjs["lg"] = paths_extjs["lg"] % lg
# update values depending on the application
application = current.request.application
plugin.dbui_conf = plugin.dbui_conf % application
plugin.dbui_conf_debug = plugin.dbui_conf_debug % application
@staticmethod @staticmethod
def initialise_ui(): def initialise_ui():
"""Initialise persistent storage for the plugin dbui. """Initialise persistent storage for the plugin dbui.
......
{{
import os
from plugin_dbui import get_reference_paths
# alias
apath, lpath = get_reference_paths()
myapp = request.application
path_exists = lambda x: x and os.path.exists(os.path.join(apath, x))
f = lambda x: x.replace("static/", "")
rwrite = response.write
}}
<h2 class="dbui-h2 dbui-small-cap">{{=T("Documentations")}}</h2> <h2 class="dbui-h2 dbui-small-cap">{{=T("Documentations")}}</h2>
<p class="dbui-p dbui-small-cap" style="margin-top: 5ex"> <p class="dbui-p dbui-small-cap" style="margin-top: 5ex">
1. {{=T("For users")}} 1. {{=T("For users")}}
</p> </p>
<ul> <ul>
<li class="dbui-p"> {{
{{=T("User guides")}} ( #.....................................................................
<a href="/{{=request.application}}/static/docs/user/index.html" target="_blank"> #
html # user guide
</a>, #
<a href="/{{=request.application}}/static/docs/pdf/{{=request.application}}_user.pdf" target="_blank"> a1, a2 = None, None
pdf
</a>) path_html_user = plugin.app_html_user
</li> if path_exists(path_html_user):
<li class="dbui-p"> a1 = A("html",
<a href="/{{=request.application}}/static/docs/database.png" target="_blank"> callback=URL("static", f(path_html_user)),
{{=T("Database schema")}} _target="_blank")
</a> pass
</li>
path_pdf_user = plugin.app_pdf_user
<li class="dbui-p"> if path_exists(path_pdf_user):
<a href="/{{=request.application}}/static/CHANGELOG" target="_blank">
Change Log a2 = A("pdf",
</a> callback=URL("static", f(path_pdf_user)),
</li> _target="_blank")
pass
if a1 is not None and a2 is not None:
rwrite(LI(T("User guides)", "(", a1, a2, ")", _class="dbui-p")))
elif a1 is not None:
rwrite(LI(T("User guides)", "(", a1, ")", _class="dbui-p")))
pass
#.....................................................................
#
# database schema
#
path_db_schema = plugin.app_db_schema
if path_exists(path_db_schema):
a = A(T("Database schema"),
callback=URL("static", f(path_db_schema)),
_target="_blank")
rwrite(LI(a, _class="dbui-p"))
pass
#.....................................................................
#
# changelog
#
path_changelog = plugin.app_changelog
if path_exists(path_changelog):
a = A("CHANGELOG",
callback=URL("static", f(path_changelog)),
_target="_blank")
rwrite(LI(a, _class="dbui-p"))
pass
}}
</ul> </ul>
...@@ -32,62 +83,120 @@ ...@@ -32,62 +83,120 @@
2. {{=T("For developpers")}} 2. {{=T("For developpers")}}
</p> </p>
<ul> <ul>
<li class="dbui-p"> {{
<a href="/{{=request.application}}/static/docs/api/index.html" target="_blank"> #.....................................................................
{{=request.application}} python API #
</a> # Python API
</li> #
path_html_api = plugin.app_html_api
<li class="dbui-p"> if path_exists(path_html_api):
<a href="/{{=request.application}}/static/docs/jsduck/index.html" target="_blank">
{{=request.application}} javascript API a = A("%s Python API" % myapp,
</a> callback=URL("static", f(path_html_api)),
</li> _target="_blank")
rwrite(LI(a, _class="dbui-p"))
pass
#.....................................................................
#
# JavaScript API
#
path_html_jsduck = plugin.app_html_jsduck
if path_exists(path_html_jsduck):
a = A("%s JavaScript API" % myapp,
callback=URL("static", f(path_html_jsduck)),
_target="_blank")
rwrite(LI(a, _class="dbui-p"))
pass
}}
</ul> </ul>
<ul> <ul>
<li class="dbui-p"> {{
<a href="https://marprod.in2p3.fr/plugin_dbui_book" target="_blank"> #.....................................................................
plugin_dbui reference manual #
</a> # dbui reference manual (python)
</li> #
a = A("plugin_dbui reference manual",
<li class="dbui-p"> _href="https://marprod.in2p3.fr/plugin_dbui_book",
<a href="/{{=request.application}}/static/plugin_dbui/docs/api/index.html" target="_blank"> _target="_blank")
plugin_dbui python API
</a> rwrite(LI(a, _class="dbui-p"))
</li>
#.....................................................................
<li class="dbui-p"> #
<a href="/{{=request.application}}/static/plugin_dbui/docs/jsduck/index.html" target="_blank"> # dbui python api
plugin_dbui javascript API #
</a> path_dbui_api = plugin.dbui_html_api
</li> if path_exists(path_dbui_api):
a = A("plugin_dbui Python API",
callback=URL("static", f(path_dbui_api)),
_target="_blank")
rwrite(LI(a, _class="dbui-p"))
pass
#.....................................................................
#
# dbui JavaScript api
#
path_dbui_jsduck = plugin.dbui_html_jsduck
if path_exists(path_dbui_jsduck):
a = A("plugin_dbui JavaScript API",
callback=URL("static", f(path_dbui_jsduck)),
_target="_blank")
rwrite(LI(a, _class="dbui-p"))
pass
}}
</ul> </ul>
<ul> <ul>
<li class="dbui-p"> {{
<a href="http://web2py.com/book" target="_blank"> #.....................................................................
Web2py reference manual #
</a> # web2py reference manual (Python)
</li> #
a = A("Web2py reference manual",
<li class="dbui-p"> _href="http://web2py.com/book",
<a href="http://docs.sencha.com/extjs/6.2.0/classic/Ext.html" target="_blank"> _target="_blank")
Ext JS 6.2.0 javasript API
</a> rwrite(LI(a, _class="dbui-p"))
</li>