Skip to content

Commit 937a33a

Browse files
committed
serve custom.js from JUPYTER_CONFIG_DIR/custom
served at /custom/ instead of /static/custom keep serving ipython/profile/static/custom temporarily while we get the migration up
1 parent 09923ed commit 937a33a

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

jupyter_notebook/notebookapp.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ def init_settings(self, ipython_app, kernel_manager, contents_manager,
171171
default_url=default_url,
172172
template_path=template_path,
173173
static_path=ipython_app.static_file_path,
174+
static_custom_path=ipython_app.static_custom_path,
174175
static_handler_class = FileFindHandler,
175176
static_url_prefix = url_path_join(base_url,'/static/'),
176177
static_handler_args = {
@@ -235,6 +236,12 @@ def init_handlers(self, settings):
235236
'no_cache_paths': ['/'], # don't cache anything in nbextensions
236237
}),
237238
)
239+
handlers.append(
240+
(r"/custom/(.*)", FileFindHandler, {
241+
'path': settings['static_custom_path'],
242+
'no_cache_paths': ['/'], # don't cache anything in custom
243+
})
244+
)
238245
# register base handlers last
239246
handlers.extend(load_handlers('base.handlers'))
240247
# set the URL that will be redirected from `/`
@@ -563,25 +570,29 @@ def _base_project_url_changed(self, name, old, new):
563570
This allows adding javascript/css to be available from the notebook server machine,
564571
or overriding individual files in the IPython"""
565572
)
566-
def _extra_static_paths_default(self):
567-
return [
568-
# FIXME: remove IPython static path once migration is set up
569-
# and JUPYTER_CONFIG_DIR/custom is served at static/custom
570-
os.path.join(get_ipython_dir(), 'static'),
571-
]
572573

573574
@property
574575
def static_file_path(self):
575576
"""return extra paths + the default location"""
576577
return self.extra_static_paths + [DEFAULT_STATIC_FILES_PATH]
578+
579+
static_custom_path = List(Unicode,
580+
help="""Path to search for custom.js, css"""
581+
)
582+
def _static_custom_path_default(self):
583+
return [
584+
os.path.join(d, 'custom') for d in (
585+
self.config_dir,
586+
# FIXME: serve IPython profile while we don't have `jupyter migrate`
587+
os.path.join(get_ipython_dir(), 'profile_default', 'static'),
588+
DEFAULT_STATIC_FILES_PATH)
589+
]
577590

578591
extra_template_paths = List(Unicode, config=True,
579592
help="""Extra paths to search for serving jinja templates.
580593
581594
Can be used to override templates from jupyter_notebook.templates."""
582595
)
583-
def _extra_template_paths_default(self):
584-
return []
585596

586597
@property
587598
def template_file_path(self):

jupyter_notebook/templates/page.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
{% endif %}
2424
baseUrl: '{{static_url("", include_version=False)}}',
2525
paths: {
26+
custom : '{{ base_url }}custom',
2627
nbextensions : '{{ base_url }}nbextensions',
2728
kernelspecs : '{{ base_url }}kernelspecs',
2829
underscore : 'components/underscore/underscore-min',

0 commit comments

Comments
 (0)