Nice dashboard page titles like /.../examples/notebooks/

This commit is contained in:
Brian E. Granger 2014-02-04 16:29:55 -08:00
parent 6ac7f6c2b4
commit 378b18b2fb
2 changed files with 15 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{% extends "page.html" %}
{% block title %}IPython Dashboard{% endblock %}
{% block title %}{{page_title}}{% endblock %}
{% block stylesheet %}

View File

@ -39,6 +39,18 @@ class TreeHandler(IPythonHandler):
breadcrumbs.append((link, comps[i]))
return breadcrumbs
def generate_page_title(self, path):
comps = path.split('/')
if len(comps) > 3:
for i in range(len(comps)-2):
comps.pop(0)
comps.insert(0, '...')
page_title = url_escape(url_path_join(*comps))
if page_title:
return '/'+page_title+'/'
else:
return '/'
@web.authenticated
def get(self, path='', name=None):
path = path.strip('/')
@ -55,9 +67,10 @@ class TreeHandler(IPythonHandler):
# no such directory, 404
raise web.HTTPError(404)
breadcrumbs = self.generate_breadcrumbs(path)
page_title = self.generate_page_title(path)
self.write(self.render_template('tree.html',
project=self.project_dir,
tree_url_path=path,
page_title=page_title,
notebook_path=path,
breadcrumbs=breadcrumbs
))