From acff400f1b3d0d61dead59b30a1991dc0ec6e035 2014-02-05 00:29:55 From: Brian E. Granger Date: 2014-02-05 00:29:55 Subject: [PATCH] Nice dashboard page titles like /.../examples/notebooks/ --- diff --git a/IPython/html/templates/tree.html b/IPython/html/templates/tree.html index 652ed13..d050200 100644 --- a/IPython/html/templates/tree.html +++ b/IPython/html/templates/tree.html @@ -1,6 +1,6 @@ {% extends "page.html" %} -{% block title %}IPython Dashboard{% endblock %} +{% block title %}{{page_title}}{% endblock %} {% block stylesheet %} diff --git a/IPython/html/tree/handlers.py b/IPython/html/tree/handlers.py index 98241de..e0979c4 100644 --- a/IPython/html/tree/handlers.py +++ b/IPython/html/tree/handlers.py @@ -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 ))