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