diff --git a/voila/configuration.py b/voila/configuration.py index 33ff57150..0de8891f6 100644 --- a/voila/configuration.py +++ b/voila/configuration.py @@ -7,7 +7,7 @@ ############################################################################# import traitlets.config -from traitlets import Unicode, Bool +from traitlets import Unicode, Bool, Dict class VoilaConfiguration(traitlets.config.Configurable): @@ -20,34 +20,13 @@ class VoilaConfiguration(traitlets.config.Configurable): 'template name to be used by voila.' ) ) - reveal_theme = Unicode( - 'simple', + extra_resources = Dict( + {}, allow_none=True, help=""" - Used only with template reveal, ignored otherwise. - Name of the reveal.js theme to use. - We look for a file with this name under - ``reveal_url_prefix``/css/theme/``reveal_theme``.css. - https://github.com/hakimel/reveal.js/tree/master/css/theme has - list of themes that ship by default with reveal.js. - """ - ).tag(config=True) - reveal_transition = Unicode( - 'slide', - allow_none=True, - help=""" - Used only with template reveal, ignored otherwise. - Name of the reveal.js transition to use. - The list of transitions that ships by default with reveal.js are: - none, fade, slide, convex, concave and zoom. - """ - ).tag(config=True) - reveal_scroll = Bool( - False, - allow_none=True, - help=""" - Used only with template reveal, ignored otherwise. - If True, enable scrolling within each slide + extra resources used by templates; + example use with --template=reveal + --extra_resources="{'reveal': {'transition': 'fade', 'scroll': True}}" """ ).tag(config=True) theme = Unicode('light').tag(config=True) diff --git a/voila/handler.py b/voila/handler.py index a347fd986..031832dca 100644 --- a/voila/handler.py +++ b/voila/handler.py @@ -72,13 +72,29 @@ def get(self, path=None): # add extra resources (necessary for reveal template) resources_reveal = { 'reveal': { - 'theme': self.voila_configuration.reveal_theme, - 'transition': self.voila_configuration.reveal_transition, - 'scroll': self.voila_configuration.reveal_scroll, + 'theme': 'simple', + 'transition': 'slide', + 'scroll': False, } } resources.update(resources_reveal) + # include potential extra resources + extra_resources = self.voila_configuration.extra_resources + if extra_resources: + for k in extra_resources.keys(): + if k in resources.keys(): + if isinstance(extra_resources[k], dict): + for kk in extra_resources[k].keys(): + # update or add depth-2 resources + resources[k][kk] = extra_resources[k][kk] + else: + # update depth-1 (top-level) resources + resources[k] = extra_resources[k] + else: + # add depth-1 (top-level) resources + resources[k] = extra_resources[k] + exporter = VoilaExporter( template_path=self.nbconvert_template_paths, config=self.exporter_config,