Show More
@@ -18,6 +18,7 b' Authors:' | |||||
18 |
|
18 | |||
19 | from tornado import web |
|
19 | from tornado import web | |
20 | from ..base.handlers import IPythonHandler |
|
20 | from ..base.handlers import IPythonHandler | |
|
21 | from urllib import quote, unquote | |||
21 |
|
22 | |||
22 | #----------------------------------------------------------------------------- |
|
23 | #----------------------------------------------------------------------------- | |
23 | # Handlers |
|
24 | # Handlers | |
@@ -31,12 +32,54 b' class ProjectDashboardHandler(IPythonHandler):' | |||||
31 | self.write(self.render_template('tree.html', |
|
32 | self.write(self.render_template('tree.html', | |
32 | project=self.project, |
|
33 | project=self.project, | |
33 | project_component=self.project.split('/'), |
|
34 | project_component=self.project.split('/'), | |
|
35 | notebook_path= "''" | |||
34 | )) |
|
36 | )) | |
35 |
|
37 | |||
36 |
|
38 | |||
|
39 | class ProjectPathDashboardHandler(IPythonHandler): | |||
|
40 | ||||
|
41 | @authenticate_unless_readonly | |||
|
42 | def get(self, notebook_path): | |||
|
43 | nbm = self.notebook_manager | |||
|
44 | name, path = nbm.named_notebook_path(notebook_path) | |||
|
45 | if name != None: | |||
|
46 | if path == None: | |||
|
47 | self.redirect(self.base_project_url + 'notebooks/' + quote(name)) | |||
|
48 | else: | |||
|
49 | self.redirect(self.base_project_url + 'notebooks/' + path + quote(name)) | |||
|
50 | else: | |||
|
51 | project = self.project + '/' + notebook_path | |||
|
52 | self.write(self.render_template('tree.html', | |||
|
53 | project=project, | |||
|
54 | project_component=project.split('/'), | |||
|
55 | notebook_path=path, | |||
|
56 | notebook_name=name)) | |||
|
57 | ||||
|
58 | ||||
|
59 | class TreeRedirectHandler(IPythonHandler): | |||
|
60 | ||||
|
61 | @authenticate_unless_readonly | |||
|
62 | def get(self): | |||
|
63 | url = self.base_project_url + 'tree' | |||
|
64 | self.redirect(url) | |||
|
65 | ||||
|
66 | class ProjectRedirectHandler(IPythonHandler): | |||
|
67 | ||||
|
68 | @authenticate_unless_readonly | |||
|
69 | def get(self): | |||
|
70 | url = self.base_project_url + 'tree' | |||
|
71 | self.redirect(url) | |||
|
72 | ||||
37 | #----------------------------------------------------------------------------- |
|
73 | #----------------------------------------------------------------------------- | |
38 | # URL to handler mappings |
|
74 | # URL to handler mappings | |
39 | #----------------------------------------------------------------------------- |
|
75 | #----------------------------------------------------------------------------- | |
40 |
|
76 | |||
41 |
|
77 | |||
42 | default_handlers = [(r"/", ProjectDashboardHandler)] No newline at end of file |
|
78 | _notebook_path_regex = r"(?P<notebook_path>.+)" | |
|
79 | ||||
|
80 | default_handlers = [ | |||
|
81 | (r"/tree/%s" % _notebook_path_regex, ProjectPathDashboardHandler), | |||
|
82 | (r"/tree", ProjectDashboardHandler), | |||
|
83 | (r"/tree/", TreeRedirectHandler), | |||
|
84 | (r"/", ProjectRedirectHandler) | |||
|
85 | ] |
General Comments 0
You need to be logged in to leave comments.
Login now