Show More
@@ -32,8 +32,6 import os | |||||
32 | from tornado import web |
|
32 | from tornado import web | |
33 | from tornado import websocket |
|
33 | from tornado import websocket | |
34 |
|
34 | |||
35 | from jinja2 import Environment, FileSystemLoader |
|
|||
36 |
|
||||
37 | from zmq.eventloop import ioloop |
|
35 | from zmq.eventloop import ioloop | |
38 | from zmq.utils import jsonapi |
|
36 | from zmq.utils import jsonapi | |
39 |
|
37 | |||
@@ -198,12 +196,6 class AuthenticatedHandler(RequestHandler): | |||||
198 | host = self.request.host # get from request |
|
196 | host = self.request.host # get from request | |
199 | return "%s://%s" % (proto, host) |
|
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 | class AuthenticatedFileHandler(AuthenticatedHandler, web.StaticFileHandler): |
|
200 | class AuthenticatedFileHandler(AuthenticatedHandler, web.StaticFileHandler): | |
209 | """static files should only be accessible when logged in""" |
|
201 | """static files should only be accessible when logged in""" | |
@@ -219,7 +211,7 class ProjectDashboardHandler(AuthenticatedHandler): | |||||
219 | def get(self): |
|
211 | def get(self): | |
220 | nbm = self.application.notebook_manager |
|
212 | nbm = self.application.notebook_manager | |
221 | project = nbm.notebook_dir |
|
213 | project = nbm.notebook_dir | |
222 |
nb = self. |
|
214 | nb = self.application.jinja2_env.get_template('projectdashboard.html') | |
223 | self.write( nb.render(project=project, |
|
215 | self.write( nb.render(project=project, | |
224 | base_project_url=self.application.ipython_app.base_project_url, |
|
216 | base_project_url=self.application.ipython_app.base_project_url, | |
225 | base_kernel_url=self.application.ipython_app.base_kernel_url, |
|
217 | base_kernel_url=self.application.ipython_app.base_kernel_url, | |
@@ -231,7 +223,7 class ProjectDashboardHandler(AuthenticatedHandler): | |||||
231 | class LoginHandler(AuthenticatedHandler): |
|
223 | class LoginHandler(AuthenticatedHandler): | |
232 |
|
224 | |||
233 | def _render(self, message=None): |
|
225 | def _render(self, message=None): | |
234 |
nb = self. |
|
226 | nb = self.application.jinja2_env.get_template('login.html') | |
235 | self.write( nb.render( |
|
227 | self.write( nb.render( | |
236 | next=self.get_argument('next', default=self.application.ipython_app.base_project_url), |
|
228 | next=self.get_argument('next', default=self.application.ipython_app.base_project_url), | |
237 | read_only=self.read_only, |
|
229 | read_only=self.read_only, | |
@@ -268,7 +260,7 class LogoutHandler(AuthenticatedHandler): | |||||
268 | else: |
|
260 | else: | |
269 | message = {'warning': 'Cannot log out. Notebook authentication ' |
|
261 | message = {'warning': 'Cannot log out. Notebook authentication ' | |
270 | 'is disabled.'} |
|
262 | 'is disabled.'} | |
271 |
nb = self. |
|
263 | nb = self.application.jinja2_env.get_template('logout.html') | |
272 | self.write( nb.render( |
|
264 | self.write( nb.render( | |
273 | read_only=self.read_only, |
|
265 | read_only=self.read_only, | |
274 | logged_in=self.logged_in, |
|
266 | logged_in=self.logged_in, | |
@@ -294,7 +286,7 class NamedNotebookHandler(AuthenticatedHandler): | |||||
294 | project = nbm.notebook_dir |
|
286 | project = nbm.notebook_dir | |
295 | if not nbm.notebook_exists(notebook_id): |
|
287 | if not nbm.notebook_exists(notebook_id): | |
296 | raise web.HTTPError(404, u'Notebook does not exist: %s' % notebook_id) |
|
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 | self.write( nb.render(project=project, |
|
290 | self.write( nb.render(project=project, | |
299 | notebook_id=notebook_id, |
|
291 | notebook_id=notebook_id, | |
300 | base_project_url=self.application.ipython_app.base_project_url, |
|
292 | base_project_url=self.application.ipython_app.base_project_url, | |
@@ -314,7 +306,7 class PrintNotebookHandler(AuthenticatedHandler): | |||||
314 | project = nbm.notebook_dir |
|
306 | project = nbm.notebook_dir | |
315 | if not nbm.notebook_exists(notebook_id): |
|
307 | if not nbm.notebook_exists(notebook_id): | |
316 | raise web.HTTPError(404, u'Notebook does not exist: %s' % notebook_id) |
|
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 | self.write( nb.render( |
|
310 | self.write( nb.render( | |
319 | project=project, |
|
311 | project=project, | |
320 | notebook_id=notebook_id, |
|
312 | notebook_id=notebook_id, |
@@ -33,6 +33,7 import webbrowser | |||||
33 |
|
33 | |||
34 | # Third party |
|
34 | # Third party | |
35 | import zmq |
|
35 | import zmq | |
|
36 | from jinja2 import Environment, FileSystemLoader | |||
36 |
|
37 | |||
37 | # Install the pyzmq ioloop. This has to be done before anything else from |
|
38 | # Install the pyzmq ioloop. This has to be done before anything else from | |
38 | # tornado is imported. |
|
39 | # tornado is imported. | |
@@ -186,6 +187,8 class NotebookWebApplication(web.Application): | |||||
186 | self.ipython_app = ipython_app |
|
187 | self.ipython_app = ipython_app | |
187 | self.read_only = self.ipython_app.read_only |
|
188 | self.read_only = self.ipython_app.read_only | |
188 | self.log = log |
|
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