1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-11-24 10:14:31 +01:00

implementing custom js

This commit is contained in:
kakwa 2015-08-09 10:35:28 +02:00
parent f61c7908cb
commit 61df2094c4
2 changed files with 28 additions and 3 deletions

View File

@ -244,6 +244,19 @@ class LdapCherry(object):
self._handle_exception(e)
raise BackendModuleInitFail(module)
def _init_custom_js(self, config):
self.custom_js = []
if '/custom' not in config:
return
directory = self._get_param(
'/custom',
'tools.staticdir.dir',
config,
)
for file in os.listdir(directory):
if file.endswith(".js"):
self.custom_js.append(file)
def _init_ppolicy(self, config):
module = self._get_param(
'ppolicy',
@ -515,6 +528,9 @@ class LdapCherry(object):
# loading the ppolicy
self._init_ppolicy(config)
# loading custom javascript
self._init_custom_js(config)
cherrypy.log.error(
msg="application started",
severity=logging.INFO
@ -970,7 +986,8 @@ class LdapCherry(object):
return self.temp_searchuser.render(
searchresult=res,
attrs_list=attrs_list,
is_admin=is_admin
is_admin=is_admin,
custom_js=self.custom_js,
)
@cherrypy.expose
@ -1005,7 +1022,8 @@ class LdapCherry(object):
return self.temp_searchadmin.render(
searchresult=res,
attrs_list=attrs_list,
is_admin=is_admin
is_admin=is_admin,
custom_js=self.custom_js,
)
@cherrypy.expose
@ -1051,7 +1069,8 @@ class LdapCherry(object):
form=form,
roles=roles,
is_admin=is_admin,
notification=notification
notification=notification,
custom_js=self.custom_js,
)
@cherrypy.expose
@ -1131,6 +1150,7 @@ class LdapCherry(object):
notification=notification,
standalone_groups=user_lonely_groups,
backends_display_names=self.backends_display_names,
custom_js=self.custom_js,
)
@cherrypy.expose

View File

@ -42,6 +42,11 @@
<script type="text/javascript" src="/static/js/removediacritic.js"></script>
<script type="text/javascript" src="/static/js/lc-filler.js"></script>
<script type="text/javascript" src="/static/js/sha1.js"></script>
% if custom_js:
% for js in custom_js:
<script type="text/javascript" src="/custom/${js}"></script>
% endfor
%endif
<script>
$(function(){