##// END OF EJS Templates
Adding proper breadcrumb support.
Brian E. Granger -
Show More
@@ -47,8 +47,9 b' data-base-kernel-url="{{base_kernel_url}}"'
47 <div id="notebook_list_header" class="row-fluid list_header">
47 <div id="notebook_list_header" class="row-fluid list_header">
48 <div id="project_name">
48 <div id="project_name">
49 <ul class="breadcrumb">
49 <ul class="breadcrumb">
50 {% for component in tree_url_path.strip('/').split('/') %}
50 <li><span><a href="{{breadcrumbs[0][0]}}">/</a></span></li>
51 <li>{{component}} <span>/</span></li>
51 {% for crumb in breadcrumbs[1:] %}
52 <li><a href="{{crumb[0]}}">{{crumb[1]}}</a> <span>/</span></li>
52 {% endfor %}
53 {% endfor %}
53 </ul>
54 </ul>
54 </div>
55 </div>
@@ -29,6 +29,16 b' from ..utils import url_path_join, path2url, url2path, url_escape'
29 class TreeHandler(IPythonHandler):
29 class TreeHandler(IPythonHandler):
30 """Render the tree view, listing notebooks, clusters, etc."""
30 """Render the tree view, listing notebooks, clusters, etc."""
31
31
32 def generate_breadcrumbs(self, path):
33 breadcrumbs = [(url_escape(url_path_join(self.base_project_url, 'tree')), '')]
34 comps = path.split('/')
35 ncomps = len(comps)
36 for i in range(ncomps):
37 if comps[i]:
38 link = url_escape(url_path_join(self.base_project_url, 'tree', *comps[0:i+1]))
39 breadcrumbs.append((link, comps[i]))
40 return breadcrumbs
41
32 @web.authenticated
42 @web.authenticated
33 def get(self, path='', name=None):
43 def get(self, path='', name=None):
34 path = path.strip('/')
44 path = path.strip('/')
@@ -44,10 +54,12 b' class TreeHandler(IPythonHandler):'
44 if not nbm.path_exists(path=path):
54 if not nbm.path_exists(path=path):
45 # no such directory, 404
55 # no such directory, 404
46 raise web.HTTPError(404)
56 raise web.HTTPError(404)
57 breadcrumbs = self.generate_breadcrumbs(path)
47 self.write(self.render_template('tree.html',
58 self.write(self.render_template('tree.html',
48 project=self.project_dir,
59 project=self.project_dir,
49 tree_url_path=path,
60 tree_url_path=path,
50 notebook_path=path,
61 notebook_path=path,
62 breadcrumbs=breadcrumbs
51 ))
63 ))
52
64
53
65
General Comments 0
You need to be logged in to leave comments. Login now