From eef42aa032fda4e7da3754cd625e5b87de30dc73 Mon Sep 17 00:00:00 2001 From: Cameron Bates Date: Tue, 28 Aug 2012 18:34:27 +0200 Subject: [PATCH] fix paths for jinja2 so they work in installed ipython instances --- IPython/frontend/html/notebook/handlers.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/IPython/frontend/html/notebook/handlers.py b/IPython/frontend/html/notebook/handlers.py index 241475792..57cb5ed82 100644 --- a/IPython/frontend/html/notebook/handlers.py +++ b/IPython/frontend/html/notebook/handlers.py @@ -213,7 +213,7 @@ class ProjectDashboardHandler(AuthenticatedHandler): def get(self): nbm = self.application.notebook_manager project = nbm.notebook_dir - env = Environment(loader=FileSystemLoader(os.path.join(os.path.abspath("."), "IPython/frontend/html/notebook/templates"))) + env = Environment(loader=FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates"))) nb = env.get_template('projectdashboard.html') self.write( nb.render(project=project, base_project_url=self.application.ipython_app.base_project_url, @@ -226,7 +226,7 @@ class ProjectDashboardHandler(AuthenticatedHandler): class LoginHandler(AuthenticatedHandler): def _render(self, message=None): - env = Environment(loader=FileSystemLoader(os.path.join(os.path.abspath("."), "IPython/frontend/html/notebook/templates"))) + env = Environment(loader=FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates"))) nb = env.get_template('login.html') self.write( nb.render( next=self.get_argument('next', default=self.application.ipython_app.base_project_url), @@ -265,7 +265,7 @@ class LogoutHandler(AuthenticatedHandler): message = {'warning': 'Cannot log out. Notebook authentication ' 'is disabled.'} - env = Environment(loader=FileSystemLoader(os.path.join(os.path.abspath("."), "IPython/frontend/html/notebook/templates"))) + env = Environment(loader=FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates"))) nb = env.get_template('logout.html') self.write( nb.render( read_only=self.read_only, @@ -292,7 +292,8 @@ class NamedNotebookHandler(AuthenticatedHandler): project = nbm.notebook_dir if not nbm.notebook_exists(notebook_id): raise web.HTTPError(404, u'Notebook does not exist: %s' % notebook_id) - env = Environment(loader=FileSystemLoader(os.path.join(os.path.abspath("."), "IPython/frontend/html/notebook/templates"))) + + env = Environment(loader=FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates"))) nb = env.get_template('notebook/notebook.html') self.write( nb.render(project=project, notebook_id=notebook_id, @@ -314,7 +315,7 @@ class PrintNotebookHandler(AuthenticatedHandler): if not nbm.notebook_exists(notebook_id): raise web.HTTPError(404, u'Notebook does not exist: %s' % notebook_id) - env = Environment(loader=FileSystemLoader(os.path.join(os.path.abspath("."), "IPython/frontend/html/notebook/templates"))) + env = Environment(loader=FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates"))) nb = env.get_template('printnotebook.html') self.write( nb.render( project=project,