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