diff --git a/paramecio/citoplasma/mtemplates.py b/paramecio/citoplasma/mtemplates.py index 4d30b0a..9c7c2eb 100644 --- a/paramecio/citoplasma/mtemplates.py +++ b/paramecio/citoplasma/mtemplates.py @@ -8,6 +8,7 @@ from paramecio.citoplasma.i18n import I18n from paramecio.citoplasma.sessions import get_session from paramecio.citoplasma.adminutils import make_admin_url from paramecio.cromosoma.formsutils import csrf_token +from paramecio.citoplasma.js import make_js_url from settings import config from os import path from collections import OrderedDict @@ -90,7 +91,7 @@ class PTemplate: module=path.dirname(module) """ - self.autoescape_ext=('html', 'htm', 'xml', 'phtml', 'pjs') + self.autoescape_ext=('html', 'htm', 'xml', 'phtml', 'js') """ self.cache_enabled=cache_enabled @@ -122,7 +123,9 @@ class PTemplate: self.add_filter(csrf_token) self.add_filter(make_admin_url) - + + self.add_filter(make_js_url) + I18n_lang=I18n.lang self.add_filter(I18n.lang) diff --git a/paramecio/i18n/__init__py b/paramecio/i18n/__init__py new file mode 100644 index 0000000..e69de29 diff --git a/paramecio/modules/javascript/load_js.py b/paramecio/modules/javascript/load_js.py index 13dbce4..1d85909 100644 --- a/paramecio/modules/javascript/load_js.py +++ b/paramecio/modules/javascript/load_js.py @@ -3,6 +3,9 @@ from paramecio.wsgiapp import app from paramecio.citoplasma.mtemplates import env_theme, PTemplate from settings import config +from paramecio.citoplasma.sessions import get_session +from paramecio.citoplasma.i18n import I18n +from bottle import response import os #t=PTemplate(env) @@ -16,9 +19,14 @@ arr_t={} @app.route('/mediajs///') def send_javascript(module, lang, filename): - path_module=workdir+'/modules/'+module+'/js/' + s=get_session() - path=workdir+'/themes/'+config.theme+'/js/'+module + if lang in I18n.dict_i18n: + s['lang']=lang + + path_module='modules/'+module+'/js' + + path='themes/'+config.theme+'/js/'+module file_path_module=path_module+'/'+filename file_path_theme=path+'/'+filename @@ -34,5 +42,7 @@ def send_javascript(module, lang, filename): if not load_path in arr_t: env=env_theme(load_path) arr_t[load_path]=PTemplate(env) - - return arr_t[module].load_template(file_path) + + response.set_header('Content-type', 'application/javascript') + + return arr_t[load_path].load_template(filename)