Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding nbextension path to voila config object #1167

Merged
merged 1 commit into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions voila/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class Voila(Application):
'base_url': 'Voila.base_url',
'server_url': 'Voila.server_url',
'enable_nbextensions': 'VoilaConfiguration.enable_nbextensions',
'nbextensions_path': 'VoilaConfiguration.nbextensions_path',
'show_tracebacks': 'VoilaConfiguration.show_tracebacks',
'preheat_kernel': 'VoilaConfiguration.preheat_kernel',
'pool_size': 'VoilaConfiguration.default_pool_size'
Expand Down Expand Up @@ -305,6 +306,8 @@ def _default_log_level(self):
@property
def nbextensions_path(self):
"""The path to look for Javascript notebook extensions"""
if self.voila_configuration.nbextensions_path:
return self.voila_configuration.nbextensions_path
path = jupyter_path('nbextensions')
# FIXME: remove IPython nbextensions path after a migration period
try:
Expand Down
1 change: 1 addition & 0 deletions voila/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class VoilaConfiguration(traitlets.config.Configurable):
theme = Unicode('light', config=True)
strip_sources = Bool(True, config=True, help='Strip sources from rendered html')
enable_nbextensions = Bool(False, config=True, help=('Set to True for Voilà to load notebook extensions'))
nbextensions_path = Unicode('', config=True, help='Set to override default path provided by Jupyter Server')

file_whitelist = List(
Unicode(),
Expand Down
10 changes: 7 additions & 3 deletions voila/server_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,13 @@ def _load_jupyter_server_extension(server_app):

# Serving notebook extensions
if voila_configuration.enable_nbextensions:
# First look into 'nbextensions_path' configuration key (classic notebook)
# and fall back to default path for nbextensions (jupyter server).
if 'nbextensions_path' in web_app.settings:
# First check whether a custom nbextensions_path has been set in
# the VoilaConfiguration object, if not, then fall back to
# looking into 'nbextensions_path' configuration key (classic notebook)
# otherwise fall back to default path for nbextensions (jupyter server).
if voila_configuration.nbextensions_path:
nbextensions_path = voila_configuration.nbextensions_path
elif 'nbextensions_path' in web_app.settings:
nbextensions_path = web_app.settings['nbextensions_path']
else:
nbextensions_path = jupyter_path('nbextensions')
Expand Down