##// END OF EJS Templates
plugins: allow more custom keys into js configs
ergo -
Show More
@@ -76,6 +76,7 b' def register_appenlight_plugin(config, plugin_name, plugin_config):'
76 'fulltext_indexer': None,
76 'fulltext_indexer': None,
77 'sqlalchemy_migrations': None,
77 'sqlalchemy_migrations': None,
78 'default_values_setter': None,
78 'default_values_setter': None,
79 'header_html': None,
79 'resource_types': [],
80 'resource_types': [],
80 'url_gen': None
81 'url_gen': None
81 }
82 }
@@ -2742,7 +2742,7 b" angular.module('appenlight.services', ["
2742
2742
2743 var pluginsToLoad = _.map(decodeEncodedJSON(window.AE.plugins),
2743 var pluginsToLoad = _.map(decodeEncodedJSON(window.AE.plugins),
2744 function(item){
2744 function(item){
2745 return item.config.angular_module
2745 return item.config.javascript.angular_module
2746 });
2746 });
2747 console.info(pluginsToLoad);
2747 console.info(pluginsToLoad);
2748
2748
@@ -110,7 +110,7 b' def add_renderer_globals(event):'
110 renderer_globals['_'] = _
110 renderer_globals['_'] = _
111 renderer_globals['security'] = security
111 renderer_globals['security'] = security
112 renderer_globals['flash_msgs'] = []
112 renderer_globals['flash_msgs'] = []
113 renderer_globals['js_plugins'] = []
113 renderer_globals['appenlight_plugins'] = []
114
114
115 if 'jinja' in event['renderer_info'].type:
115 if 'jinja' in event['renderer_info'].type:
116 renderer_globals['url_list'] = gen_urls(request)
116 renderer_globals['url_list'] = gen_urls(request)
@@ -120,9 +120,12 b' def add_renderer_globals(event):'
120 urls = config['url_gen'](request)
120 urls = config['url_gen'](request)
121 renderer_globals['url_list']['plugins'][module] = urls
121 renderer_globals['url_list']['plugins'][module] = urls
122
122
123 if config['javascript']:
123 renderer_globals['appenlight_plugins'].append(
124 renderer_globals['js_plugins'].append(
124 {'name': module,
125 ({'name': module, 'config': config['javascript']}))
125 'config': {
126 'javascript':config['javascript'],
127 'header_html':config['header_html']
128 }})
126
129
127 footer_config = ConfigService.by_key_and_section(
130 footer_config = ConfigService.by_key_and_section(
128 'template_footer_html', 'global', default_value='')
131 'template_footer_html', 'global', default_value='')
@@ -26,7 +26,7 b''
26 AE.ws_url = '{{ request.registry.settings['cometd.ws_url'] }}';
26 AE.ws_url = '{{ request.registry.settings['cometd.ws_url'] }}';
27 AE.flash_messages = {{ flash_msgs|toJSONUnsafe }};
27 AE.flash_messages = {{ flash_msgs|toJSONUnsafe }};
28 AE.timeOptions = {{ h.time_options|toJSONUnsafe }};
28 AE.timeOptions = {{ h.time_options|toJSONUnsafe }};
29 AE.plugins = {{ js_plugins|toJSONUnsafe }};
29 AE.plugins = {{ appenlight_plugins|toJSONUnsafe }};
30 </script>
30 </script>
31 {% if request.registry.settings.get('appenlight.public_api_key') %}
31 {% if request.registry.settings.get('appenlight.public_api_key') %}
32 <script type="application/javascript">
32 <script type="application/javascript">
@@ -62,8 +62,11 b''
62 </script>
62 </script>
63 {% endif %}
63 {% endif %}
64 <script src="{{ request.static_url('appenlight:webassets/appenlight/js/appenlight.js', _query={'rev':js_hash}) }}"></script>
64 <script src="{{ request.static_url('appenlight:webassets/appenlight/js/appenlight.js', _query={'rev':js_hash}) }}"></script>
65 {% for plugin in js_plugins %}
65 {% for plugin in appenlight_plugins %}
66 <script src="{{ request.static_url('appenlight:webassets/{}/js/{}'.format(plugin['name'], plugin['config']['src']), _query={'rev':js_hash}) }}"></script>
66 <script src="{{ request.static_url('appenlight:webassets/{}/js/{}'.format(plugin['name'], plugin['config']['javascript']['src']), _query={'rev':js_hash}) }}"></script>
67 {% if plugin['config']['header_html'] %}
68 {{ plugin['config']['header_html']|safe }}
69 {% endif %}
67 {% endfor %}
70 {% endfor %}
68 <script>
71 <script>
69 var xhr = new XMLHttpRequest();
72 var xhr = new XMLHttpRequest();
@@ -106,7 +106,7 b" angular.module('appenlight.services', ["
106
106
107 var pluginsToLoad = _.map(decodeEncodedJSON(window.AE.plugins),
107 var pluginsToLoad = _.map(decodeEncodedJSON(window.AE.plugins),
108 function(item){
108 function(item){
109 return item.config.angular_module
109 return item.config.javascript.angular_module
110 });
110 });
111 console.info(pluginsToLoad);
111 console.info(pluginsToLoad);
112
112
General Comments 0
You need to be logged in to leave comments. Login now