Show More
@@ -32,8 +32,6 import os | |||
|
32 | 32 | from tornado import web |
|
33 | 33 | from tornado import websocket |
|
34 | 34 | |
|
35 | from jinja2 import Environment, FileSystemLoader | |
|
36 | ||
|
37 | 35 | from zmq.eventloop import ioloop |
|
38 | 36 | from zmq.utils import jsonapi |
|
39 | 37 | |
@@ -198,12 +196,6 class AuthenticatedHandler(RequestHandler): | |||
|
198 | 196 | host = self.request.host # get from request |
|
199 | 197 | return "%s://%s" % (proto, host) |
|
200 | 198 | |
|
201 | @property | |
|
202 | def environment(self): | |
|
203 | """ Jinja 2 template base directory | |
|
204 | """ | |
|
205 | env = Environment(loader=FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates"))) | |
|
206 | return env | |
|
207 | 199 | |
|
208 | 200 | class AuthenticatedFileHandler(AuthenticatedHandler, web.StaticFileHandler): |
|
209 | 201 | """static files should only be accessible when logged in""" |
@@ -219,7 +211,7 class ProjectDashboardHandler(AuthenticatedHandler): | |||
|
219 | 211 | def get(self): |
|
220 | 212 | nbm = self.application.notebook_manager |
|
221 | 213 | project = nbm.notebook_dir |
|
222 |
nb = self. |
|
|
214 | nb = self.application.jinja2_env.get_template('projectdashboard.html') | |
|
223 | 215 | self.write( nb.render(project=project, |
|
224 | 216 | base_project_url=self.application.ipython_app.base_project_url, |
|
225 | 217 | base_kernel_url=self.application.ipython_app.base_kernel_url, |
@@ -231,7 +223,7 class ProjectDashboardHandler(AuthenticatedHandler): | |||
|
231 | 223 | class LoginHandler(AuthenticatedHandler): |
|
232 | 224 | |
|
233 | 225 | def _render(self, message=None): |
|
234 |
nb = self. |
|
|
226 | nb = self.application.jinja2_env.get_template('login.html') | |
|
235 | 227 | self.write( nb.render( |
|
236 | 228 | next=self.get_argument('next', default=self.application.ipython_app.base_project_url), |
|
237 | 229 | read_only=self.read_only, |
@@ -268,7 +260,7 class LogoutHandler(AuthenticatedHandler): | |||
|
268 | 260 | else: |
|
269 | 261 | message = {'warning': 'Cannot log out. Notebook authentication ' |
|
270 | 262 | 'is disabled.'} |
|
271 |
nb = self. |
|
|
263 | nb = self.application.jinja2_env.get_template('logout.html') | |
|
272 | 264 | self.write( nb.render( |
|
273 | 265 | read_only=self.read_only, |
|
274 | 266 | logged_in=self.logged_in, |
@@ -294,7 +286,7 class NamedNotebookHandler(AuthenticatedHandler): | |||
|
294 | 286 | project = nbm.notebook_dir |
|
295 | 287 | if not nbm.notebook_exists(notebook_id): |
|
296 | 288 | raise web.HTTPError(404, u'Notebook does not exist: %s' % notebook_id) |
|
297 |
nb = self. |
|
|
289 | nb = self.application.jinja2_env.get_template('notebook.html') | |
|
298 | 290 | self.write( nb.render(project=project, |
|
299 | 291 | notebook_id=notebook_id, |
|
300 | 292 | base_project_url=self.application.ipython_app.base_project_url, |
@@ -314,7 +306,7 class PrintNotebookHandler(AuthenticatedHandler): | |||
|
314 | 306 | project = nbm.notebook_dir |
|
315 | 307 | if not nbm.notebook_exists(notebook_id): |
|
316 | 308 | raise web.HTTPError(404, u'Notebook does not exist: %s' % notebook_id) |
|
317 |
nb = self. |
|
|
309 | nb = self.application.jinja2_env.get_template('printnotebook.html') | |
|
318 | 310 | self.write( nb.render( |
|
319 | 311 | project=project, |
|
320 | 312 | notebook_id=notebook_id, |
@@ -33,6 +33,7 import webbrowser | |||
|
33 | 33 | |
|
34 | 34 | # Third party |
|
35 | 35 | import zmq |
|
36 | from jinja2 import Environment, FileSystemLoader | |
|
36 | 37 | |
|
37 | 38 | # Install the pyzmq ioloop. This has to be done before anything else from |
|
38 | 39 | # tornado is imported. |
@@ -186,6 +187,8 class NotebookWebApplication(web.Application): | |||
|
186 | 187 | self.ipython_app = ipython_app |
|
187 | 188 | self.read_only = self.ipython_app.read_only |
|
188 | 189 | self.log = log |
|
190 | self.jinja2_env = Environment(loader=FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates"))) | |
|
191 | ||
|
189 | 192 | |
|
190 | 193 | |
|
191 | 194 | #----------------------------------------------------------------------------- |
General Comments 0
You need to be logged in to leave comments.
Login now