Added __init__.py and fixes in load_js

This commit is contained in:
Antonio de la Rosa 2017-05-19 14:45:26 +02:00
parent c97a49b5a7
commit ad4326048a
3 changed files with 19 additions and 6 deletions

View file

@ -8,6 +8,7 @@ from paramecio.citoplasma.i18n import I18n
from paramecio.citoplasma.sessions import get_session from paramecio.citoplasma.sessions import get_session
from paramecio.citoplasma.adminutils import make_admin_url from paramecio.citoplasma.adminutils import make_admin_url
from paramecio.cromosoma.formsutils import csrf_token from paramecio.cromosoma.formsutils import csrf_token
from paramecio.citoplasma.js import make_js_url
from settings import config from settings import config
from os import path from os import path
from collections import OrderedDict from collections import OrderedDict
@ -90,7 +91,7 @@ class PTemplate:
module=path.dirname(module) 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 self.cache_enabled=cache_enabled
@ -122,7 +123,9 @@ class PTemplate:
self.add_filter(csrf_token) self.add_filter(csrf_token)
self.add_filter(make_admin_url) self.add_filter(make_admin_url)
self.add_filter(make_js_url)
I18n_lang=I18n.lang I18n_lang=I18n.lang
self.add_filter(I18n.lang) self.add_filter(I18n.lang)

View file

View file

@ -3,6 +3,9 @@
from paramecio.wsgiapp import app from paramecio.wsgiapp import app
from paramecio.citoplasma.mtemplates import env_theme, PTemplate from paramecio.citoplasma.mtemplates import env_theme, PTemplate
from settings import config from settings import config
from paramecio.citoplasma.sessions import get_session
from paramecio.citoplasma.i18n import I18n
from bottle import response
import os import os
#t=PTemplate(env) #t=PTemplate(env)
@ -16,9 +19,14 @@ arr_t={}
@app.route('/mediajs/<module>/<lang>/<filename:path>') @app.route('/mediajs/<module>/<lang>/<filename:path>')
def send_javascript(module, lang, filename): 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_module=path_module+'/'+filename
file_path_theme=path+'/'+filename file_path_theme=path+'/'+filename
@ -34,5 +42,7 @@ def send_javascript(module, lang, filename):
if not load_path in arr_t: if not load_path in arr_t:
env=env_theme(load_path) env=env_theme(load_path)
arr_t[load_path]=PTemplate(env) 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)