Skip to content
Snippets Groups Projects
Commit bf142a78 authored by Renaud Le Gac's avatar Renaud Le Gac
Browse files

add a new helper function get_js_files.

parent 65b410ba
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,8 @@ from directsvc import DBUI, DirectSvc
from fieldmodifier import FieldModifier
from formmodifier import configure_forms, FormModifier
from gridmodifier import configure_grids, GridModifier
from helper import (get_extjs_path,
from helper import (get_extjs_path,
get_js_files,
get_language,
get_reference_paths,
get_script_path)
......
......@@ -74,6 +74,41 @@ def get_extjs_path(environment):
return os.path.join(os.path.sep, application, 'static', 'plugin_extjs')
def get_js_files(server_path, client_path, directory):
"""Return a list of javascript files stored in the directory.
The alphabetic order is preserved.
"""
li = []
cltdir = os.path.join(client_path, directory)
svrdir = os.path.join(server_path, directory)
if os.path.exists(svrdir):
for file in os.listdir(svrdir):
if file.endswith(".js"):
li.append(os.path.join(cltdir, file))
li.sort()
return li
def get_language(environment):
"""Helper method returning the application language.
The result is compliant with the ExtJS file name.
The dictionary environment contains the keys request, response,
session, plugins, ....
"""
lg = environment['T'].accepted_language
if len(lg) == 5 and lg[0:2] == lg[3:5]:
lg = lg[0:2]
return lg
def get_reference_paths(environment):
"""Helper method returning a tuple with the server and the local paths.
......@@ -125,22 +160,6 @@ def get_script_path(environment):
return script
def get_language(environment):
"""Helper method returning the application language.
The result is compliant with the ExtJS file name.
The dictionary environment contains the keys request, response,
session, plugins, ....
"""
lg = environment['T'].accepted_language
if len(lg) == 5 and lg[0:2] == lg[3:5]:
lg = lg[0:2]
return lg
def rows_serializer(rows):
"""Helper function to serialize a gluon.dal.Rows.
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<!-- $Id: plugin_dbui.html 1129 2011-02-19 13:50:53Z legac $ -->
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="author" lang="en" content="{{=response.author}}" />
<meta name="keywords" content="{{=response.keywords}}" />
<meta name="description" content="{{=response.description}}" />
<title>{{=request.application}}</title>
<!-- extjs css -->
<link rel="stylesheet" type="text/css" href="{{=pextjs}}/resources/css/ext-all.css"/>
<link rel="stylesheet" type="text/css" href="{{=pextjs}}/examples/shared/icons/silk.css"/>
<!-- extjs javascript library -->
<script type="text/javascript" src="{{=pextjs}}/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="{{=pextjs}}/ext-all.js"></script>
<script type="text/javascript" src="{{=pextjs}}/src/locale/ext-lang-{{=lg}}.js"></script>
<!-- dbui javascript library -->
<script type="text/javascript" src="/{{=request.application}}/plugin_dbui/get_api"></script>
<script type="text/javascript" src="/{{=request.application}}/static/plugin_dbui/dbui.min.js"></script>
<!-- user javascript library and main script-->
{{for el in response.files:}}
<script type="text/javascript" src="{{=el}}"></script>
{{pass}}
</head>
<body>
<div id='appmain'></div>
</body>
</html>
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