Skip to content

Commit

Permalink
Merge pull request #301 from mkcor/config-reveal-resources
Browse files Browse the repository at this point in the history
Passing custom resources to voila configuration
  • Loading branch information
SylvainCorlay committed Jul 24, 2019
2 parents 3df5181 + 4b24a11 commit 3cce6bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion voila/configuration.py
Expand Up @@ -7,7 +7,7 @@
#############################################################################

import traitlets.config
from traitlets import Unicode, Bool
from traitlets import Unicode, Bool, Dict


class VoilaConfiguration(traitlets.config.Configurable):
Expand All @@ -20,6 +20,14 @@ class VoilaConfiguration(traitlets.config.Configurable):
'template name to be used by voila.'
)
)
resources = Dict(
allow_none=True,
help="""
extra resources used by templates;
example use with --template=reveal
--resources="{'reveal': {'transition': 'fade', 'scroll': True}}"
"""
).tag(config=True)
theme = Unicode('light').tag(config=True)
strip_sources = Bool(True, help='Strip sources from rendered html').tag(config=True)
enable_nbextensions = Bool(False, config=True, help=('Set to True for Voila to load notebook extensions'))
6 changes: 6 additions & 0 deletions voila/handler.py
Expand Up @@ -11,6 +11,7 @@
import tornado.web

from jupyter_server.base.handlers import JupyterHandler
from jupyter_server.config_manager import recursive_update

from .execute import executenb
from .exporter import VoilaExporter
Expand Down Expand Up @@ -67,6 +68,11 @@ def get(self, path=None):
'theme': self.voila_configuration.theme
}

# include potential extra resources
extra_resources = self.voila_configuration.resources
if extra_resources:
recursive_update(resources, extra_resources)

exporter = VoilaExporter(
template_path=self.nbconvert_template_paths,
config=self.exporter_config,
Expand Down

0 comments on commit 3cce6bf

Please sign in to comment.