Show More
@@ -134,18 +134,18 b' class NotebookWebApplication(web.Application):' | |||
|
134 | 134 | |
|
135 | 135 | def __init__(self, ipython_app, kernel_manager, notebook_manager, |
|
136 | 136 | cluster_manager, session_manager, log, base_url, |
|
137 | settings_overrides): | |
|
137 | settings_overrides, jinja_env_options): | |
|
138 | 138 | |
|
139 | 139 | settings = self.init_settings( |
|
140 | 140 | ipython_app, kernel_manager, notebook_manager, cluster_manager, |
|
141 | session_manager, log, base_url, settings_overrides) | |
|
141 | session_manager, log, base_url, settings_overrides, jinja_env_options) | |
|
142 | 142 | handlers = self.init_handlers(settings) |
|
143 | 143 | |
|
144 | 144 | super(NotebookWebApplication, self).__init__(handlers, **settings) |
|
145 | 145 | |
|
146 | 146 | def init_settings(self, ipython_app, kernel_manager, notebook_manager, |
|
147 | 147 | cluster_manager, session_manager, log, base_url, |
|
148 | settings_overrides): | |
|
148 | settings_overrides, jinja_env_options=None): | |
|
149 | 149 | # Python < 2.6.5 doesn't accept unicode keys in f(**kwargs), and |
|
150 | 150 | # base_url will always be unicode, which will in turn |
|
151 | 151 | # make the patterns unicode, and ultimately result in unicode |
@@ -156,6 +156,8 b' class NotebookWebApplication(web.Application):' | |||
|
156 | 156 | # and thus guaranteed to be ASCII: 'héllo' is really 'h%C3%A9llo'. |
|
157 | 157 | base_url = py3compat.unicode_to_str(base_url, 'ascii') |
|
158 | 158 | template_path = settings_overrides.get("template_path", os.path.join(os.path.dirname(__file__), "templates")) |
|
159 | jenv_opt = jinja_env_options if jinja_env_options else {} | |
|
160 | env = Environment(loader=FileSystemLoader(template_path),**jenv_opt ) | |
|
159 | 161 | settings = dict( |
|
160 | 162 | # basics |
|
161 | 163 | log_function=log_request, |
@@ -180,7 +182,7 b' class NotebookWebApplication(web.Application):' | |||
|
180 | 182 | nbextensions_path = ipython_app.nbextensions_path, |
|
181 | 183 | mathjax_url=ipython_app.mathjax_url, |
|
182 | 184 | config=ipython_app.config, |
|
183 | jinja2_env=Environment(loader=FileSystemLoader(template_path)), | |
|
185 | jinja2_env=env, | |
|
184 | 186 | ) |
|
185 | 187 | |
|
186 | 188 | # allow custom overrides for the tornado web app. |
@@ -401,6 +403,10 b' class NotebookApp(BaseIPythonApplication):' | |||
|
401 | 403 | help="Supply overrides for the tornado.web.Application that the " |
|
402 | 404 | "IPython notebook uses.") |
|
403 | 405 | |
|
406 | jinja_environment_options = Dict(config=True, | |
|
407 | help="Supply extra arguments that will be passed to Jinja environment.") | |
|
408 | ||
|
409 | ||
|
404 | 410 | enable_mathjax = Bool(True, config=True, |
|
405 | 411 | help="""Whether to enable MathJax for typesetting math/TeX |
|
406 | 412 | |
@@ -591,7 +597,8 b' class NotebookApp(BaseIPythonApplication):' | |||
|
591 | 597 | self.web_app = NotebookWebApplication( |
|
592 | 598 | self, self.kernel_manager, self.notebook_manager, |
|
593 | 599 | self.cluster_manager, self.session_manager, |
|
594 | self.log, self.base_url, self.webapp_settings | |
|
600 | self.log, self.base_url, self.webapp_settings, | |
|
601 | self.jinja_environment_options | |
|
595 | 602 | ) |
|
596 | 603 | if self.certfile: |
|
597 | 604 | ssl_options = dict(certfile=self.certfile) |
General Comments 0
You need to be logged in to leave comments.
Login now