From 56b33145e7e4e4f509eb0f9a09f5eccf3ece0419 Mon Sep 17 00:00:00 2001 From: Matt Henderson Date: Wed, 14 Aug 2013 17:40:48 -0700 Subject: [PATCH 1/4] Fixed custom jinja2 templates being ignored when setting template_path --- IPython/html/notebookapp.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/IPython/html/notebookapp.py b/IPython/html/notebookapp.py index 9e261117b..41669b21f 100644 --- a/IPython/html/notebookapp.py +++ b/IPython/html/notebookapp.py @@ -172,12 +172,15 @@ class NotebookWebApplication(web.Application): # IPython stuff mathjax_url=ipython_app.mathjax_url, config=ipython_app.config, - use_less=ipython_app.use_less, - jinja2_env=Environment(loader=FileSystemLoader(template_path)), + use_less=ipython_app.use_less ) # allow custom overrides for the tornado web app. settings.update(settings_overrides) + + # create a jinja2 environment using the template path and store it in settings + settings.jinja2_env=Environment(loader=FileSystemLoader(settings.template_path)) + return settings def init_handlers(self, settings): From 918d872f2cb620915d2d51d2bc6e474cd2f3eb52 Mon Sep 17 00:00:00 2001 From: Matt Henderson Date: Wed, 14 Aug 2013 18:17:44 -0700 Subject: [PATCH 2/4] needed proper dict syntax --- IPython/html/notebookapp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IPython/html/notebookapp.py b/IPython/html/notebookapp.py index 41669b21f..bc2d4819a 100644 --- a/IPython/html/notebookapp.py +++ b/IPython/html/notebookapp.py @@ -179,7 +179,7 @@ class NotebookWebApplication(web.Application): settings.update(settings_overrides) # create a jinja2 environment using the template path and store it in settings - settings.jinja2_env=Environment(loader=FileSystemLoader(settings.template_path)) + settings["jinja2_env"]=Environment(loader=FileSystemLoader(settings["template_path"])) return settings From af03eb6d1b3fb0a5bdb1e768d545b8333e88fec9 Mon Sep 17 00:00:00 2001 From: Matt Henderson Date: Thu, 15 Aug 2013 16:28:19 -0700 Subject: [PATCH 3/4] Modified initial template_path to pickup any overridden value by the user --- IPython/html/notebookapp.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/IPython/html/notebookapp.py b/IPython/html/notebookapp.py index bc2d4819a..ec0423905 100644 --- a/IPython/html/notebookapp.py +++ b/IPython/html/notebookapp.py @@ -149,7 +149,7 @@ class NotebookWebApplication(web.Application): # Note that the URLs these patterns check against are escaped, # and thus guaranteed to be ASCII: 'héllo' is really 'h%C3%A9llo'. base_project_url = py3compat.unicode_to_str(base_project_url, 'ascii') - template_path = os.path.join(os.path.dirname(__file__), "templates") + template_path = settings_overrides.get("template_path", os.path.join(os.path.dirname(__file__), "templates")) settings = dict( # basics base_project_url=base_project_url, @@ -172,15 +172,12 @@ class NotebookWebApplication(web.Application): # IPython stuff mathjax_url=ipython_app.mathjax_url, config=ipython_app.config, - use_less=ipython_app.use_less + use_less=ipython_app.use_less, + jinja2_env=Environment(loader=FileSystemLoader(template_path)) ) # allow custom overrides for the tornado web app. settings.update(settings_overrides) - - # create a jinja2 environment using the template path and store it in settings - settings["jinja2_env"]=Environment(loader=FileSystemLoader(settings["template_path"])) - return settings def init_handlers(self, settings): From b7ed106d11d6dc6e95743efa741770b894f4d6e2 Mon Sep 17 00:00:00 2001 From: Matt Henderson Date: Thu, 15 Aug 2013 16:49:42 -0700 Subject: [PATCH 4/4] must...bring...back...comma --- IPython/html/notebookapp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IPython/html/notebookapp.py b/IPython/html/notebookapp.py index ec0423905..08b4f584a 100644 --- a/IPython/html/notebookapp.py +++ b/IPython/html/notebookapp.py @@ -173,7 +173,7 @@ class NotebookWebApplication(web.Application): mathjax_url=ipython_app.mathjax_url, config=ipython_app.config, use_less=ipython_app.use_less, - jinja2_env=Environment(loader=FileSystemLoader(template_path)) + jinja2_env=Environment(loader=FileSystemLoader(template_path)), ) # allow custom overrides for the tornado web app.