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