Show More
@@ -222,7 +222,7 b' class IPythonHandler(AuthenticatedHandler):' | |||||
222 | return self.settings['session_manager'] |
|
222 | return self.settings['session_manager'] | |
223 |
|
223 | |||
224 | @property |
|
224 | @property | |
225 | def project(self): |
|
225 | def project_dir(self): | |
226 | return self.notebook_manager.notebook_dir |
|
226 | return self.notebook_manager.notebook_dir | |
227 |
|
227 | |||
228 | #--------------------------------------------------------------- |
|
228 | #--------------------------------------------------------------- |
@@ -13,7 +13,6 b'' | |||||
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-notebook-name={{notebook_name}} |
|
|||
17 | data-base-kernel-url={{base_kernel_url}} |
|
16 | data-base-kernel-url={{base_kernel_url}} | |
18 |
|
17 | |||
19 | {% endblock %} |
|
18 | {% endblock %} | |
@@ -48,7 +47,7 b' data-base-kernel-url={{base_kernel_url}}' | |||||
48 | <div id="notebook_list_header" class="row-fluid list_header"> |
|
47 | <div id="notebook_list_header" class="row-fluid list_header"> | |
49 | <div id="project_name"> |
|
48 | <div id="project_name"> | |
50 | <ul class="breadcrumb"> |
|
49 | <ul class="breadcrumb"> | |
51 |
{% for component in |
|
50 | {% for component in tree_url_path.strip('/').split('/') %} | |
52 | <li>{{component}} <span>/</span></li> |
|
51 | <li>{{component}} <span>/</span></li> | |
53 | {% endfor %} |
|
52 | {% endfor %} | |
54 | </ul> |
|
53 | </ul> |
@@ -15,64 +15,49 b' Authors:' | |||||
15 | #----------------------------------------------------------------------------- |
|
15 | #----------------------------------------------------------------------------- | |
16 | # Imports |
|
16 | # Imports | |
17 | #----------------------------------------------------------------------------- |
|
17 | #----------------------------------------------------------------------------- | |
|
18 | import os | |||
18 |
|
19 | |||
19 | from tornado import web |
|
20 | from tornado import web | |
20 | from ..base.handlers import IPythonHandler |
|
21 | from ..base.handlers import IPythonHandler | |
|
22 | from ..utils import url_path_join, path2url, url2path | |||
21 |
|
23 | |||
22 | #----------------------------------------------------------------------------- |
|
24 | #----------------------------------------------------------------------------- | |
23 | # Handlers |
|
25 | # Handlers | |
24 | #----------------------------------------------------------------------------- |
|
26 | #----------------------------------------------------------------------------- | |
25 |
|
27 | |||
26 |
|
28 | |||
27 |
class |
|
29 | class TreeHandler(IPythonHandler): | |
|
30 | """Render the tree view, listing notebooks, clusters, etc.""" | |||
28 |
|
31 | |||
29 | @web.authenticated |
|
32 | @web.authenticated | |
30 | def get(self): |
|
33 | def get(self, notebook_path=""): | |
31 | self.write(self.render_template('tree.html', |
|
|||
32 | project=self.project, |
|
|||
33 | project_component=self.project.split('/'), |
|
|||
34 | notebook_path= "/" |
|
|||
35 | )) |
|
|||
36 |
|
||||
37 |
|
||||
38 | class ProjectPathDashboardHandler(IPythonHandler): |
|
|||
39 |
|
||||
40 | @web.authenticated |
|
|||
41 | def get(self, notebook_path): |
|
|||
42 | nbm = self.notebook_manager |
|
34 | nbm = self.notebook_manager | |
43 | name, path = nbm.named_notebook_path(notebook_path) |
|
35 | name, path = nbm.named_notebook_path(notebook_path) | |
44 | if name is not None: |
|
36 | if name is not None: | |
45 | # ends with .ipynb |
|
37 | # is a notebook, redirect to notebook handler | |
46 |
|
|
38 | url = url_path_join(self.base_project_url, 'notebooks', path, name) | |
|
39 | self.redirect(url) | |||
47 | else: |
|
40 | else: | |
48 | project = self.project + path |
|
41 | location = nbm.get_os_path(path=path) | |
49 | path = nbm.url_encode(path) |
|
42 | ||
|
43 | if not os.path.exists(location): | |||
|
44 | # no such directory, 404 | |||
|
45 | raise web.HTTPError(404) | |||
|
46 | ||||
50 | self.write(self.render_template('tree.html', |
|
47 | self.write(self.render_template('tree.html', | |
51 | project=project, |
|
48 | project=self.project_dir, | |
52 | project_component=project.split('/')[:-1], |
|
49 | tree_url_path=path2url(location), | |
53 | notebook_path=path, |
|
50 | notebook_path=path, | |
54 | notebook_name=name)) |
|
51 | )) | |
55 |
|
52 | |||
56 |
|
53 | |||
57 | class TreeRedirectHandler(IPythonHandler): |
|
54 | class TreeRedirectHandler(IPythonHandler): | |
58 |
|
55 | """Redirect a request to the corresponding tree URL""" | ||
59 | @web.authenticated |
|
|||
60 | def get(self): |
|
|||
61 | url = self.base_project_url + 'tree' |
|
|||
62 | self.redirect(url) |
|
|||
63 |
|
||||
64 | class TreePathRedirectHandler(IPythonHandler): |
|
|||
65 |
|
||||
66 | @web.authenticated |
|
|||
67 | def get(self, notebook_path): |
|
|||
68 | url = self.base_project_url + 'tree/'+ notebook_path+'/' |
|
|||
69 | self.redirect(url) |
|
|||
70 |
|
56 | |||
71 | class ProjectRedirectHandler(IPythonHandler): |
|
|||
72 |
|
||||
73 | @web.authenticated |
|
57 | @web.authenticated | |
74 | def get(self): |
|
58 | def get(self, notebook_path=''): | |
75 |
url = self.base_project_url |
|
59 | url = url_path_join(self.base_project_url, 'tree', notebook_path) | |
|
60 | self.log.debug("Redirecting %s to %s", self.request.uri, url) | |||
76 | self.redirect(url) |
|
61 | self.redirect(url) | |
77 |
|
62 | |||
78 |
|
63 | |||
@@ -84,9 +69,9 b' class ProjectRedirectHandler(IPythonHandler):' | |||||
84 | _notebook_path_regex = r"(?P<notebook_path>.+)" |
|
69 | _notebook_path_regex = r"(?P<notebook_path>.+)" | |
85 |
|
70 | |||
86 | default_handlers = [ |
|
71 | default_handlers = [ | |
87 |
(r"/tree/%s/" % _notebook_path_regex, |
|
72 | (r"/tree/%s/" % _notebook_path_regex, TreeRedirectHandler), | |
88 |
(r"/tree/%s" % _notebook_path_regex, Tree |
|
73 | (r"/tree/%s" % _notebook_path_regex, TreeHandler), | |
89 | (r"/tree", ProjectDashboardHandler), |
|
|||
90 | (r"/tree/", TreeRedirectHandler), |
|
74 | (r"/tree/", TreeRedirectHandler), | |
91 |
(r"/", |
|
75 | (r"/tree", TreeHandler), | |
|
76 | (r"/", TreeRedirectHandler), | |||
92 | ] |
|
77 | ] |
General Comments 0
You need to be logged in to leave comments.
Login now