Remove the old scheduler
[cds-indico.git] / indico / web / assets / bundles.py
bloba5ab3fa0844795a1420bb5b47638a73a09c64103
1 # This file is part of Indico.
2 # Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN).
4 # Indico is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3 of the
7 # License, or (at your option) any later version.
9 # Indico is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with Indico; if not, see <http://www.gnu.org/licenses/>.
18 """
19 This file declares all core JS/CSS assets used by Indico
20 """
22 # stdlib imports
23 import os
24 from urlparse import urlparse
26 # 3rd party libs
27 from markupsafe import Markup
28 from webassets import Bundle, Environment
30 # legacy imports
31 from indico.core.config import Config
34 def configure_pyscss(environment):
35 config = Config.getInstance()
36 base_url_path = urlparse(config.getBaseURL()).path
37 environment.config['PYSCSS_DEBUG_INFO'] = environment.debug and config.getSCSSDebugInfo()
38 environment.config['PYSCSS_STATIC_URL'] = '{0}/static/'.format(base_url_path)
39 environment.config['PYSCSS_LOAD_PATHS'] = [
40 os.path.join(config.getHtdocsDir(), 'sass', 'lib', 'compass'),
41 os.path.join(config.getHtdocsDir(), 'sass')
45 class IndicoEnvironment(Environment):
46 def __init__(self):
47 config = Config.getInstance()
48 url_path = urlparse(config.getBaseURL()).path
49 output_dir = os.path.join(config.getHtdocsDir(), 'static', 'assets')
50 url = '{0}/static/assets/'.format(url_path)
52 super(IndicoEnvironment, self).__init__(output_dir, url)
53 self.debug = config.getDebug()
54 configure_pyscss(self)
56 self.append_path(config.getHtdocsDir(), '/')
57 self.append_path(os.path.join(config.getHtdocsDir(), 'css'), '{0}/css'.format(url_path))
58 self.append_path(os.path.join(config.getHtdocsDir(), 'js'), '{0}/js'.format(url_path))
61 def namespace(dir_ns, *list_files):
62 return [os.path.join(dir_ns, f) for f in list_files]
65 def include_js_assets(bundle_name):
66 """Jinja template function to generate HTML tags for a JS asset bundle."""
67 return Markup('\n'.join('<script src="{}"></script>'.format(url) for url in core_env[bundle_name].urls()))
70 def include_css_assets(bundle_name):
71 """Jinja template function to generate HTML tags for a CSS asset bundle."""
72 return Markup('\n'.join('<link rel="stylesheet" type="text/css" href="{}">'.format(url)
73 for url in core_env[bundle_name].urls()))
76 def rjs_bundle(name, *files):
77 return Bundle(*files, filters='rjsmin', output='js/{}_%(version)s.min.js'.format(name))
80 indico_core = rjs_bundle(
81 'indico_core',
82 *namespace('js/indico/Core',
84 'Presentation.js',
85 'Data.js',
86 'Components.js',
87 'Auxiliar.js',
88 'Buttons.js',
89 'Effects.js',
90 'Interaction/Base.js',
91 'Widgets/Base.js',
92 'Widgets/Inline.js',
93 'Widgets/DateTime.js',
94 'Widgets/Menu.js',
95 'Widgets/RichText.js',
96 'Widgets/Navigation.js',
97 'Widgets/UserList.js',
98 'Dialogs/Popup.js',
99 'Dialogs/PopupWidgets.js',
100 'Dialogs/Base.js',
101 'Dialogs/Util.js',
102 'Dialogs/Users.js',
103 'Dialogs/PopupWidgets.js',
104 'Browser.js',
105 'Services.js',
106 'Util.js',
107 'Login.js',
108 'Dragndrop.js',
109 'keymap.js'))
111 indico_management = rjs_bundle(
112 'indico_management',
113 *namespace('js/indico/Management',
115 'ConfModifDisplay.js',
116 'RoomBooking.js',
117 'eventCreation.js',
118 'Timetable.js',
119 'AbstractReviewing.js',
120 'NotificationTPL.js',
121 'Registration.js',
122 'Contributions.js',
123 'Sessions.js',
124 'CFA.js',
125 'RoomBookingMapOfRooms.js',
126 'EventUsers.js'))
128 indico_room_booking = rjs_bundle(
129 'indico_room_booking',
130 'js/lib/rrule.js',
131 *namespace('js/indico/RoomBooking',
133 'util.js',
134 'MapOfRooms.js',
135 'BookingForm.js',
136 'RoomBookingCalendar.js',
137 'roomselector.js',
138 'validation.js'))
140 indico_admin = rjs_bundle(
141 'indico_admin',
142 *namespace('js/indico/Admin',
144 'News.js',
145 'Upcoming.js'))
147 indico_timetable = rjs_bundle(
148 'indico_timetable',
149 *namespace('js/indico/Timetable',
151 'Filter.js',
152 'Layout.js',
153 'Undo.js',
154 'Base.js',
155 'DragAndDrop.js',
156 'Draw.js',
157 'Management.js'))
159 indico_legacy = rjs_bundle(
160 'indico_legacy',
161 *namespace('js/indico/Legacy',
163 'Widgets.js',
164 'Dialogs.js',
165 'Util.js'))
167 indico_common = rjs_bundle(
168 'indico_common',
169 *namespace('js/indico/Common',
170 'Export.js',
171 'TimezoneSelector.js',
172 'Social.js',
173 'htmlparser.js'))
175 indico_materialeditor = rjs_bundle('indico_materialeditor', 'js/indico/MaterialEditor/Editor.js')
177 indico_display = rjs_bundle('indico_display', 'js/indico/Display/Dialogs.js')
179 indico_jquery = rjs_bundle(
180 'indico_jquery',
181 *namespace('js/indico/jquery',
182 'defaults.js',
183 'global.js',
184 'errors.js',
185 'ajaxcheckbox.js',
186 'ajaxdialog.js',
187 'clearableinput.js',
188 'actioninput.js',
189 'fieldarea.js',
190 'multiselect.js',
191 'principalfield.js',
192 'realtimefilter.js',
193 'scrollblocker.js',
194 'timerange.js',
195 'tooltips.js'))
197 indico_jquery_authors = rjs_bundle('indico_jquery_authors', 'js/indico/jquery/authors.js')
199 indico_badges_js = rjs_bundle('indico_badges', 'js/indico/Management/ConfModifBadgePosterPrinting.js')
201 indico_badges_css = Bundle('css/badges.css',
202 filters='cssmin', output='css/indico_badges_%(version)s.min.css')
204 indico_regform = rjs_bundle(
205 'indico_regform',
206 *namespace('js/indico/RegistrationForm',
207 'registrationform.js',
208 'section.js',
209 'field.js',
210 'sectiontoolbar.js',
211 'table.js'))
213 angular = rjs_bundle(
214 'angular',
215 'js/lib/angular.js',
216 'js/lib/angular-resource.js',
217 'js/lib/angular-sanitize.js',
218 'js/lib/sortable.js',
219 'js/indico/angular/app.js',
220 'js/indico/angular/directives.js',
221 'js/indico/angular/filters.js',
222 'js/indico/angular/services.js')
224 zero_clipboard_js = rjs_bundle('zero_clipboard_js',
225 'js/lib/zeroclipboard/ZeroClipboard.js',
226 'js/custom/zeroclipboard.js')
228 selectize_js = rjs_bundle('selectize_js',
229 'js/lib/selectize.js/selectize.js')
231 selectize_css = Bundle('css/lib/selectize.js/selectize.css',
232 'css/lib/selectize.js/selectize.default.css',
233 filters='cssmin', output='css/selectize_css_%(version)s.min.css')
235 jquery = rjs_bundle('jquery', *filter(None, [
236 'js/lib/underscore.js',
237 'js/lib/jquery.js',
238 'js/lib/jquery.qtip.js',
239 'js/jquery/jquery-ui.js',
240 'js/lib/jquery.multiselect.js',
241 'js/lib/jquery.multiselect.filter.js',
242 'js/jquery/jquery-migrate-silencer.js' if not Config.getInstance().getDebug() else None] +
243 namespace('js/jquery',
245 'jquery-migrate.js',
246 'jquery.form.js',
247 'jquery.custom.js',
248 'jquery.daterange.js',
249 'jquery.dttbutton.js',
250 'jquery.colorbox.js',
251 'jquery.menu.js',
252 'date.js',
253 'jquery.colorpicker.js',
254 'jquery-extra-selectors.js',
255 'jquery.typewatch.js',
256 'jstorage.js',
257 'jquery.placeholder.js')))
259 utils = rjs_bundle('utils', *namespace('js/utils', 'routing.js', 'i18n.js', 'misc.js', 'forms.js'))
260 calendar = rjs_bundle('calendar', *namespace('js/calendar', 'calendar.js', 'calendar-setup.js'))
262 presentation = rjs_bundle(
263 'presentation',
264 *namespace('js/presentation',
266 'Core/Primitives.js',
267 'Core/Iterators.js',
268 'Core/Tools.js',
269 'Core/String.js',
270 'Core/Type.js',
271 'Core/Interfaces.js',
272 'Core/Commands.js',
273 'Core/MathEx.js',
274 'Data/Bag.js',
275 'Data/Watch.js',
276 'Data/WatchValue.js',
277 'Data/WatchList.js',
278 'Data/WatchObject.js',
279 'Data/Binding.js',
280 'Data/Logic.js',
281 'Data/Json.js',
282 'Data/Remote.js',
283 'Data/DateTime.js',
284 'Ui/MimeTypes.js',
285 'Ui/XElement.js',
286 'Ui/Html.js',
287 'Ui/Dom.js',
288 'Ui/Style.js',
289 'Ui/Extensions/Lookup.js',
290 'Ui/Extensions/Layout.js',
291 'Ui/Text.js',
292 'Ui/Styles/SimpleStyles.js',
293 'Ui/Widgets/WidgetBase.js',
294 'Ui/Widgets/WidgetPage.js',
295 'Ui/Widgets/WidgetComponents.js',
296 'Ui/Widgets/WidgetControl.js',
297 'Ui/Widgets/WidgetEditor.js',
298 'Ui/Widgets/WidgetTable.js',
299 'Ui/Widgets/WidgetField.js',
300 'Ui/Widgets/WidgetEditable.js',
301 'Ui/Widgets/WidgetMenu.js',
302 'Ui/Widgets/WidgetGrid.js'))
304 ie_compatibility = rjs_bundle('ie_compatibility', 'js/selectivizr.js')
306 jed = rjs_bundle('jed', 'js/lib/jed.js')
307 moment = rjs_bundle('moment', *namespace('js/moment', 'moment.js', 'locale/es.js', 'locale/fr.js'))
309 jqplot_js = rjs_bundle('jqplot',
310 *namespace('js/lib/jqplot',
311 'core/jqplot.core.js',
312 'core/jqplot.linearTickGenerator.js',
313 'core/jqplot.linearAxisRenderer.js',
314 'core/jqplot.axisTickRenderer.js',
315 'core/jqplot.axisLabelRenderer.js',
316 'core/jqplot.tableLegendRenderer.js',
317 'core/jqplot.lineRenderer.js',
318 'core/jqplot.markerRenderer.js',
319 'core/jqplot.divTitleRenderer.js',
320 'core/jqplot.canvasGridRenderer.js',
321 'core/jqplot.linePattern.js',
322 'core/jqplot.shadowRenderer.js',
323 'core/jqplot.shapeRenderer.js',
324 'core/jqplot.sprintf.js',
325 'core/jsdate.js',
326 'core/jqplot.themeEngine.js',
327 'core/jqplot.toImage.js',
328 'core/jqplot.effects.core.js',
329 'core/jqplot.effects.blind.js',
330 # hardcoded list since globbing doesn't have a fixed order across machines
331 'plugins/axis/jqplot.canvasAxisLabelRenderer.js',
332 'plugins/axis/jqplot.canvasAxisTickRenderer.js',
333 'plugins/axis/jqplot.categoryAxisRenderer.js',
334 'plugins/axis/jqplot.dateAxisRenderer.js',
335 'plugins/axis/jqplot.logAxisRenderer.js',
336 'plugins/bar/jqplot.barRenderer.js',
337 'plugins/cursor/jqplot.cursor.js',
338 'plugins/highlighter/jqplot.highlighter.js',
339 'plugins/points/jqplot.pointLabels.js',
340 'plugins/text/jqplot.canvasTextRenderer.js'))
342 jqplot_css = Bundle(
343 'css/lib/jquery.jqplot.css',
344 filters='cssmin', output='css/jqplot_%(version)s.min.css'
347 mathjax_js = rjs_bundle('mathjax', 'js/lib/mathjax/MathJax.js', 'js/custom/pagedown_mathjax.js')
348 contributions_js = rjs_bundle('contributions', 'js/indico/Display/contributions.js')
350 abstracts_js = rjs_bundle(
351 'abstracts',
352 contributions_js,
353 'js/indico/Management/abstracts.js',
354 *namespace('js/lib/pagedown',
355 'Markdown.Converter.js',
356 'Markdown.Editor.js',
357 'Markdown.Sanitizer.js'))
359 base_js = Bundle(jquery, angular, jed, utils, presentation, calendar, indico_jquery, moment,
360 indico_core, indico_legacy, indico_common)
362 module_js = {
363 'vc': rjs_bundle('modules_vc', 'js/indico/modules/vc.js'),
364 'event_display': rjs_bundle('modules_event_display', 'js/indico/modules/eventdisplay.js')
367 SASS_BASE_MODULES = ["sass/*.scss",
368 "sass/base/*.scss",
369 "sass/custom/*.scss",
370 "sass/partials/*.scss"]
373 def sass_module_bundle(module_name, depends=[]):
374 return Bundle('sass/modules/_{0}.scss'.format(module_name),
375 filters=("pyscss", "cssrewrite", "cssmin"),
376 output="sass/{0}_%(version)s.min.css".format(module_name),
377 depends = SASS_BASE_MODULES + ['sass/modules/{0}/*.scss'.format(module_name)] + depends)
379 agreements_sass = sass_module_bundle('agreements')
380 contributions_sass = sass_module_bundle('contributions')
381 registrationform_sass = sass_module_bundle('registrationform')
382 roombooking_sass = sass_module_bundle('roombooking')
383 dashboard_sass = sass_module_bundle('dashboard')
384 category_sass = sass_module_bundle('category')
385 admin_sass = sass_module_bundle('admin')
386 eventservices_sass = sass_module_bundle('eventservices')
387 event_display_sass = sass_module_bundle('event_display')
388 event_management_sass = sass_module_bundle('event_management')
389 overviews_sass = sass_module_bundle('overviews')
390 vc_sass = sass_module_bundle('vc')
391 news_sass = sass_module_bundle('news')
392 users_sass = sass_module_bundle('users')
393 auth_sass = sass_module_bundle('auth')
395 screen_sass = Bundle('sass/screen.scss',
396 filters=("pyscss", "cssrewrite", "cssmin"),
397 output="sass/screen_sass_%(version)s.css",
398 depends=SASS_BASE_MODULES)
401 def register_all_js(env):
402 env.register('jquery', jquery)
403 env.register('utils', utils)
404 env.register('presentation', presentation)
405 env.register('indico_core', indico_core)
406 env.register('indico_management', indico_management)
407 env.register('indico_roombooking', indico_room_booking)
408 env.register('indico_admin', indico_admin)
409 env.register('indico_timetable', indico_timetable)
410 env.register('indico_legacy', indico_legacy)
411 env.register('indico_common', indico_common)
412 env.register('indico_materialeditor', indico_materialeditor)
413 env.register('indico_display', indico_display)
414 env.register('indico_jquery', indico_jquery)
415 env.register('indico_authors', indico_jquery_authors)
416 env.register('indico_badges_js', indico_badges_js)
417 env.register('indico_regform', indico_regform)
418 env.register('base_js', base_js)
419 env.register('ie_compatibility', ie_compatibility)
420 env.register('abstracts_js', abstracts_js)
421 env.register('contributions_js', contributions_js)
422 env.register('mathjax_js', mathjax_js)
423 env.register('jqplot_js', jqplot_js)
424 env.register('zero_clipboard_js', zero_clipboard_js)
425 env.register('selectize_js', selectize_js)
427 for key, bundle in module_js.iteritems():
428 env.register('modules_{}_js'.format(key), bundle)
431 def register_all_css(env, main_css_file):
433 base_css = Bundle(
434 *namespace('css',
435 main_css_file,
436 'calendar-blue.css',
437 'jquery-ui.css',
438 'lib/angular.css',
439 'lib/jquery.qtip.css',
440 'lib/jquery.multiselect.css',
441 'lib/jquery.multiselect.filter.css',
442 'jquery.colorbox.css',
443 'jquery-ui-custom.css',
444 'jquery.qtip-custom.css',
445 'jquery.colorpicker.css'),
446 filters=("cssmin", "cssrewrite"),
447 output='css/base_%(version)s.min.css')
449 env.register('base_css', base_css)
450 env.register('indico_badges_css', indico_badges_css)
451 env.register('jqplot_css', jqplot_css)
452 env.register('selectize_css', selectize_css)
454 # SASS/SCSS
455 env.register('agreements_sass', agreements_sass)
456 env.register('registrationform_sass', registrationform_sass)
457 env.register('roombooking_sass', roombooking_sass)
458 env.register('contributions_sass', contributions_sass)
459 env.register('dashboard_sass', dashboard_sass)
460 env.register('category_sass', category_sass)
461 env.register('admin_sass', admin_sass)
462 env.register('screen_sass', screen_sass)
463 env.register('eventservices_sass', eventservices_sass)
464 env.register('event_display_sass', event_display_sass)
465 env.register('event_management_sass', event_management_sass)
466 env.register('overviews_sass', overviews_sass)
467 env.register('vc_sass', vc_sass)
468 env.register('news_sass', news_sass)
469 env.register('users_sass', users_sass)
470 env.register('auth_sass', auth_sass)
473 core_env = IndicoEnvironment()