##// END OF EJS Templates
Merge pull request #7665 from jdfreder/fixedmodeindi2...
Merge pull request #7665 from jdfreder/fixedmodeindi2 Fix the mode indicator width.

File last commit:

r19742:5bcd54d3
r20310:2e4fbcff merge
Show More
handlers.py
56 lines | 1.7 KiB | text/x-python | PythonLexer
MinRK
move `/files/` redirect to base handlers...
r17533 """Tornado handlers for the live notebook view."""
Brian E. Granger
Adding new files.
r10641
MinRK
move `/files/` redirect to base handlers...
r17533 # Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
Brian E. Granger
Adding new files.
r10641
MinRK
support 1.0-style `files/` relative URLs...
r13563 import os
Brian E. Granger
Adding new files.
r10641 from tornado import web
Brian E. Granger
Splitting handlers into different files....
r10642 HTTPError = web.HTTPError
Brian E. Granger
Adding new files.
r10641
MinRK
move `/files/` redirect to base handlers...
r17533 from ..base.handlers import (
Min RK
don't enforce .ipynb extension in URLs...
r19675 IPythonHandler, FilesRedirectHandler, path_regex,
MinRK
move `/files/` redirect to base handlers...
r17533 )
from ..utils import url_escape
Brian E. Granger
Adding new files.
r10641
Zachary Sailer
removed '/new' URL and added POST notebook request
r13016 class NotebookHandler(IPythonHandler):
Brian E. Granger
Adding new files.
r10641
@web.authenticated
Min RK
address review in contents service...
r18758 def get(self, path):
Paul Ivanov
named_notebook_path: consistent usage convention
r13029 """get renders the notebook template if a name is given, or
redirects to the '/files/' handler if the name is not given."""
MinRK
strip '/' from paths in template-render handlers
r13117 path = path.strip('/')
MinRK
rename notebooks service to contents service...
r17524 cm = self.contents_manager
MinRK
cleanup old, unused `/notebooks/foo` API methods...
r13073
Min RK
don't enforce .ipynb extension in URLs...
r19675 # will raise 404 on not found
Min RK
checkpoint
r19676 try:
model = cm.get(path, content=False)
except web.HTTPError as e:
Min RK
handle deprecated files redirect on /notebooks
r19741 if e.status_code == 404 and 'files' in path.split('/'):
Min RK
checkpoint
r19676 # 404, but '/files/' in URL, let FilesRedirect take care of it
Min RK
make FilesRedirectHandler redirect logic accessible...
r19742 return FilesRedirectHandler.redirect_to_files(self, path)
Min RK
checkpoint
r19676 else:
raise
Min RK
don't enforce .ipynb extension in URLs...
r19675 if model['type'] != 'notebook':
# not a notebook, redirect to files
Min RK
make FilesRedirectHandler redirect logic accessible...
r19742 return FilesRedirectHandler.redirect_to_files(self, path)
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 name = url_escape(path.rsplit('/', 1)[-1])
MinRK
move url_[un]escape to utils from nbm
r13068 path = url_escape(path)
MinRK
adjust definition of 'path' in notebooks...
r13067 self.write(self.render_template('notebook.html',
notebook_path=path,
notebook_name=name,
kill_kernel=False,
mathjax_url=self.mathjax_url,
)
)
Zachary Sailer
removed '/new' URL and added POST notebook request
r13016
Brian E. Granger
Adding new files.
r10641
Brian E. Granger
More work on the handlers
r10647 #-----------------------------------------------------------------------------
# URL to handler mappings
#-----------------------------------------------------------------------------
default_handlers = [
Min RK
don't enforce .ipynb extension in URLs...
r19675 (r"/notebooks%s" % path_regex, NotebookHandler),
Zachary Sailer
fixing broken links from recent changes....
r13033 ]