Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit 5f54e581 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Merge branch 'master' into 'production'

Release 0.9.7

* Version is non backward compatible since a new mechanism is used to initialise the plugin. It relies on class `Dbui` to configure the plugin and to launch the  service `directSvc`. 
* Remove the `models/plugin_dbui.py ` file which  is not needed any more.
* Remove the controller `plugin_dbui/debug`. The `debug` argument is now handle by the controller `plugin_dbui/index`.
* Rename the controller `plugin_dbui/documentations` as `documentations_table` and add the controller `plugin_dbui/documentations_list`.
* Add the JavaScript function `Dbui.getFields` and uses it in the class `Dbui.grid.Filter` and `Dbui.panel.WithUrlSelector`.
* Fix a bug in the JavaScript method `Dbui.form.field.Table.getValue`.
* Improve the converter `to_panelWithUrlSelector` to remove frozen options.
* Add the `LazyT` converter in MyJsonEncoder and rename it `JSONEncoder`. The web2py applications can be run when lazy translation is activated.
* Update the JavScript classes `GridWithFilter`, `WithUrlSelector` and `MathJax` to always mask the viewport.
* Close #2, #21

See merge request !36
parents c55bf52d 2f2aae2c
static/plugin_dbui/LICENCE_UK.html
\ No newline at end of file
static/plugin_dbui/LICENSE
\ No newline at end of file
0.9.6
\ No newline at end of file
static/plugin_dbui/VERSION
\ No newline at end of file
......@@ -77,17 +77,9 @@ PLUGINS_FILES["ace"] = [
PLUGINS_FILES["dbui"] = [
"modules/plugin_dbui",
"models/plugin_dbui.py",
"controllers/plugin_dbui.py",
"views/plugin_dbui",
"static/plugin_dbui/resources/css/kde-oxygen.css",
"static/plugin_dbui/resources/css/dbui.css",
"static/plugin_dbui/resources/icons",
"static/plugin_dbui/src",
"static/plugin_dbui/locale/dbui-lang-en.js",
"static/plugin_dbui/locale/dbui-lang-fr.js",
"static/plugin_dbui/dbui-min.js",
"static/plugin_dbui/docs"]
"static/plugin_dbui",
"views/plugin_dbui"]
PLUGINS_FILES["extjs"] = [
"static/plugin_extjs/build/classic/locale",
......
......@@ -2,45 +2,14 @@
import os
import re
from gluon.admin import plugin_pack
def index():
"""Main Controller to run the application.
"""
if 'debug' in request.vars:
del request.vars['debug']
url = URL('plugin_dbui', 'debug', args=request.args, vars=request.vars)
else:
url = URL('plugin_dbui', 'index', args=request.args, vars=request.vars)
url = URL('plugin_dbui', 'index', args=request.args, vars=request.vars)
return redirect(url)
def pack_plugin():
"""Helper controller to produce the plugin_dbui binary version.
Used by the script buildVersion when building a new release.
Light version of the appadmin/default/pack_plugin controller.
"""
pname = request.vars.plugin
fname = 'web2py.plugin.%s.w2p' % pname
filename = plugin_pack(request.application, pname, request)
if filename:
response.headers['Content-Type'] = 'application/w2p'
disposition = 'attachment; filename=%s' % fname
response.headers['Content-Disposition'] = disposition
fi = open(filename, 'rb')
try:
return fi.read()
finally:
fi.close()
else:
return None
def user():
return 'hello you hit the default/user controller'
\ No newline at end of file
......@@ -2,16 +2,23 @@
Controllers expose by the plugin:
about
call
csv
dbui_conf
documentation
index
database
configuration
Author: R. Le Gac
latex2pdf
satus
version
"""
import json
import os
import plugin_dbui as dbui
from gluon.tools import PluginManager
API = """
......@@ -30,8 +37,7 @@ Dbui.REMOTE_API = {
def about():
fn = os.path.join("applications",
request.application,
"static",
"ABOUT.html")
PluginManager("dbui").dbui.app_about)
return open(fn, 'rb').read()
......@@ -128,7 +134,7 @@ def dbui_conf():
# The only way to extract them is to scan the attributes list of
# the DAL since the method db.tables() or any variant return
# tables but not the alias one
config['stores'].update(plugins.dbui.static_stores)
config['stores'].update(PluginManager("dbui").dbui.static_stores)
for table in get_all_tables(db):
cfg = to_jsonstore(table)
config['stores'][cfg['storeId']] = cfg
......@@ -147,7 +153,7 @@ def dbui_conf():
# fill the javascript template
app = request.application
script = API % (app,
json.dumps(config),
json.dumps(config, cls=dbui.JSONEncoder),
debug,
app,
app,
......@@ -159,73 +165,17 @@ def dbui_conf():
return script
def debug():
"""Action to run the plugin in debug mode.
Load dynamically the javascript source code for all libraries.
Active the debug mode on the server and client side.
EXAMPLES
def documentations_table():
"""Documentation for users and developer display as table.
http://localhost:8000/myapp/plugin_dbui/debug
http://localhost:8000/myapp/plugin_dbui/debug?script=foo
URL OPTIONS
script
run the javascript foo in the framework defined by the plugin.
The scripts are stored in the directory defined by the plugin
configuration app_script_dir.
"""
from plugin_dbui import get_file_paths, get_script_path
plugin = plugins.dbui
# 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'))
# 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'))
# 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'))
# URL for the dbui configuration activating the debug
# mode on the client side
response.files.append(plugin.dbui_conf_debug)
# main script which can be defined in many different ways
pscript = get_script_path(plugin)
response.files.append(pscript)
# switch ON the debug mode on the server side
session.debug = True
# select the view
response.view = 'plugin_dbui/index.html'
# return the plugin configuration parameter as well as the response
return dict(plugin=plugin)
def documentations():
"""Return the Ext.data.Array configuration for the documentation
and for the source code.
Returns:
Ext.data.Array:
configuration for the documentation and for the source code.
"""
from plugin_dbui import get_reference_paths, Store
plugin = plugins.dbui
plugin = PluginManager("dbui").dbui
# alias
a = '<a href="%s" target="_blank">%s</a>'
......@@ -234,20 +184,26 @@ def documentations():
trJS = T("Javascript API")
trPy = T("Python API")
# documentation of the application
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 = ""
if os.path.exists(os.path.join(apath, 'static/docs/database.png')):
userdoc = a % (URL('static', 'docs/database.png'), T("Data base scheme"))
path_db_schema = plugin.app_db_schema
if path_exists(path_db_schema):
userdoc = a % (URL('static', f(path_db_schema)), T("Data base scheme"))
pydoc = ""
if os.path.exists(os.path.join(apath, 'static/docs/api/index.html')):
pydoc = a % (URL('static', 'docs/api/index.html'), trPy)
path_html_api = plugin.app_html_api
if path_exists(path_html_api):
pydoc = a % (URL('static', f(path_html_api)), trPy)
jsdoc = ""
if os.path.exists(os.path.join(apath, 'static/docs/jsduck/index.html')):
jsdoc = a % (URL('static', 'docs/jsduck/index.html'), trJS)
path_html_jsduck = plugin.app_html_jsduck
if path_exists(path_html_jsduck):
jsdoc = a % (URL('static', f(path_html_jsduck)), trJS)
# configuration of the Ext.data.Store for the documentation
cfg = Store()
......@@ -328,6 +284,27 @@ def documentations():
return dict(cfg_doc=cfg_doc, cfg_src=cfg_src)
def documentations_list():
"""Documentations for users and developers display as list.
Exploit documentations for the application located in:
/static
/docs
/api
/jsduck
/latex
/pdf
/user
Returns:
dict:
the configuration of the plugin dbui
"""
plugin = PluginManager("dbui").dbui
return dict(plugin=plugin)
def index():
"""Default Action to run the plugin
Load compressed version of all libraries.
......@@ -335,51 +312,85 @@ def index():
EXAMPLES
http://localhost:8000/myapp/plugin_dbui
http://localhost:8000/myapp/plugin_dbui?debug
http://localhost:8000/myapp/plugin_dbui?script=foo
URL OPTIONS
debug
Load dynamically the javascript source code for all libraries.
Active the debug mode on the server and client side.
script
run the javascript foo in the framework defined by the plugin.
The scripts are stored in the directory defined by the plugin
configuration app_script_dir.
Returns:
list of HTML string
"""
from plugin_dbui import get_file_paths, get_script_path
plugin = plugins.dbui
lst = []
plugin = PluginManager("dbui").dbui
plugins_paths = plugin.plugins_paths
is_debug = "debug" in request.vars
# css
for plg in plugins_paths:
path =plugins_paths[plg]["css"]
if path is not None:
lst.extend(get_file_paths(path, ext='.css'))
# 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'))
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'))
# javascript libraries
# depend on the debug mode either minified or full version
key = ("debug" if is_debug else "libmin")
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'))
for plg in plugins_paths:
path =plugins_paths[plg][key]
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'))
path = (plugin.app_debug if is_debug else plugin.app_libmin)
lst.extend(get_file_paths(path, 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)
path = (plugin.dbui_conf_debug if is_debug else plugin.dbui_conf)
lst.append(path)
# 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
# switch on/off the debug mode on the server side
session.debug = is_debug
# 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():
......@@ -450,4 +461,4 @@ def versions():
cfg.data = get_versions()
return dict(cfg_store=json.dumps(cfg))
return dict(cfg_store=json.dumps(cfg, cls=dbui.JSONEncoder))
......@@ -2,6 +2,15 @@
Database model
--------------
Initialisation
^^^^^^^^^^^^^^
.. currentmodule:: plugin_dbui
.. autosummary::
:toctree: generated/
Dbui
Callbacks
^^^^^^^^^
......
plugin_dbui.Dbui.define_paths
=============================
.. currentmodule:: plugin_dbui
.. automethod:: Dbui.define_paths
\ No newline at end of file
plugin_dbui.Dbui.initialise_ui
==============================
.. currentmodule:: plugin_dbui
.. automethod:: Dbui.initialise_ui
\ No newline at end of file
plugin_dbui.Dbui.start_directSvc
================================
.. currentmodule:: plugin_dbui
.. automethod:: Dbui.start_directSvc
\ No newline at end of file
plugin_dbui.Dbui
================
.. currentmodule:: plugin_dbui
.. autoclass:: Dbui
:show-inheritance:
.. rubric:: Methods
.. autosummary::
:toctree: model/
~Dbui.define_paths
~Dbui.initialise_ui
~Dbui.start_directSvc
......@@ -23,6 +23,7 @@
'countries': 'pays',
'Country': 'Pays',
'Data base scheme': 'Schéma de la base de données',
'Database schema': 'Database schema',
'Dates': 'Dates',
'Definition': 'Définition',
'dev': 'dev',
......@@ -30,6 +31,8 @@
'Documentation for developers': 'Documentation pour développeurs',
'documentations': 'documentations',
'Documentations': 'Documentations',
'documentations (list)': 'documentations (liste)',
'documentations (table)': 'documentations (table)',
'Doi': 'Doi',
'domain': 'domaine',
'E Print': 'E Print',
......@@ -52,6 +55,8 @@
'Filter reports': 'Filter reports',
'Filter teams': 'Filter teams',
'First Page': 'Première Page',
'For developpers': 'For developpers',
'For users': 'For users',
'Form': 'Formulaire',
'Forms': 'Formulaires',
'General': 'Général',
......@@ -140,6 +145,7 @@
'undefined': 'indéfini',
'unknown': 'unknown',
'url': 'url',
'User guides': 'User guides',
'Value': 'Valeur',
'Value already in database or empty': 'La valeur existe dans la base de données ou est nulle',
'value already in database or empty': 'La valeur existe dans la base de données ou est nulle',
......
......@@ -8,59 +8,73 @@ from callbacks import country_delete, country_insert, country_update
from datetime import datetime
from gluon.tools import PluginManager
#-------------------------------------------------------------------------------
#.............................................................................
#
# PLUGIN DBUI
# Language
#
#-------------------------------------------------------------------------------
plugins = PluginManager()
# plugins.dbui.app_css = None # relative path, i.e static/myapp.css or dir or list
# plugins.dbui.app_js = None # relative path static/src/my.js or dir or list
plugins.dbui.app_git = "https://gitlab.in2p3.fr/w2pext/%s.git" % request.application
# plugins.dbui.app_libmin = None # relative path static/myapp-min.js or dir or list
plugins.dbui.app_script = 'static/app.js' # relative path static/myapp.js
plugins.dbui.app_script_dir = 'static/scripts' # relative directory static/scripts
# plugins.dbui.dbui_libmin='static/plugin_dbui/dbui-debug.js'
T.set_current_languages("en", "en-gb", "en-us") # mother tongue
T.force("fr-fr") # user language
T.lazy = True # no immediate translation
#-------------------------------------------------------------------------------
#.............................................................................
#
# LANGUAGE
# Configure plugin_dbui
#
#-------------------------------------------------------------------------------
T.set_current_languages('en', 'en-gb', 'en-us') # mother tongue
T.force('fr-fr') # user language
T.lazy = False # immediate translation
#-------------------------------------------------------------------------------
plg_dbui = dbui.Dbui
plg_dbui.define_paths(
app_about="static/plugin_dbui/ABOUT.html",
# app_css=None,
app_db_schema=None,
app_changelog="static/plugin_dbui/CHANGELOG",
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_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_dir="static/scripts",
# dbui_libmin="static/plugin_dbui/dbui-debug.js"
)
plg_dbui.initialise_ui()
directSvc = plg_dbui.start_directSvc()
#.............................................................................
#
# CONSTANTS
# Constants
#
#-------------------------------------------------------------------------------
undef = T(dbui.UNDEF)
undef_id = dbui.UNDEF_ID
year = datetime.now().year
#-------------------------------------------------------------------------------
#.............................................................................
#
# COMMON CONFIGURATION FOR FORMS AND GRIDS
# Common configuration for forms and grids
#
#-------------------------------------------------------------------------------
tables = ['categories',
'collaborations',
'countries',
'harvesters',
'new_fields',
'projects',
'publishers',
'publications',
'reports',
'teams']
dbui.configure_forms(tables, plugins=['pFormToolTip'],
tables = ["categories",
"collaborations",
"countries",
"harvesters",
"new_fields",
"projects",
"publishers",
"publications",
"reports",
"teams"]
dbui.configure_forms(tables, plugins=["pFormToolTip"],
width=300)
dbui.configure_grids(tables, plugins=['pGridRowEditorConfirmDelete',
'pGridRowEditorContextMenu',
'pGridRowEditorDblClick',
'pGridToolbar'])
\ No newline at end of file
dbui.configure_grids(tables, plugins=["pGridRowEditorConfirmDelete",
"pGridRowEditorContextMenu",
"pGridRowEditorDblClick",
"pGridToolbar"])
""" plugin_dbui
Initialize the plugin_dbui
Define persistent storage, main services
and methods available on the client side.
"""
import plugin_dbui as dbui
from gluon.storage import Storage
from gluon.tools import PluginManager
# NOTE:
# define default configuration parameters for the plugin,
# the application using it and the persistent storage used to tune the widgets.
# In most of the case configuration parameters are either a relative path
# to a file (static/myapp.css) or to a directory (static/css) except app_script
# and base_script which should point to a file.
#