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/>.
19 This file declares all core JS/CSS assets used by Indico
24 from urlparse
import urlparse
27 from markupsafe
import Markup
28 from webassets
import Bundle
, Environment
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
):
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(
82 *namespace('js/indico/Core',
90 'Interaction/Base.js',
93 'Widgets/DateTime.js',
95 'Widgets/RichText.js',
96 'Widgets/Navigation.js',
97 'Widgets/UserList.js',
99 'Dialogs/PopupWidgets.js',
103 'Dialogs/PopupWidgets.js',
111 indico_management
= rjs_bundle(
113 *namespace('js/indico/Management',
115 'ConfModifDisplay.js',
119 'AbstractReviewing.js',
120 'NotificationTPL.js',
125 'RoomBookingMapOfRooms.js',
128 indico_room_booking
= rjs_bundle(
129 'indico_room_booking',
131 *namespace('js/indico/RoomBooking',
136 'RoomBookingCalendar.js',
140 indico_admin
= rjs_bundle(
142 *namespace('js/indico/Admin',
147 indico_timetable
= rjs_bundle(
149 *namespace('js/indico/Timetable',
159 indico_legacy
= rjs_bundle(
161 *namespace('js/indico/Legacy',
167 indico_common
= rjs_bundle(
169 *namespace('js/indico/Common',
171 'TimezoneSelector.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(
181 *namespace('js/indico/jquery',
196 'nullableselector.js'))
198 indico_jquery_authors
= rjs_bundle('indico_jquery_authors', 'js/indico/jquery/authors.js')
200 indico_badges_js
= rjs_bundle('indico_badges', 'js/indico/Management/ConfModifBadgePosterPrinting.js')
202 indico_badges_css
= Bundle('css/badges.css',
203 filters
='cssmin', output
='css/indico_badges_%(version)s.min.css')
205 indico_regform
= rjs_bundle(
207 *namespace('js/indico/RegistrationForm',
208 'registrationform.js',
214 angular
= rjs_bundle(
217 'js/lib/angular-resource.js',
218 'js/lib/angular-sanitize.js',
219 'js/lib/sortable.js',
220 'js/indico/angular/app.js',
221 'js/indico/angular/directives.js',
222 'js/indico/angular/filters.js',
223 'js/indico/angular/services.js')
225 zero_clipboard_js
= rjs_bundle('zero_clipboard_js',
226 'js/lib/zeroclipboard/ZeroClipboard.js',
227 'js/custom/zeroclipboard.js')
229 dropzone_js
= rjs_bundle('dropzone_js',
230 'js/lib/dropzone.js/dropzone.js')
232 dropzone_css
= Bundle('css/lib/dropzone.js/dropzone.css',
233 'sass/custom/_dropzone.scss',
234 filters
=('pyscss', 'cssmin'), output
='css/dropzone_css_%(version)s.min.css')
236 jquery
= rjs_bundle('jquery', *filter(None, [
237 'js/lib/underscore.js',
239 'js/lib/jquery.qtip.js',
240 'js/jquery/jquery-ui.js',
241 'js/lib/jquery.multiselect.js',
242 'js/lib/jquery.multiselect.filter.js',
243 'js/lib/jquery.typeahead.js',
244 'js/jquery/jquery-migrate-silencer.js' if not Config
.getInstance().getDebug() else None] +
245 namespace('js/jquery',
250 'jquery.daterange.js',
251 'jquery.dttbutton.js',
252 'jquery.colorbox.js',
255 'jquery.colorpicker.js',
256 'jquery-extra-selectors.js',
257 'jquery.typewatch.js',
259 'jquery.placeholder.js')))
261 utils
= rjs_bundle('utils', *namespace('js/utils', 'routing.js', 'i18n.js', 'misc.js', 'forms.js'))
262 calendar
= rjs_bundle('calendar', *namespace('js/calendar', 'calendar.js', 'calendar-setup.js'))
264 presentation
= rjs_bundle(
266 *namespace('js/presentation',
268 'Core/Primitives.js',
273 'Core/Interfaces.js',
278 'Data/WatchValue.js',
280 'Data/WatchObject.js',
291 'Ui/Extensions/Lookup.js',
292 'Ui/Extensions/Layout.js',
294 'Ui/Styles/SimpleStyles.js',
295 'Ui/Widgets/WidgetBase.js',
296 'Ui/Widgets/WidgetPage.js',
297 'Ui/Widgets/WidgetComponents.js',
298 'Ui/Widgets/WidgetControl.js',
299 'Ui/Widgets/WidgetEditor.js',
300 'Ui/Widgets/WidgetTable.js',
301 'Ui/Widgets/WidgetField.js',
302 'Ui/Widgets/WidgetEditable.js',
303 'Ui/Widgets/WidgetMenu.js',
304 'Ui/Widgets/WidgetGrid.js'))
306 ie_compatibility
= rjs_bundle('ie_compatibility', 'js/selectivizr.js')
308 jed
= rjs_bundle('jed', 'js/lib/jed.js')
309 moment
= rjs_bundle('moment', *namespace('js/moment', 'moment.js', 'locale/es.js', 'locale/fr.js'))
311 jqplot_js
= rjs_bundle('jqplot',
312 *namespace('js/lib/jqplot',
313 'core/jqplot.core.js',
314 'core/jqplot.linearTickGenerator.js',
315 'core/jqplot.linearAxisRenderer.js',
316 'core/jqplot.axisTickRenderer.js',
317 'core/jqplot.axisLabelRenderer.js',
318 'core/jqplot.tableLegendRenderer.js',
319 'core/jqplot.lineRenderer.js',
320 'core/jqplot.markerRenderer.js',
321 'core/jqplot.divTitleRenderer.js',
322 'core/jqplot.canvasGridRenderer.js',
323 'core/jqplot.linePattern.js',
324 'core/jqplot.shadowRenderer.js',
325 'core/jqplot.shapeRenderer.js',
326 'core/jqplot.sprintf.js',
328 'core/jqplot.themeEngine.js',
329 'core/jqplot.toImage.js',
330 'core/jqplot.effects.core.js',
331 'core/jqplot.effects.blind.js',
332 # hardcoded list since globbing doesn't have a fixed order across machines
333 'plugins/axis/jqplot.canvasAxisLabelRenderer.js',
334 'plugins/axis/jqplot.canvasAxisTickRenderer.js',
335 'plugins/axis/jqplot.categoryAxisRenderer.js',
336 'plugins/axis/jqplot.dateAxisRenderer.js',
337 'plugins/axis/jqplot.logAxisRenderer.js',
338 'plugins/bar/jqplot.barRenderer.js',
339 'plugins/cursor/jqplot.cursor.js',
340 'plugins/highlighter/jqplot.highlighter.js',
341 'plugins/points/jqplot.pointLabels.js',
342 'plugins/text/jqplot.canvasTextRenderer.js'))
345 'css/lib/jquery.jqplot.css',
346 filters
='cssmin', output
='css/jqplot_%(version)s.min.css'
349 mathjax_js
= rjs_bundle('mathjax', 'js/lib/mathjax/MathJax.js', 'js/custom/pagedown_mathjax.js')
350 contributions_js
= rjs_bundle('contributions', 'js/indico/Display/contributions.js')
352 abstracts_js
= rjs_bundle(
355 'js/indico/Management/abstracts.js',
356 *namespace('js/lib/pagedown',
357 'Markdown.Converter.js',
358 'Markdown.Editor.js',
359 'Markdown.Sanitizer.js'))
361 base_js
= Bundle(jquery
, angular
, jed
, utils
, presentation
, calendar
, indico_jquery
, moment
,
362 indico_core
, indico_legacy
, indico_common
)
365 'vc': rjs_bundle('modules_vc', 'js/indico/modules/vc.js'),
366 'event_display': rjs_bundle('modules_event_display', 'js/indico/modules/eventdisplay.js'),
367 'attachments': rjs_bundle('modules_attachments', 'js/indico/modules/attachments.js')
370 SASS_BASE_MODULES
= ["sass/*.scss",
372 "sass/custom/*.scss",
373 "sass/partials/*.scss"]
376 def sass_module_bundle(module_name
, depends
=[]):
377 return Bundle('sass/modules/_{0}.scss'.format(module_name
),
378 filters
=("pyscss", "cssrewrite", "cssmin"),
379 output
="sass/{0}_%(version)s.min.css".format(module_name
),
380 depends
= SASS_BASE_MODULES
+ ['sass/modules/{0}/*.scss'.format(module_name
)] + depends
)
382 agreements_sass
= sass_module_bundle('agreements')
383 attachments_sass
= sass_module_bundle('attachments')
384 contributions_sass
= sass_module_bundle('contributions')
385 registrationform_sass
= sass_module_bundle('registrationform')
386 roombooking_sass
= sass_module_bundle('roombooking')
387 dashboard_sass
= sass_module_bundle('dashboard')
388 category_sass
= sass_module_bundle('category')
389 admin_sass
= sass_module_bundle('admin')
390 eventservices_sass
= sass_module_bundle('eventservices')
391 event_display_sass
= sass_module_bundle('event_display')
392 event_management_sass
= sass_module_bundle('event_management')
393 overviews_sass
= sass_module_bundle('overviews')
394 vc_sass
= sass_module_bundle('vc')
395 news_sass
= sass_module_bundle('news')
396 users_sass
= sass_module_bundle('users')
397 auth_sass
= sass_module_bundle('auth')
399 screen_sass
= Bundle('sass/screen.scss',
400 filters
=("pyscss", "cssrewrite", "cssmin"),
401 output
="sass/screen_sass_%(version)s.css",
402 depends
=SASS_BASE_MODULES
)
405 def register_all_js(env
):
406 env
.register('jquery', jquery
)
407 env
.register('utils', utils
)
408 env
.register('presentation', presentation
)
409 env
.register('indico_core', indico_core
)
410 env
.register('indico_management', indico_management
)
411 env
.register('indico_roombooking', indico_room_booking
)
412 env
.register('indico_admin', indico_admin
)
413 env
.register('indico_timetable', indico_timetable
)
414 env
.register('indico_legacy', indico_legacy
)
415 env
.register('indico_common', indico_common
)
416 env
.register('indico_materialeditor', indico_materialeditor
)
417 env
.register('indico_display', indico_display
)
418 env
.register('indico_jquery', indico_jquery
)
419 env
.register('indico_authors', indico_jquery_authors
)
420 env
.register('indico_badges_js', indico_badges_js
)
421 env
.register('indico_regform', indico_regform
)
422 env
.register('base_js', base_js
)
423 env
.register('ie_compatibility', ie_compatibility
)
424 env
.register('abstracts_js', abstracts_js
)
425 env
.register('contributions_js', contributions_js
)
426 env
.register('mathjax_js', mathjax_js
)
427 env
.register('jqplot_js', jqplot_js
)
428 env
.register('zero_clipboard_js', zero_clipboard_js
)
429 env
.register('dropzone_js', dropzone_js
)
431 for key
, bundle
in module_js
.iteritems():
432 env
.register('modules_{}_js'.format(key
), bundle
)
435 def register_all_css(env
, main_css_file
):
443 'lib/jquery.qtip.css',
444 'lib/jquery.multiselect.css',
445 'lib/jquery.multiselect.filter.css',
446 'lib/jquery.typeahead.css',
447 'jquery.colorbox.css',
448 'jquery-ui-custom.css',
449 'jquery.qtip-custom.css',
450 'jquery.colorpicker.css'),
451 filters
=("cssmin", "cssrewrite"),
452 output
='css/base_%(version)s.min.css')
454 env
.register('base_css', base_css
)
455 env
.register('indico_badges_css', indico_badges_css
)
456 env
.register('jqplot_css', jqplot_css
)
457 env
.register('dropzone_css', dropzone_css
)
460 env
.register('agreements_sass', agreements_sass
)
461 env
.register('attachments_sass', attachments_sass
)
462 env
.register('registrationform_sass', registrationform_sass
)
463 env
.register('roombooking_sass', roombooking_sass
)
464 env
.register('contributions_sass', contributions_sass
)
465 env
.register('dashboard_sass', dashboard_sass
)
466 env
.register('category_sass', category_sass
)
467 env
.register('admin_sass', admin_sass
)
468 env
.register('screen_sass', screen_sass
)
469 env
.register('eventservices_sass', eventservices_sass
)
470 env
.register('event_display_sass', event_display_sass
)
471 env
.register('event_management_sass', event_management_sass
)
472 env
.register('overviews_sass', overviews_sass
)
473 env
.register('vc_sass', vc_sass
)
474 env
.register('news_sass', news_sass
)
475 env
.register('users_sass', users_sass
)
476 env
.register('auth_sass', auth_sass
)
479 core_env
= IndicoEnvironment()