diff --git a/IPython/html/__init__.py b/IPython/html/__init__.py index 97e2c984b..b250a9620 100644 --- a/IPython/html/__init__.py +++ b/IPython/html/__init__.py @@ -3,7 +3,9 @@ import os # Packagers: modify this line if you store the notebook static files elsewhere DEFAULT_STATIC_FILES_PATH = os.path.join(os.path.dirname(__file__), "static") +# Packagers: modify this line if you store the notebook template files elsewhere +DEFAULT_TEMPLATE_FILES_PATH = os.path.join(os.path.dirname(__file__), "templates") del os -from .nbextensions import install_nbextension \ No newline at end of file +from .nbextensions import install_nbextension diff --git a/IPython/html/notebookapp.py b/IPython/html/notebookapp.py index bf7f4f8d5..0f73ca895 100644 --- a/IPython/html/notebookapp.py +++ b/IPython/html/notebookapp.py @@ -51,7 +51,10 @@ from tornado import httpserver from tornado import web from tornado.log import LogFormatter, app_log, access_log, gen_log -from IPython.html import DEFAULT_STATIC_FILES_PATH +from IPython.html import ( + DEFAULT_STATIC_FILES_PATH, + DEFAULT_TEMPLATE_FILES_PATH, +) from .base.handlers import Template404 from .log import log_request from .services.kernels.kernelmanager import MappingKernelManager @@ -138,7 +141,10 @@ class NotebookWebApplication(web.Application): log, base_url, default_url, settings_overrides, jinja_env_options=None): - _template_path = settings_overrides.get("template_path", os.path.join(os.path.dirname(__file__), "templates")) + _template_path = settings_overrides.get( + "template_path", + ipython_app.template_file_path, + ) if isinstance(_template_path, str): _template_path = (_template_path,) template_path = [os.path.expanduser(path) for path in _template_path] @@ -519,7 +525,20 @@ class NotebookApp(BaseIPythonApplication): def static_file_path(self): """return extra paths + the default location""" return self.extra_static_paths + [DEFAULT_STATIC_FILES_PATH] - + + extra_template_paths = List(Unicode, config=True, + help="""Extra paths to search for serving jinja templates. + + Can be used to override templates from IPython.html.templates.""" + ) + def _extra_template_paths_default(self): + return [] + + @property + def template_file_path(self): + """return extra paths + the default location""" + return self.extra_template_paths + [DEFAULT_TEMPLATE_FILES_PATH] + nbextensions_path = List(Unicode, config=True, help="""paths for Javascript extensions. By default, this is just IPYTHONDIR/nbextensions""" )