##// END OF EJS Templates
manual rebase tree/handlers.py
Zachary Sailer -
Show More
@@ -1,42 +1,85 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
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
24 #-----------------------------------------------------------------------------
25 #-----------------------------------------------------------------------------
25
26
26
27
27 class ProjectDashboardHandler(IPythonHandler):
28 class ProjectDashboardHandler(IPythonHandler):
28
29
29 @web.authenticated
30 @web.authenticated
30 def get(self):
31 def get(self):
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