##// END OF EJS Templates
get cell correctly in nested context...
get cell correctly in nested context fix some extensions like live_reveal the .not('.cell .cell') part prevent the potential selection of DOM elelment that would have the class cell from any output. In each branch of the dom we thus select the first decendent node that have the class '.cell'.

File last commit:

r18758:8ab80d68
r19086:baacd87d
Show More
handlers.py
49 lines | 1.4 KiB | text/x-python | PythonLexer
"""Tornado handlers for the live notebook view."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import os
from tornado import web
HTTPError = web.HTTPError
from ..base.handlers import (
IPythonHandler, FilesRedirectHandler,
notebook_path_regex, path_regex,
)
from ..utils import url_escape
class NotebookHandler(IPythonHandler):
@web.authenticated
def get(self, path):
"""get renders the notebook template if a name is given, or
redirects to the '/files/' handler if the name is not given."""
path = path.strip('/')
cm = self.contents_manager
# a .ipynb filename was given
if not cm.file_exists(path):
raise web.HTTPError(404, u'Notebook does not exist: %s' % path)
name = url_escape(path.rsplit('/', 1)[-1])
path = url_escape(path)
self.write(self.render_template('notebook.html',
notebook_path=path,
notebook_name=name,
kill_kernel=False,
mathjax_url=self.mathjax_url,
)
)
#-----------------------------------------------------------------------------
# URL to handler mappings
#-----------------------------------------------------------------------------
default_handlers = [
(r"/notebooks%s" % notebook_path_regex, NotebookHandler),
(r"/notebooks%s" % path_regex, FilesRedirectHandler),
]