##// END OF EJS Templates
Adding proper breadcrumb support.
Brian E. Granger -
Show More
@@ -1,91 +1,92 b''
1 {% extends "page.html" %}
1 {% extends "page.html" %}
2
2
3 {% block title %}IPython Dashboard{% endblock %}
3 {% block title %}IPython Dashboard{% endblock %}
4
4
5
5
6 {% block stylesheet %}
6 {% block stylesheet %}
7 {{super()}}
7 {{super()}}
8 <link rel="stylesheet" href="{{ static_url("tree/css/override.css") }}" type="text/css" />
8 <link rel="stylesheet" href="{{ static_url("tree/css/override.css") }}" type="text/css" />
9 {% endblock %}
9 {% endblock %}
10
10
11 {% block params %}
11 {% block params %}
12
12
13 data-project="{{project}}"
13 data-project="{{project}}"
14 data-base-project-url="{{base_project_url}}"
14 data-base-project-url="{{base_project_url}}"
15 data-notebook-path="{{notebook_path}}"
15 data-notebook-path="{{notebook_path}}"
16 data-base-kernel-url="{{base_kernel_url}}"
16 data-base-kernel-url="{{base_kernel_url}}"
17
17
18 {% endblock %}
18 {% endblock %}
19
19
20
20
21 {% block site %}
21 {% block site %}
22
22
23 <div id="ipython-main-app" class="container">
23 <div id="ipython-main-app" class="container">
24
24
25 <div id="tabs" class="tabbable">
25 <div id="tabs" class="tabbable">
26 <ul class="nav nav-tabs" id="tabs">
26 <ul class="nav nav-tabs" id="tabs">
27 <li class="active"><a href="#notebooks" data-toggle="tab">Notebooks</a></li>
27 <li class="active"><a href="#notebooks" data-toggle="tab">Notebooks</a></li>
28 <li><a href="#clusters" data-toggle="tab">Clusters</a></li>
28 <li><a href="#clusters" data-toggle="tab">Clusters</a></li>
29 </ul>
29 </ul>
30
30
31 <div class="tab-content">
31 <div class="tab-content">
32 <div id="notebooks" class="tab-pane active">
32 <div id="notebooks" class="tab-pane active">
33 <div id="notebook_toolbar">
33 <div id="notebook_toolbar">
34 <form id='alternate_upload' class='alternate_upload' >
34 <form id='alternate_upload' class='alternate_upload' >
35 <span id="drag_info" style="position:absolute" >
35 <span id="drag_info" style="position:absolute" >
36 To import a notebook, drag the file onto the listing below or <strong>click here</strong>.
36 To import a notebook, drag the file onto the listing below or <strong>click here</strong>.
37 </span>
37 </span>
38 <input type="file" name="datafile" class="fileinput" multiple='multiple'>
38 <input type="file" name="datafile" class="fileinput" multiple='multiple'>
39 </form>
39 </form>
40 <span id="notebook_buttons">
40 <span id="notebook_buttons">
41 <button id="refresh_notebook_list" title="Refresh notebook list" class="btn btn-small">Refresh</button>
41 <button id="refresh_notebook_list" title="Refresh notebook list" class="btn btn-small">Refresh</button>
42 <button id="new_notebook" title="Create new notebook" class="btn btn-small">New Notebook</button>
42 <button id="new_notebook" title="Create new notebook" class="btn btn-small">New Notebook</button>
43 </span>
43 </span>
44 </div>
44 </div>
45
45
46 <div id="notebook_list">
46 <div id="notebook_list">
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>
55 </div>
56 </div>
56 </div>
57 </div>
57 </div>
58 </div>
58
59
59 <div id="clusters" class="tab-pane">
60 <div id="clusters" class="tab-pane">
60
61
61 <div id="cluster_toolbar">
62 <div id="cluster_toolbar">
62 <span id="cluster_list_info">IPython parallel computing clusters</span>
63 <span id="cluster_list_info">IPython parallel computing clusters</span>
63
64
64 <span id="cluster_buttons">
65 <span id="cluster_buttons">
65 <button id="refresh_cluster_list" title="Refresh cluster list" class="btn btn-small">Refresh</button>
66 <button id="refresh_cluster_list" title="Refresh cluster list" class="btn btn-small">Refresh</button>
66 </span>
67 </span>
67 </div>
68 </div>
68
69
69 <div id="cluster_list">
70 <div id="cluster_list">
70 <div id="cluster_list_header" class="row-fluid list_header">
71 <div id="cluster_list_header" class="row-fluid list_header">
71 <span class="profile_col span4">profile</span>
72 <span class="profile_col span4">profile</span>
72 <span class="status_col span3">status</span>
73 <span class="status_col span3">status</span>
73 <span class="engines_col span3" title="Enter the number of engines to start or empty for default"># of engines</span>
74 <span class="engines_col span3" title="Enter the number of engines to start or empty for default"># of engines</span>
74 <span class="action_col span2">action</span>
75 <span class="action_col span2">action</span>
75 </div>
76 </div>
76 </div>
77 </div>
77 </div>
78 </div>
78 </div>
79 </div>
79
80
80 </div>
81 </div>
81
82
82 {% endblock %}
83 {% endblock %}
83
84
84 {% block script %}
85 {% block script %}
85 {{super()}}
86 {{super()}}
86 <script src="{{ static_url("base/js/utils.js") }}" type="text/javascript" charset="utf-8"></script>
87 <script src="{{ static_url("base/js/utils.js") }}" type="text/javascript" charset="utf-8"></script>
87 <script src="{{static_url("base/js/dialog.js") }}" type="text/javascript" charset="utf-8"></script>
88 <script src="{{static_url("base/js/dialog.js") }}" type="text/javascript" charset="utf-8"></script>
88 <script src="{{static_url("tree/js/notebooklist.js") }}" type="text/javascript" charset="utf-8"></script>
89 <script src="{{static_url("tree/js/notebooklist.js") }}" type="text/javascript" charset="utf-8"></script>
89 <script src="{{static_url("tree/js/clusterlist.js") }}" type="text/javascript" charset="utf-8"></script>
90 <script src="{{static_url("tree/js/clusterlist.js") }}" type="text/javascript" charset="utf-8"></script>
90 <script src="{{static_url("tree/js/main.js") }}" type="text/javascript" charset="utf-8"></script>
91 <script src="{{static_url("tree/js/main.js") }}" type="text/javascript" charset="utf-8"></script>
91 {% endblock %}
92 {% endblock %}
@@ -1,76 +1,88 b''
1 """Tornado handlers for the tree view.
1 """Tornado handlers for the tree view.
2
2
3 Authors:
3 Authors:
4
4
5 * Brian Granger
5 * Brian Granger
6 """
6 """
7
7
8 #-----------------------------------------------------------------------------
8 #-----------------------------------------------------------------------------
9 # Copyright (C) 2011 The IPython Development Team
9 # Copyright (C) 2011 The IPython Development Team
10 #
10 #
11 # Distributed under the terms of the BSD License. The full license is in
11 # Distributed under the terms of the BSD License. The full license is in
12 # the file COPYING, distributed as part of this software.
12 # the file COPYING, distributed as part of this software.
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14
14
15 #-----------------------------------------------------------------------------
15 #-----------------------------------------------------------------------------
16 # Imports
16 # Imports
17 #-----------------------------------------------------------------------------
17 #-----------------------------------------------------------------------------
18 import os
18 import os
19
19
20 from tornado import web
20 from tornado import web
21 from ..base.handlers import IPythonHandler, notebook_path_regex, path_regex
21 from ..base.handlers import IPythonHandler, notebook_path_regex, path_regex
22 from ..utils import url_path_join, path2url, url2path, url_escape
22 from ..utils import url_path_join, path2url, url2path, url_escape
23
23
24 #-----------------------------------------------------------------------------
24 #-----------------------------------------------------------------------------
25 # Handlers
25 # Handlers
26 #-----------------------------------------------------------------------------
26 #-----------------------------------------------------------------------------
27
27
28
28
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('/')
35 nbm = self.notebook_manager
45 nbm = self.notebook_manager
36 if name is not None:
46 if name is not None:
37 # is a notebook, redirect to notebook handler
47 # is a notebook, redirect to notebook handler
38 url = url_escape(url_path_join(
48 url = url_escape(url_path_join(
39 self.base_project_url, 'notebooks', path, name
49 self.base_project_url, 'notebooks', path, name
40 ))
50 ))
41 self.log.debug("Redirecting %s to %s", self.request.path, url)
51 self.log.debug("Redirecting %s to %s", self.request.path, url)
42 self.redirect(url)
52 self.redirect(url)
43 else:
53 else:
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
54 class TreeRedirectHandler(IPythonHandler):
66 class TreeRedirectHandler(IPythonHandler):
55 """Redirect a request to the corresponding tree URL"""
67 """Redirect a request to the corresponding tree URL"""
56
68
57 @web.authenticated
69 @web.authenticated
58 def get(self, path=''):
70 def get(self, path=''):
59 url = url_escape(url_path_join(
71 url = url_escape(url_path_join(
60 self.base_project_url, 'tree', path.strip('/')
72 self.base_project_url, 'tree', path.strip('/')
61 ))
73 ))
62 self.log.debug("Redirecting %s to %s", self.request.path, url)
74 self.log.debug("Redirecting %s to %s", self.request.path, url)
63 self.redirect(url)
75 self.redirect(url)
64
76
65
77
66 #-----------------------------------------------------------------------------
78 #-----------------------------------------------------------------------------
67 # URL to handler mappings
79 # URL to handler mappings
68 #-----------------------------------------------------------------------------
80 #-----------------------------------------------------------------------------
69
81
70
82
71 default_handlers = [
83 default_handlers = [
72 (r"/tree%s" % notebook_path_regex, TreeHandler),
84 (r"/tree%s" % notebook_path_regex, TreeHandler),
73 (r"/tree%s" % path_regex, TreeHandler),
85 (r"/tree%s" % path_regex, TreeHandler),
74 (r"/tree", TreeHandler),
86 (r"/tree", TreeHandler),
75 (r"/", TreeRedirectHandler),
87 (r"/", TreeRedirectHandler),
76 ]
88 ]
General Comments 0
You need to be logged in to leave comments. Login now