##// END OF EJS Templates
Nice dashboard page titles like /.../examples/notebooks/
Brian E. Granger -
Show More
@@ -1,99 +1,99 b''
1 {% extends "page.html" %}
1 {% extends "page.html" %}
2
2
3 {% block title %}IPython Dashboard{% endblock %}
3 {% block title %}{{page_title}}{% 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="tab_content" class="tabbable">
25 <div id="tab_content" class="tabbable">
26 <ul id="tabs" class="nav nav-tabs">
26 <ul id="tabs" class="nav nav-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" class="row-fluid">
33 <div id="notebook_toolbar" class="row-fluid">
34 <div class="span8">
34 <div class="span8">
35 <form id='alternate_upload' class='alternate_upload' >
35 <form id='alternate_upload' class='alternate_upload' >
36 <span id="drag_info" style="position:absolute" >
36 <span id="drag_info" style="position:absolute" >
37 To import a notebook, drag the file onto the listing below or <strong>click here</strong>.
37 To import a notebook, drag the file onto the listing below or <strong>click here</strong>.
38 </span>
38 </span>
39 <input type="file" name="datafile" class="fileinput" multiple='multiple'>
39 <input type="file" name="datafile" class="fileinput" multiple='multiple'>
40 </form>
40 </form>
41 </div>
41 </div>
42 <div class="span4 clearfix">
42 <div class="span4 clearfix">
43 <span id="notebook_buttons" class="pull-right">
43 <span id="notebook_buttons" class="pull-right">
44 <button id="new_notebook" title="Create new notebook" class="btn btn-small">New Notebook</button>
44 <button id="new_notebook" title="Create new notebook" class="btn btn-small">New Notebook</button>
45 <button id="refresh_notebook_list" title="Refresh notebook list" class="btn btn-small"><i class="icon-refresh"></i></button>
45 <button id="refresh_notebook_list" title="Refresh notebook list" class="btn btn-small"><i class="icon-refresh"></i></button>
46 </span>
46 </span>
47 </div>
47 </div>
48 </div>
48 </div>
49
49
50 <div id="notebook_list">
50 <div id="notebook_list">
51 <div id="notebook_list_header" class="row-fluid list_header">
51 <div id="notebook_list_header" class="row-fluid list_header">
52 <div id="project_name">
52 <div id="project_name">
53 <ul class="breadcrumb">
53 <ul class="breadcrumb">
54 <li><span><a href="{{breadcrumbs[0][0]}}">/</a></span></li>
54 <li><span><a href="{{breadcrumbs[0][0]}}">/</a></span></li>
55 {% for crumb in breadcrumbs[1:] %}
55 {% for crumb in breadcrumbs[1:] %}
56 <li><a href="{{crumb[0]}}">{{crumb[1]}}</a> <span>/</span></li>
56 <li><a href="{{crumb[0]}}">{{crumb[1]}}</a> <span>/</span></li>
57 {% endfor %}
57 {% endfor %}
58 </ul>
58 </ul>
59 </div>
59 </div>
60 </div>
60 </div>
61 </div>
61 </div>
62 </div>
62 </div>
63
63
64 <div id="clusters" class="tab-pane">
64 <div id="clusters" class="tab-pane">
65
65
66 <div id="cluster_toolbar" class="row-fluid">
66 <div id="cluster_toolbar" class="row-fluid">
67 <div class="span8">
67 <div class="span8">
68 <span id="cluster_list_info">IPython parallel computing clusters</span>
68 <span id="cluster_list_info">IPython parallel computing clusters</span>
69 </div>
69 </div>
70 <div class="span4" class="clearfix">
70 <div class="span4" class="clearfix">
71 <span id="cluster_buttons" class="pull-right">
71 <span id="cluster_buttons" class="pull-right">
72 <button id="refresh_cluster_list" title="Refresh cluster list" class="btn btn-small"><i class="icon-refresh"></i></button>
72 <button id="refresh_cluster_list" title="Refresh cluster list" class="btn btn-small"><i class="icon-refresh"></i></button>
73 </span>
73 </span>
74 </div>
74 </div>
75 </div>
75 </div>
76
76
77 <div id="cluster_list">
77 <div id="cluster_list">
78 <div id="cluster_list_header" class="row-fluid list_header">
78 <div id="cluster_list_header" class="row-fluid list_header">
79 <div class="profile_col span4">profile</div>
79 <div class="profile_col span4">profile</div>
80 <div class="status_col span3">status</div>
80 <div class="status_col span3">status</div>
81 <div class="engines_col span3" title="Enter the number of engines to start or empty for default"># of engines</div>
81 <div class="engines_col span3" title="Enter the number of engines to start or empty for default"># of engines</div>
82 <div class="action_col span2">action</div>
82 <div class="action_col span2">action</div>
83 </div>
83 </div>
84 </div>
84 </div>
85 </div>
85 </div>
86 </div>
86 </div>
87
87
88 </div>
88 </div>
89
89
90 {% endblock %}
90 {% endblock %}
91
91
92 {% block script %}
92 {% block script %}
93 {{super()}}
93 {{super()}}
94 <script src="{{ static_url("base/js/utils.js") }}" type="text/javascript" charset="utf-8"></script>
94 <script src="{{ static_url("base/js/utils.js") }}" type="text/javascript" charset="utf-8"></script>
95 <script src="{{static_url("base/js/dialog.js") }}" type="text/javascript" charset="utf-8"></script>
95 <script src="{{static_url("base/js/dialog.js") }}" type="text/javascript" charset="utf-8"></script>
96 <script src="{{static_url("tree/js/notebooklist.js") }}" type="text/javascript" charset="utf-8"></script>
96 <script src="{{static_url("tree/js/notebooklist.js") }}" type="text/javascript" charset="utf-8"></script>
97 <script src="{{static_url("tree/js/clusterlist.js") }}" type="text/javascript" charset="utf-8"></script>
97 <script src="{{static_url("tree/js/clusterlist.js") }}" type="text/javascript" charset="utf-8"></script>
98 <script src="{{static_url("tree/js/main.js") }}" type="text/javascript" charset="utf-8"></script>
98 <script src="{{static_url("tree/js/main.js") }}" type="text/javascript" charset="utf-8"></script>
99 {% endblock %}
99 {% endblock %}
@@ -1,88 +1,101 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):
32 def generate_breadcrumbs(self, path):
33 breadcrumbs = [(url_escape(url_path_join(self.base_project_url, 'tree')), '')]
33 breadcrumbs = [(url_escape(url_path_join(self.base_project_url, 'tree')), '')]
34 comps = path.split('/')
34 comps = path.split('/')
35 ncomps = len(comps)
35 ncomps = len(comps)
36 for i in range(ncomps):
36 for i in range(ncomps):
37 if comps[i]:
37 if comps[i]:
38 link = url_escape(url_path_join(self.base_project_url, 'tree', *comps[0:i+1]))
38 link = url_escape(url_path_join(self.base_project_url, 'tree', *comps[0:i+1]))
39 breadcrumbs.append((link, comps[i]))
39 breadcrumbs.append((link, comps[i]))
40 return breadcrumbs
40 return breadcrumbs
41
41
42 def generate_page_title(self, path):
43 comps = path.split('/')
44 if len(comps) > 3:
45 for i in range(len(comps)-2):
46 comps.pop(0)
47 comps.insert(0, '...')
48 page_title = url_escape(url_path_join(*comps))
49 if page_title:
50 return '/'+page_title+'/'
51 else:
52 return '/'
53
42 @web.authenticated
54 @web.authenticated
43 def get(self, path='', name=None):
55 def get(self, path='', name=None):
44 path = path.strip('/')
56 path = path.strip('/')
45 nbm = self.notebook_manager
57 nbm = self.notebook_manager
46 if name is not None:
58 if name is not None:
47 # is a notebook, redirect to notebook handler
59 # is a notebook, redirect to notebook handler
48 url = url_escape(url_path_join(
60 url = url_escape(url_path_join(
49 self.base_project_url, 'notebooks', path, name
61 self.base_project_url, 'notebooks', path, name
50 ))
62 ))
51 self.log.debug("Redirecting %s to %s", self.request.path, url)
63 self.log.debug("Redirecting %s to %s", self.request.path, url)
52 self.redirect(url)
64 self.redirect(url)
53 else:
65 else:
54 if not nbm.path_exists(path=path):
66 if not nbm.path_exists(path=path):
55 # no such directory, 404
67 # no such directory, 404
56 raise web.HTTPError(404)
68 raise web.HTTPError(404)
57 breadcrumbs = self.generate_breadcrumbs(path)
69 breadcrumbs = self.generate_breadcrumbs(path)
70 page_title = self.generate_page_title(path)
58 self.write(self.render_template('tree.html',
71 self.write(self.render_template('tree.html',
59 project=self.project_dir,
72 project=self.project_dir,
60 tree_url_path=path,
73 page_title=page_title,
61 notebook_path=path,
74 notebook_path=path,
62 breadcrumbs=breadcrumbs
75 breadcrumbs=breadcrumbs
63 ))
76 ))
64
77
65
78
66 class TreeRedirectHandler(IPythonHandler):
79 class TreeRedirectHandler(IPythonHandler):
67 """Redirect a request to the corresponding tree URL"""
80 """Redirect a request to the corresponding tree URL"""
68
81
69 @web.authenticated
82 @web.authenticated
70 def get(self, path=''):
83 def get(self, path=''):
71 url = url_escape(url_path_join(
84 url = url_escape(url_path_join(
72 self.base_project_url, 'tree', path.strip('/')
85 self.base_project_url, 'tree', path.strip('/')
73 ))
86 ))
74 self.log.debug("Redirecting %s to %s", self.request.path, url)
87 self.log.debug("Redirecting %s to %s", self.request.path, url)
75 self.redirect(url)
88 self.redirect(url)
76
89
77
90
78 #-----------------------------------------------------------------------------
91 #-----------------------------------------------------------------------------
79 # URL to handler mappings
92 # URL to handler mappings
80 #-----------------------------------------------------------------------------
93 #-----------------------------------------------------------------------------
81
94
82
95
83 default_handlers = [
96 default_handlers = [
84 (r"/tree%s" % notebook_path_regex, TreeHandler),
97 (r"/tree%s" % notebook_path_regex, TreeHandler),
85 (r"/tree%s" % path_regex, TreeHandler),
98 (r"/tree%s" % path_regex, TreeHandler),
86 (r"/tree", TreeHandler),
99 (r"/tree", TreeHandler),
87 (r"/", TreeRedirectHandler),
100 (r"/", TreeRedirectHandler),
88 ]
101 ]
General Comments 0
You need to be logged in to leave comments. Login now