##// END OF EJS Templates
widen modal dialogs on wide displays...
widen modal dialogs on wide displays needed for quick help layout with multiple meta keys

File last commit:

r15630:d5bb5801
r15900:f64f9e13
Show More
handlers.py
103 lines | 3.5 KiB | text/x-python | PythonLexer
Brian E. Granger
Splitting handlers into different files....
r10642 """Tornado handlers for the tree view.
Brian E. Granger
Adding new files.
r10641
Authors:
* Brian Granger
"""
#-----------------------------------------------------------------------------
Brian E. Granger
Splitting handlers into different files....
r10642 # Copyright (C) 2011 The IPython Development Team
Brian E. Granger
Adding new files.
r10641 #
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
MinRK
Simplify Tree handlers...
r13055 import os
Brian E. Granger
Adding new files.
r10641
MinRK
remove notebook read-only view...
r11644 from tornado import web
Thomas Kluyver
Move notebook URL fragment regexen into IPython.html.base.handlers
r13916 from ..base.handlers import IPythonHandler, notebook_path_regex, path_regex
Brian E. Granger
Creating and testing IPython.html.utils.is_hidden.
r15097 from ..utils import url_path_join, path2url, url2path, url_escape, is_hidden
Brian E. Granger
Adding new files.
r10641
#-----------------------------------------------------------------------------
Brian E. Granger
Splitting handlers into different files....
r10642 # Handlers
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)
page_title = url_escape(url_path_join(*comps))
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
adjust definition of 'path' in notebooks...
r13067 def get(self, path='', name=None):
MinRK
strip '/' from paths in template-render handlers
r13117 path = path.strip('/')
Zachary Sailer
manual rebase tree/handlers.py
r12990 nbm = self.notebook_manager
Zachary Sailer
fixing broken links from recent changes....
r13033 if name is not None:
MinRK
Simplify Tree handlers...
r13055 # is a notebook, redirect to notebook handler
MinRK
url_escape redirects
r13135 url = url_escape(url_path_join(
MinRK
s/base_project_url/base_url/...
r15238 self.base_url, 'notebooks', path, name
MinRK
url_escape redirects
r13135 ))
self.log.debug("Redirecting %s to %s", self.request.path, url)
MinRK
Simplify Tree handlers...
r13055 self.redirect(url)
Zachary Sailer
manual rebase tree/handlers.py
r12990 else:
Paul Ivanov
fix test suite...
r15630 if not nbm.path_exists(path=path):
Brian E. Granger
Creating and testing IPython.html.utils.is_hidden.
r15097 # Directory is hidden or does not exist.
MinRK
Simplify Tree handlers...
r13055 raise web.HTTPError(404)
Paul Ivanov
fix test suite...
r15630 elif nbm.is_hidden(path):
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',
MinRK
Simplify Tree handlers...
r13055 project=self.project_dir,
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,
Brian E. Granger
Adding proper breadcrumb support.
r15073 breadcrumbs=breadcrumbs
MinRK
Simplify Tree handlers...
r13055 ))
Zachary Sailer
manual rebase tree/handlers.py
r12990
class TreeRedirectHandler(IPythonHandler):
MinRK
Simplify Tree handlers...
r13055 """Redirect a request to the corresponding tree URL"""
Zachary Sailer
fixing path redirects, cleaning path logic
r12992
Zachary Sailer
rebase master- eliminate read-only
r13014 @web.authenticated
MinRK
adjust definition of 'path' in notebooks...
r13067 def get(self, path=''):
MinRK
url_escape redirects
r13135 url = url_escape(url_path_join(
MinRK
s/base_project_url/base_url/...
r15238 self.base_url, 'tree', path.strip('/')
MinRK
url_escape redirects
r13135 ))
self.log.debug("Redirecting %s to %s", self.request.path, url)
Zachary Sailer
manual rebase tree/handlers.py
r12990 self.redirect(url)
Zachary Sailer
added folder creation ability using '/-new'
r13003
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" % notebook_path_regex, TreeHandler),
(r"/tree%s" % path_regex, TreeHandler),
MinRK
Simplify Tree handlers...
r13055 (r"/tree", TreeHandler),
(r"/", TreeRedirectHandler),
Zachary Sailer
manual rebase tree/handlers.py
r12990 ]