Show More
@@ -81,6 +81,12 b' class NotebookManager(LoggingConfigurable):' | |||||
81 |
|
81 | |||
82 | allowed_formats = List([u'json',u'py']) |
|
82 | allowed_formats = List([u'json',u'py']) | |
83 |
|
83 | |||
|
84 | def add_new_folder(self, path=None): | |||
|
85 | new_path = os.path.join(self.notebook_dir, path) | |||
|
86 | if not os.path.exists(new_path): | |||
|
87 | os.makedirs(new_path) | |||
|
88 | else: | |||
|
89 | raise web.HTTPError(409, u'Directory already exists or creation permission not allowed.') | |||
84 |
|
90 | |||
85 | def load_notebook_names(self, path): |
|
91 | def load_notebook_names(self, path): | |
86 | """Load the notebook names into memory. |
|
92 | """Load the notebook names into memory. |
@@ -77,6 +77,17 b' class ProjectRedirectHandler(IPythonHandler):' | |||||
77 | url = self.base_project_url + 'tree' |
|
77 | url = self.base_project_url + 'tree' | |
78 | self.redirect(url) |
|
78 | self.redirect(url) | |
79 |
|
79 | |||
|
80 | class NewFolderHandler(IPythonHandler): | |||
|
81 | ||||
|
82 | @authenticate_unless_readonly | |||
|
83 | def get(self, notebook_path): | |||
|
84 | nbm = self.notebook_manager | |||
|
85 | name, path = nbm.named_notebook_path(notebook_path) | |||
|
86 | nbm.add_new_folder(path) | |||
|
87 | url = self.base_project_url + 'tree/' + notebook_path | |||
|
88 | self.redirect(url) | |||
|
89 | ||||
|
90 | ||||
80 | #----------------------------------------------------------------------------- |
|
91 | #----------------------------------------------------------------------------- | |
81 | # URL to handler mappings |
|
92 | # URL to handler mappings | |
82 | #----------------------------------------------------------------------------- |
|
93 | #----------------------------------------------------------------------------- | |
@@ -85,6 +96,7 b' class ProjectRedirectHandler(IPythonHandler):' | |||||
85 | _notebook_path_regex = r"(?P<notebook_path>.+)" |
|
96 | _notebook_path_regex = r"(?P<notebook_path>.+)" | |
86 |
|
97 | |||
87 | default_handlers = [ |
|
98 | default_handlers = [ | |
|
99 | (r"/tree/%s/-new" %_notebook_path_regex, NewFolderHandler), | |||
88 | (r"/tree/%s/" % _notebook_path_regex, TreePathRedirectHandler), |
|
100 | (r"/tree/%s/" % _notebook_path_regex, TreePathRedirectHandler), | |
89 | (r"/tree/%s" % _notebook_path_regex, ProjectPathDashboardHandler), |
|
101 | (r"/tree/%s" % _notebook_path_regex, ProjectPathDashboardHandler), | |
90 | (r"/tree", ProjectDashboardHandler), |
|
102 | (r"/tree", ProjectDashboardHandler), |
General Comments 0
You need to be logged in to leave comments.
Login now