Commit 6cc06a90 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Merge branch 'master' into 'production'

Release 0.9.0

* Change the name space for the JavaScript code from `App` to `Dbui`.
* Fix the LaTeX conversion for special character.

See merge request !25
parents fe0ebd19 643f6e49
*~
.directory
.project
*.pyc
.pydevproject
......
......@@ -55,7 +55,7 @@ The packed version of the `plugin_dbui` and its friends can be obtained using
the versioning tool [git](http://git-scm.com/):
```
git clone https://gitlab.in2p3.fr/legac/plugin_dbui_build.git
git clone https://gitlab.in2p3.fr/w2pext/plugins.git
```
* Install the `plugin_dbui` in your application using the `web2py`
......
0.8.3
\ No newline at end of file
0.9.0
\ No newline at end of file
......@@ -45,12 +45,14 @@ import urllib
from os.path import join as opj
from subprocess import call, check_output, CalledProcessError
from numexpr.version import release
from tempfile import TemporaryFile
import cmd
# constants
APP = os.path.basename(os.getcwd())
API = 'api'
BUILDDIR = '../plugin_dbui_build'
BUILDDIR = '../plugins'
DOCSRC = 'docs'
LATEX = 'latex'
MSG_RELEASE = 'Enter the new release: '
......@@ -70,7 +72,7 @@ CHANGELOG = opj(APP_STATIC, "plugin_dbui", "CHANGELOG")
DOCS_DIR = opj(APP_STATIC, "plugin_dbui", "docs")
DBUISRC = opj(APP_STATIC, "plugin_dbui", "src")
EXTJSSRC = opj(APP_STATIC, "plugin_extjs", "src")
JSBASE = opj(APP_STATIC, "plugin_dbui", "src", "App.js")
JSBASE = opj(APP_STATIC, "plugin_dbui", "src", "Dbui.js")
JSDOC = opj(DOCS_DIR, "jsduck")
JSLIBDEBUG = opj(APP_STATIC, "plugin_dbui", "dbui-debug.js")
JSLIBMIN = opj(APP_STATIC, "plugin_dbui", "dbui-min.js")
......@@ -169,8 +171,11 @@ def build():
"""
compile_js()
build_html()
if os.path.exists(DOCS_DIR):
call(["rm", "-rf", DOCS_DIR])
build_html()
for doc in (API, REFERENCE, USER):
build_pdf(doc)
......@@ -228,25 +233,29 @@ def build_pdf(doc):
filenames = [el for el in os.listdir('.') if el.endswith('.tex')]
filename = (filenames[0] if len(filenames) == 1 else None)
fpdf = filename.replace('.tex', '.pdf')
if not filename:
print "\n\tNo latex file !\n"
os.chdir(cwd)
return
try:
check_output(["pdflatex", "-interaction", "nonstopmode", filename])
check_output(["pdflatex", filename])
except CalledProcessError:
if os.path.exists(fpdf):
print "\n\tSome errors in the PDF file."
else:
print "\n\tFailled to generate PDF file !"
print "\tCheck LaTeX file in", latexdir, "\n"
os.chdir(cwd)
return
check_output(["pdflatex", filename])
os.chdir(cwd)
# rename the pdf file as application_doctype.pdf
fpdf = filename.replace('.tex', '.pdf')
fout = "%s_%s.pdf" % (os.path.splitext(filename)[0], doc)
os.rename(opj(latexdir, fpdf), opj(PDFDOC, fout))
......@@ -361,10 +370,10 @@ def build_plugin_mathjax():
def commit_change_log():
"""Commit CHANGELOG and App.js.
"""Commit CHANGELOG and Dbui.js.
"""
print "Commit CHANGELOG and App.js..."
print "Commit CHANGELOG and Dbui.js..."
if not which("git", localhost=True):
print '\n\tThe application git is missing !'
print '\tSkip this step.\n'
......@@ -447,11 +456,6 @@ def compile_js():
JSLIBDEBUG_CNT,
JSLIBMIN_CNT)
cmd = ["docker", "exec", ARGS.docker_container,
"chown", get_perm(), JSLIBDEBUG_CNT, JSLIBMIN_CNT]
call(cmd)
print '\n\tDebug version of the js library', JSLIBDEBUG, 'is ready'
print '\tMinimised version of the js library', JSLIBMIN, 'is ready\n'
......@@ -481,7 +485,7 @@ def get_plugin_version(plugin):
os.chdir(cwd)
elif plugin == "dbui":
filename = os.path.join('static', 'plugin_dbui', 'src', 'App.js')
filename = os.path.join('static', 'plugin_dbui', 'src', 'Dbui.js')
tmpfile = open(filename, 'rb')
text = tmpfile.read()
......@@ -535,19 +539,6 @@ def get_plugin_version(plugin):
return release
def get_perm():
""""Return the permission of the current user.
Returns:
str: permission encoded as uid:gid
"""
uid = check_output(["id", "-u"]).strip("\n")
gid = check_output(["id", "-g"]).strip("\n")
return "%s:%s" % (uid, gid)
def get_version():
"""Get the current version identifier.
......@@ -594,7 +585,7 @@ def is_plugin(plugin):
bool: true when the plugin exist.
"""
path = os.path.join('static', 'plugin_%s' % plugin)
path = os.path.join("static", "plugin_%s" % plugin)
if not os.path.exists(path):
print "\n\tNo source file for the plugin %s !" % plugin
......@@ -621,9 +612,13 @@ def jsduck():
return
# clean
if os.path.exists(JSDOC):
print "\n\tRemove old javascript documentation...\n"
call(["rm", "-rf", JSDOC])
if not os.path.exists(DOCS_DIR):
os.mkdir(DOCS_DIR)
# NOTE
# the processing depend on the localisation of jsduck
# either on the localhost or behind a docker container
......@@ -652,20 +647,17 @@ def jsduck():
call(cmd)
cnt = ARGS.docker_container
call(["docker", "exec", cnt, "chown", "-R", get_perm(), JSDOC_CNT])
print "\n\tJavaScript documentation in", JSDOC
def set_version(version):
"""Set release identifier in CHANGELOG and App.js
"""Set release identifier in CHANGELOG and Dbui.js
Args:
version (str): release identifier
"""
print "Update CHANGELOG and App.js files with the release", version, "..."
print "Update CHANGELOG and Dbui.js files with the release", version, "..."
# check tag in git
if version in check_output(["git", "tag"]).split("\n"):
......@@ -676,7 +668,7 @@ def set_version(version):
with open(JSBASE) as fi:
txt = fi.read()
# look for a pattern App.version = '0.8.3'; in appbase.js
# look for a pattern Dbui.version = '0.8.3'; in appbase.js
# split the the string in 3 parts (pre, version, post)
match = re.match(r"(.+ version: ')([\w._-]*)('.+)", txt, re.DOTALL)
......@@ -789,17 +781,13 @@ def sphinx(builder, doc):
cmd.extend(["-b", builder, "-q", srcdir, outdir])
call(cmd)
if is_behind_cnt:
cnt = ARGS.docker_container
call(["docker", "exec", cnt, "chown", "-R", get_perm(), outdir])
print "\n\t%s documentation in" % builder.upper(), outdir
def start_release():
"""Start the release cycle.
Set the new release number in the CHANGELOG and App.js files.
Set the new release number in the CHANGELOG and Dbui.js files.
Commit then in the master branch.
"""
......@@ -883,6 +871,11 @@ def which(cmd, localhost=False):
"""Test if the command exists on the localhost or on a docker container.
Return the sequence to execute it. Priority is given to the localhost.
Note:
* The command is execute as the user me when running via a container
* The user me is the one running the scrip build_version and w2pcnt
* The user me is added when the container is created
Args:
cmd (str): name of the command
localhost (bool): force the command to be on localhost even if
......@@ -893,10 +886,13 @@ def which(cmd, localhost=False):
The list is empty when the command is not found.
"""
container = OPT.docker_container
# local host
if not ARGS.force_container or localhost:
if not container or localhost:
try:
out = check_output(["which", cmd])
with TemporaryFile() as fi:
out = check_output(["which", cmd], stderr=fi)
print "\n\tCommand", cmd, "found on the localhost"
return [out.strip("\n")]
......@@ -905,7 +901,6 @@ def which(cmd, localhost=False):
return []
# docker container is running ?
container = ARGS.docker_container
is_running = False
for line in check_output(["docker", "ps"]).split("\n"):
......@@ -916,16 +911,19 @@ def which(cmd, localhost=False):
if not is_running:
print "\n\tDocker container", container, "is not running !"
if ARGS.force_container:
if OPT.force_container:
sys.exit(1)
return []
# docker container
# command is executed as the user me
# the user me is the one running the script. It is created in the
# container when it is created
try:
out = check_output(["docker", "exec", container, "which", cmd])
path = out.strip("\n")
print "\n\tCommand", cmd, "found on the container", container
return ["docker", "exec", container, path]
return ["docker", "exec", "--user", "me", container, path]
except CalledProcessError:
print "\n\tCommand", cmd, \
......@@ -953,6 +951,11 @@ if __name__ == '__main__':
action="store_true",
help="build the API documentation in PDF.")
AGP.add_argument(
"-b", "--build",
action="store_true",
help="build javaScript libraries and documentation.")
AGP.add_argument(
"-c", "--compile",
action="store_true",
......@@ -961,7 +964,7 @@ if __name__ == '__main__':
AGP.add_argument(
"--commit-changelog",
action="store_true",
help="commit CHANGELOG and App.js. "
help="commit CHANGELOG and Dbui.js. "
"To be used with --write-release. "
"Recommend to use --start-release.")
......@@ -1016,7 +1019,7 @@ if __name__ == '__main__':
"-s", "--start-release",
action="store_true",
help="start the release candidate by setting "
"release number in change log and App.js. "
"release number in change log and Dbui.js. "
"Commit changes in the master branch. "
"Equivalent to --write-release followed by "
"--commit-changelog.")
......@@ -1054,67 +1057,70 @@ if __name__ == '__main__':
AGP.add_argument(
"--write-release",
action="store_true",
help="write the release number in CHANGELOG and App.js. "
help="write the release number in CHANGELOG and Dbui.js. "
"To be used with --commit-changelog. "
"Recommend to use --start-release.")
ARGS = AGP.parse_args()
OPT = AGP.parse_args()
if ARGS.ace:
if OPT.ace:
build_plugin_ace()
if ARGS.api_doc:
if OPT.api_doc:
sphinx("html", API)
if ARGS.api_pdf:
if OPT.api_pdf:
build_pdf(API)
if ARGS.compile:
if OPT.build:
build()
if OPT.compile:
compile_js()
if ARGS.commit_changelog:
if OPT.commit_changelog:
commit_change_log()
if ARGS.dbui:
if OPT.dbui:
build()
build_plugin_dbui()
if ARGS.extjs:
if OPT.extjs:
build_plugin_extjs()
if ARGS.jsduck:
if OPT.jsduck:
jsduck()
if ARGS.mathjax:
if OPT.mathjax:
build_plugin_mathjax()
if ARGS.reference_doc:
if OPT.reference_doc:
sphinx("html", REFERENCE)
if ARGS.reference_pdf:
if OPT.reference_pdf:
build_pdf(REFERENCE)
if ARGS.start_release:
if OPT.start_release:
start_release()
if ARGS.tag:
if OPT.tag:
tag()
if ARGS.user_doc:
if OPT.user_doc:
sphinx("html", USER)
if ARGS.user_pdf:
if OPT.user_pdf:
build_pdf(USER)
if ARGS.version:
if OPT.version:
print "\nThe current release is %s\n" % get_version()
if ARGS.web2py:
if ARGS.web2py == "dbui":
if OPT.web2py:
if OPT.web2py == "dbui":
build()
web2py(ARGS.web2py)
web2py(OPT.web2py)
if ARGS.write_release:
if OPT.write_release:
set_version(raw_input(MSG_RELEASE))
sys.exit(0)
......@@ -15,12 +15,12 @@ import os
API = """
App.csvUrl = '/%s/plugin_dbui/csv';
App.config = %s;
App.debug = %s;
App.latex2pdfUrl = '/%s/plugin_dbui/latex2pdf.pdf';
App.name = '%s';
App.REMOTE_API = {
Dbui.csvUrl = '/%s/plugin_dbui/csv';
Dbui.config = %s;
Dbui.debug = %s;
Dbui.latex2pdfUrl = '/%s/plugin_dbui/latex2pdf.pdf';
Dbui.name = '%s';
Dbui.REMOTE_API = {
'url': '/%s/plugin_dbui/call',
'type': 'remoting',
'actions': %s
......@@ -305,7 +305,7 @@ def documentations():
source=src)
r2 = dict(code="plugin_dbui",
source="<em>git clone https://gitlab.in2p3.fr/legac/"
source="<em>git clone https://gitlab.in2p3.fr/w2pext/"
"plugin_dbui.git</em>")
r3 = dict(code="Web2py",
......
......@@ -19,7 +19,7 @@ from datetime import datetime
def get_plugin_dbui_release():
JSBASE = '../../static/plugin_dbui/src/App.js'
JSBASE = '../../static/plugin_dbui/src/Dbui.js'
s = open(JSBASE, 'rb').read()
m = re.match("(.+ version: ')([\w._-]*)('.+)", s, re.DOTALL)
return m.group(2)
......
......@@ -10,17 +10,17 @@
.. _Ext.form.field.Checkbox:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Checkbox
.. _App.form.field.CombBox:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/App.form.field.CombBox
.. _Dbui.form.field.CombBox:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.form.field.CombBox
.. _App.data.DirectStore:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/App.data.DirectStore
.. _Dbui.data.DirectStore:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.data.DirectStore
.. _Ext.form.field.Field:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Field
.. _App.form.field.AceEditor:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/App.form.field.AceEditor
.. _Dbui.form.field.AceEditor:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.form.field.AceEditor
.. _Ext.form.FieldContainer:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.FieldContainer
......@@ -28,11 +28,11 @@
.. _Ext.form.field.Date:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Date
.. _App.form.field.Dict:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/App.form.field.Dict
.. _Dbui.form.field.Dict:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.form.field.Dict
.. _App.form.field.List:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/App.form.field.List
.. _Dbui.form.field.List:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.form.field.List
.. _Ext.form.field.Number:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Number
......@@ -49,8 +49,8 @@
.. _Ext.form.field.Time:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.Time
.. _App.form.Panel:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/App.form.Panel
.. _Dbui.form.Panel:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.form.Panel
.. _Ext.grid.Column:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.grid.Column
......@@ -58,11 +58,11 @@
.. _Ext.grid.ColumnModel:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.grid.ColumnModel
.. _App.grid.Filter:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/App.grid.Filter
.. _Dbui.grid.Filter:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.grid.Filter
.. _App.grid.Panel:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/App.grid.Panel
.. _Dbui.grid.Panel:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.grid.Panel
.. _Ext.grid.Panel:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.grid.Panel
......@@ -73,8 +73,8 @@
.. _Ext.grid.TemplateColumn:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.grid.TemplateColumn
.. _App.panel.GridWithFilter:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/App.panel.GridWithFilter
.. _Dbui.panel.GridWithFilter:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.panel.GridWithFilter
.. _Ext.data.JsonStore:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.data.JsonStore
......@@ -88,8 +88,8 @@
.. _Ext.panel.Panel:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.panel.Panel
.. _App.panel.WithUrlSelector:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/App.panel.WithUrlSelector
.. _Dbui.panel.WithUrlSelector:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.panel.WithUrlSelector
.. _Ext.data.Store:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.data.Store
......@@ -97,8 +97,8 @@
.. _Ext.tab.Panel:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.tab.Panel
.. _App.container.Viewport:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/App.container.Viewport
.. _Dbui.container.Viewport:
https://marprod.in2p3.fr/plugin_dbui_book/static/plugin_dbui/docs/jsduck/index.html#!/api/Dbui.container.Viewport
.. _Ext.Window:
http://docs-origin.sencha.com/extjs/4.2.1/#!/api/Ext.Window
......
......@@ -20,7 +20,7 @@ from datetime import datetime
def get_plugin_dbui_release():
JSBASE = '../../static/plugin_dbui/src/App.js'
JSBASE = '../../static/plugin_dbui/src/Dbui.js'
s = open(JSBASE, 'rb').read()
m = re.match("(.+ version: ')([\w._-]*)('.+)", s, re.DOTALL)
return m.group(2)
......
......@@ -34,11 +34,11 @@ following:
``double`` Ext.form.field.Number
``id`` Ext.form.field.Text
``integer`` Ext.form.field.Number
``json`` App.form.field.Dict
``list:string`` App.form.field.List
``json`` Dbui.form.field.Dict
``list:string`` Dbui.form.field.List
``list:integer`` Ext.form.field.TextArea
``password`` Ext.form.field.Text
``reference`` App.form.field.ComboBox
``reference`` Dbui.form.field.ComboBox
``string`` Ext.form.field.Text
``text`` Ext.form.field.TextArea
``time`` Ext.form.field.Time
......@@ -78,7 +78,7 @@ Fields can be hidden in form::
ComboBox
--------
The ComboBox is an instance of the ``App.form.field.ComboBox``
The ComboBox is an instance of the ``Dbui.form.field.ComboBox``
which derives from the base class ``Ext.form.field.ComboBox``.
The former embedded the logic to exchange data with the server.
......
......@@ -16,7 +16,7 @@ associated to each table, *e.g.* ``ui_people.py``.
Form configuration
-------------------
A form is an instance of the ``App.form.Panel`` class which derives from
A form is an instance of the ``Dbui.form.Panel`` class which derives from
the ``Ext.form.Panel``. The former mainly embedded the logic to exchange
date with the server. Its configuration parameters are those of the base
class.
......
......@@ -25,7 +25,7 @@ The recommend practice is to do it in the ``ui`` file associated to each table,
Grid configuration
------------------
The grid is an instance of the ``App.grid.Panel`` which derives from the
The grid is an instance of the ``Dbui.grid.Panel`` which derives from the
base class ``Ext.grid.Panel``. The former mainly embedded the logic to exchange
date with the server.
......
......@@ -56,7 +56,7 @@ version number.
The plugin_dbui and its friends can be obtained using the versioning tool git_::
git clone http://gitlab.in2p3.fr/legac/plugin_dbui_build.git
git clone https://gitlab.in2p3.fr/w2pext/plugins.git
* Install the ``plugin_dbui`` in your application using the web2py
administration interface.
......@@ -97,7 +97,7 @@ Source code
The source code of ``plugin_dbui`` can be obtained using the versioning tool
git_::
git clone http://gitlab.in2p3.fr/legac/plugin_dbui.git
git clone https://gitlab.in2p3.fr/w2pext/plugin_dbui.git
This is a complete web2py application which can be used as an example.
......
......@@ -84,7 +84,7 @@ The second part is more tricky and required a good knowledge of the
//
// instantiate the grid
//
grid = Ext.create('App.grid.Panel', {
grid = Ext.create('Dbui.grid.Panel', {
plugins: ['pGridExport'],
store: cfgStore,
columns: [
......
......@@ -28,7 +28,7 @@ The typical actions are:
Configure the viewport
----------------------
The viewport is an instance of the ``App.viewport.Viewport`` which derives from
The viewport is an instance of the ``Dbui.viewport.Viewport`` which derives from
the base class ``Ext.container.Viewport``. Its configuration parameters are
described in the `Ext JS API`_ documentation and can be customized in the python
model. The recommend practice is to do it in the file ``widgets_viewport.py``.
......@@ -184,7 +184,7 @@ the last step is create a leaf in the viewport to launch the action::
reportNode.add_child(T('lists'), listLeaf)
The python ``Selector`` and its associated ``App.panel.WithUrlSelector``
The python ``Selector`` and its associated ``Dbui.panel.WithUrlSelector``
widget are a very powerful tool which can be used to build reports or to perform
some actions on the database. It has several interesting keyword parameters
described in the plugin_dbui API.
......
......@@ -16,7 +16,7 @@ from gluon.tools import PluginManager
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/legac/%s.git" % request.application
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