Skip to content
Snippets Groups Projects
Commit a73d8ce5 authored by legac's avatar legac
Browse files

Improved code for the documentations and version view.

parent 2994af14
No related branches found
No related tags found
No related merge requests found
......@@ -46,4 +46,20 @@ def report_4():
"""Execute a javascript in the view using python information
"""
return dict(msg="Hello world")
\ No newline at end of file
import json
cfg = dict()
cfg['fields'] = [{'name': 'controller', 'type': 'string'},
{'name': 'host', 'type': 'string'},
{'name': 'collections', 'type': 'string'},
{'name': 'ratio', 'type': 'number'}]
cfg['data'] = []
for row in db().select(db.harvesters.ALL):
cfg['data'].append([row.controller,
row.host,
row.collections,
row.ratio])
return dict(msg="Hello world", cfg_store=json.dumps(cfg))
......@@ -7,6 +7,7 @@
'agency': 'agence',
'Authors': 'Auteurs',
'Authors Cppm': 'Auteurs Cppm',
'Binary files': 'Fichiers binaires',
'bla bla...': 'bla bla...',
'blab blab ....': 'blab blab ....',
'categories': 'catégories',
......@@ -26,6 +27,7 @@
'Dictionary': 'Dictionary',
'Documentation for developers': 'Documentation pour développeurs',
'documentations': 'documentations',
'Documentations': 'Documentations',
'Doi': 'Doi',
'domain': 'domaine',
'E Print': 'E Print',
......@@ -74,6 +76,7 @@
'My String': 'My String',
'My_Merge': 'My_Merge',
'new_fields': 'new_fields',
'Open source': 'Code open source',
'Pages': 'Pages',
'plugin not install': 'plugin not install',
'Project': 'Projet',
......
......@@ -4,26 +4,35 @@
# The python controller return cfg_doc, and cfg_src the configuration for
# the Ext.data.Array
#
# - build unique DIV identifier
#
#--------------------------------------------------------------------------
#
# Export python variables to the javascript
#
jsvars = ["cfgDoc = %s" % cfg_doc,
"cfgSrc = %s" % cfg_src]
jsvars = " var %s;" % ',\n'.join(jsvars)
response.write(SCRIPT(jsvars), escape=False)
#
# unique identifier for the DIV block associated to the grid
#
divdoc = id(cfg_doc)
divsrc = id(cfg_src)
}}
<h2 class="dbui-h2 dbui-small-cap">Documentations</h2>
<div id="grid-{{=divdoc}}"></div>
<h2 class="dbui-h2 dbui-small-cap">Code source</h2>
<div id="grid-{{=divsrc}}"></div>
#
# The DIV blocks
#
response.write(H2(T("Documentations"), _class="dbui-h2 dbui-small-cap"))
response.write(DIV(_id="grid-%s" % divdoc))
response.write(H2(T("Open source"), _class="dbui-h2 dbui-small-cap"))
response.write(DIV(_id="grid-%s" % divsrc))
<h2 class="dbui-h2 dbui-small-cap">Binnaires pour web2py</h2>
response.write(H2(T("Binary files"), _class="dbui-h2 dbui-small-cap"))
}}
<div style="width: 570px; padding: 0 20 0 20;">
<p class="dbui-p">
Les logiciels tierce
......@@ -41,27 +50,8 @@
</div>
<script>
/**
* Inline javascript to instantiate and render the Ext JS grids
*
*/
//
// bind the python and javascript variables
// use the internationalization of web2py to translate grid header
// MANDATORY: escape false to convert properly the quotes
//
{{
def write(value):
return response.write("\n%s" % value, escape=False)
write("var cfgDoc = %s," % cfg_doc)
write(" cfgSrc = %s;" % cfg_src)
}}
//
// instantiate the grids for the documentation
// instantiate the grid for the documentation
//
var grid = Ext.create('Ext.grid.Panel', {
store: Ext.create('Ext.data.ArrayStore', cfgDoc),
......@@ -79,7 +69,7 @@
});
//
// instantiate the grids for source code
// instantiate the grid for source code
//
var grid = Ext.create('Ext.grid.Panel', {
store: Ext.create('Ext.data.ArrayStore', cfgSrc),
......@@ -94,4 +84,4 @@
renderTo: 'grid-{{=divsrc}}'
});
</script>
</script>
\ No newline at end of file
......@@ -13,43 +13,27 @@
#
# unique identifier for the DIV block associated to the grid
#
divgrid = abs(hash(cfg_store))
divgrid = id(cfg_store)
#
# The title and the DIV block
#
style = ["font-size: 12px;",
"font-variant: small-caps;",
"margin-left: 20px;",
"margin-bottom: 1ex;",
"margin-top: 2ex;"]
response.write(P(T("Software versions"), _style="".join(style)))
response.write(H2(T("Software versions"), _class="dbui-h2 dbui-small-cap"))
response.write(DIV(_id="grid-%s" % divgrid))
#
# Export python variables to the javascript
#
jsvars = "var cfgStore = %s;" % cfg_store
response.write(SCRIPT(jsvars), escape=False)
}}
<script>
/**
* Inline javascript to instantiate and render the Ext JS grid
*
*/
//
// bind the python and javascript variables
// use the internationalization of web2py to translate grid header
// MANDATORY: escape false to convert properly the quotes
// instantiate the grid showing version numbers
//
{{
def write(value):
return response.write("\n%s" % value, escape=False)
write("var cfgStore = %s;" % cfg_store)
}}
//
// instantiate the grids
//
var grid = Ext.create('Ext.grid.Panel', {
store: Ext.create('Ext.data.ArrayStore', cfgStore),
columns: [
......
{{=msg}}
<script type="text/javascript">
var v1 = "{{=msg}}";
Ext.Msg.alert("Execute inline script", v1);
{{
#--------------------------------------------------------------------------
#
# The python controller return cfg_store, the configuration of
# the Ext.data.Array
#--------------------------------------------------------------------------
#
# unique identifier for the DIV block associated to the grid
#
divgrid = id(cfg_store)
#
# The DIV block
#
response.write(DIV(_id="grid-%s" % divgrid))
#
# Export python variables to the javascript
#
jsvars = "var cfgStore = %s;" % cfg_store
response.write(SCRIPT(jsvars), escape=False)
}}
<script>
/**
* Inline javascript to instantiate and render the Ext JS grid
*
*/
var grid = Ext.create('Ext.grid.Panel', {
store: Ext.create('Ext.data.ArrayStore', cfgStore),
columns: [
{text: "Controller", dataIndex: 'controller', flex: 0.8},
{text: "Host", dataIndex: 'host', flex: 1},
{text: "Collections", dataIndex: 'collections', flex: 1.2},
{text: "Ratio", dataIndex: 'ratio', flex: 0.5}
],
forceFit: true,
//hideHeaders: true,
padding: "10 40 20 60",
renderTo: 'grid-{{=divgrid}}'
});
</script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment