mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-21 04:10:17 +08:00
DEV: Support for configurable list of extra jinja template directories.
This commit is contained in:
parent
e6939f9aa5
commit
cd1304961f
@ -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
|
||||
from .nbextensions import install_nbextension
|
||||
|
@ -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"""
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user