##// END OF EJS Templates
address review in install doc
address review in install doc

File last commit:

r18979:ee673d8b
r20534:0ae199a2
Show More
handlers.py
73 lines | 2.6 KiB | text/x-python | PythonLexer
MinRK
teach contents service about non-notebook files
r17525 """Tornado handlers for the tree view."""
Brian E. Granger
Adding new files.
r10641
MinRK
teach contents service about non-notebook files
r17525 # Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
Brian E. Granger
Adding new files.
r10641
MinRK
remove notebook read-only view...
r11644 from tornado import web
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 from ..base.handlers import IPythonHandler, path_regex
Spencer Nelson
Remove unused imports
r16525 from ..utils import url_path_join, url_escape
Brian E. Granger
Adding new files.
r10641
MinRK
Simplify Tree handlers...
r13055 class TreeHandler(IPythonHandler):
"""Render the tree view, listing notebooks, clusters, etc."""
Brian E. Granger
Adding new files.
r10641
Brian E. Granger
Adding proper breadcrumb support.
r15073 def generate_breadcrumbs(self, path):
MinRK
s/base_project_url/base_url/...
r15238 breadcrumbs = [(url_escape(url_path_join(self.base_url, 'tree')), '')]
Brian E. Granger
Adding proper breadcrumb support.
r15073 comps = path.split('/')
ncomps = len(comps)
for i in range(ncomps):
if comps[i]:
MinRK
s/base_project_url/base_url/...
r15238 link = url_escape(url_path_join(self.base_url, 'tree', *comps[0:i+1]))
Brian E. Granger
Adding proper breadcrumb support.
r15073 breadcrumbs.append((link, comps[i]))
return breadcrumbs
Brian E. Granger
Nice dashboard page titles like /.../examples/notebooks/
r15085 def generate_page_title(self, path):
comps = path.split('/')
if len(comps) > 3:
for i in range(len(comps)-2):
comps.pop(0)
Spencer Nelson
Don't urlescape the text that goes into a title tag
r16524 page_title = url_path_join(*comps)
Brian E. Granger
Nice dashboard page titles like /.../examples/notebooks/
r15085 if page_title:
Brian E. Granger
Another variation of the dashboard page title.
r15089 return page_title+'/'
Brian E. Granger
Nice dashboard page titles like /.../examples/notebooks/
r15085 else:
Brian E. Granger
Another variation of the dashboard page title.
r15089 return 'Home'
Brian E. Granger
Nice dashboard page titles like /.../examples/notebooks/
r15085
MinRK
remove notebook read-only view...
r11644 @web.authenticated
MinRK
Remove separate 'path', 'name' in Contents API...
r18749 def get(self, path=''):
MinRK
strip '/' from paths in template-render handlers
r13117 path = path.strip('/')
MinRK
rename notebooks service to contents service...
r17524 cm = self.contents_manager
Matthias Bussonnier
fix clientside notebook manager and assume tree is dir by default...
r18979 if cm.dir_exists(path=path):
if cm.is_hidden(path):
Paul Ivanov
fix test suite...
r15630 self.log.info("Refusing to serve hidden directory, via 404 Error")
raise web.HTTPError(404)
Brian E. Granger
Adding proper breadcrumb support.
r15073 breadcrumbs = self.generate_breadcrumbs(path)
Brian E. Granger
Nice dashboard page titles like /.../examples/notebooks/
r15085 page_title = self.generate_page_title(path)
Zachary Sailer
manual rebase tree/handlers.py
r12990 self.write(self.render_template('tree.html',
Brian E. Granger
Nice dashboard page titles like /.../examples/notebooks/
r15085 page_title=page_title,
Zachary Sailer
manual rebase tree/handlers.py
r12990 notebook_path=path,
Thomas Kluyver
Only display terminals in dashboard if terminals are available
r18557 breadcrumbs=breadcrumbs,
terminals_available=self.settings['terminals_available'],
MinRK
Simplify Tree handlers...
r13055 ))
Matthias Bussonnier
fix clientside notebook manager and assume tree is dir by default...
r18979 elif cm.file_exists(path):
# it's not a directory, we have redirecting to do
model = cm.get(path, content=False)
# redirect to /api/notebooks if it's a notebook, otherwise /api/files
service = 'notebooks' if model['type'] == 'notebook' else 'files'
url = url_escape(url_path_join(
self.base_url, service, path,
))
self.log.debug("Redirecting %s to %s", self.request.path, url)
self.redirect(url)
else:
raise web.HTTPError(404)
Zachary Sailer
manual rebase tree/handlers.py
r12990
Brian E. Granger
More work on the handlers
r10647 #-----------------------------------------------------------------------------
# URL to handler mappings
#-----------------------------------------------------------------------------
Zachary Sailer
manual rebase tree/handlers.py
r12990 default_handlers = [
Thomas Kluyver
Move notebook URL fragment regexen into IPython.html.base.handlers
r13916 (r"/tree%s" % path_regex, TreeHandler),
MinRK
Simplify Tree handlers...
r13055 (r"/tree", TreeHandler),
Zachary Sailer
manual rebase tree/handlers.py
r12990 ]