##// END OF EJS Templates
outputarea.js: Wrap inline SVGs inside an iframe...
outputarea.js: Wrap inline SVGs inside an iframe When multiple inline SVGs are included in a single document, they share the same parse tree. Therefore, style collisions and use id collisions can occur and upset the rendering. This patch wraps each SVG inside an individual iframe, ensuring that SVG's declarations do not collide. (The SVG representation is kept as XML and not converted to a binary format, so I do not think this approach precludes the use of d3.js) Tested on: * Chrome Version 29.0.1547.57 Debian 7.1 (217859) * Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130806 Firefox/17.0 Iceweasel/17.0.8 Closes #1866

File last commit:

r13398:da0c6c29
r13408:333abbe5
Show More
handlers.py
79 lines | 2.8 KiB | text/x-python | PythonLexer
"""Tornado handlers for the live notebook view.
Authors:
* Brian Granger
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2011 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
from tornado import web
HTTPError = web.HTTPError
from ..base.handlers import IPythonHandler
from ..services.notebooks.handlers import _notebook_path_regex, _path_regex
from ..utils import url_path_join, url_escape
#-----------------------------------------------------------------------------
# Handlers
#-----------------------------------------------------------------------------
class NotebookHandler(IPythonHandler):
@web.authenticated
def get(self, path='', name=None):
"""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('/')
nbm = self.notebook_manager
if name is None:
raise web.HTTPError(500, "This shouldn't be accessible: %s" % self.request.uri)
# a .ipynb filename was given
if not nbm.notebook_exists(name, path):
raise web.HTTPError(404, u'Notebook does not exist: %s/%s' % (path, name))
name = url_escape(name)
path = url_escape(path)
self.write(self.render_template('notebook.html',
project=self.project_dir,
notebook_path=path,
notebook_name=name,
kill_kernel=False,
mathjax_url=self.mathjax_url,
)
)
class NotebookRedirectHandler(IPythonHandler):
def get(self, path=''):
nbm = self.notebook_manager
if nbm.path_exists(path):
# it's a *directory*, redirect to /tree
url = url_path_join(self.base_project_url, 'tree', path)
else:
# otherwise, redirect to /files
# TODO: This should check if it's actually a file
url = url_path_join(self.base_project_url, 'files', path)
url = url_escape(url)
self.log.debug("Redirecting %s to %s", self.request.path, url)
self.redirect(url)
#-----------------------------------------------------------------------------
# URL to handler mappings
#-----------------------------------------------------------------------------
default_handlers = [
(r"/notebooks%s" % _notebook_path_regex, NotebookHandler),
(r"/notebooks%s" % _path_regex, NotebookRedirectHandler),
]