##// END OF EJS Templates
allow spaces in notebook path
Zachary Sailer -
Show More
@@ -58,7 +58,9 b' class NamedNotebookHandler(IPythonHandler):'
58 58 else:
59 59 project = self.project + '/' + path +'/'+ name
60 60 if not nbm.notebook_exists(notebook_path):
61 raise web.HTTPError(404, u'Notebook does not exist: %s' % name)
61 raise web.HTTPError(404, u'Notebook does not exist: %s' % name)
62 path = nbm.url_encode(path)
63 name = nbm.url_encode(name)
62 64 self.write(self.render_template('notebook.html',
63 65 project=project,
64 66 notebook_path=path,
@@ -45,8 +45,8 b' class NotebookRootHandler(IPythonHandler):'
45 45 model = nbm.notebook_model(notebook_name)
46 46 self.set_header('Location', '{0}api/notebooks/{1}'.format(self.base_project_url, notebook_name))
47 47 self.finish(jsonapi.dumps(model))
48
49
48
49
50 50 class NotebookRootRedirect(IPythonHandler):
51 51
52 52 @authenticate_unless_readonly
@@ -20,6 +20,7 b' import os'
20 20 import uuid
21 21
22 22 from tornado import web
23 from urllib import quote, unquote
23 24
24 25 from IPython.config.configurable import LoggingConfigurable
25 26 from IPython.nbformat import current
@@ -62,7 +63,23 b' class NotebookManager(LoggingConfigurable):'
62 63 name = None
63 64 path = notebook_path+'/'
64 65 return name, path
65
66
67 def url_encode(self, path):
68 parts = path.split('/')
69 path=""
70 for part in parts:
71 part = quote(part)
72 path = os.path.join(path,part)
73 return path
74
75 def url_decode(self, path):
76 parts = path.split('/')
77 path=""
78 for part in parts:
79 part = unquote(part)
80 path = os.path.join(path,part)
81 return path
82
66 83 def _notebook_dir_changed(self, new):
67 84 """do a bit of validation of the notebook dir"""
68 85 if not os.path.isabs(new):
@@ -114,7 +131,7 b' class NotebookManager(LoggingConfigurable):'
114 131 def notebook_exists(self, notebook_path):
115 132 """Does a notebook exist?"""
116 133
117
134
118 135 def notebook_model(self, notebook_name, notebook_path=None, content=True):
119 136 """ Creates the standard notebook model """
120 137 last_modified, contents = self.read_notebook_object(notebook_name, notebook_path)
@@ -78,6 +78,11 b' var IPython = (function (IPython) {'
78 78 return this._baseProjectUrl || $('body').data('baseProjectUrl');
79 79 };
80 80
81 Notebook.prototype.notebookName = function() {
82 var name = $('body').data('notebookName');
83 return name;
84 };
85
81 86 Notebook.prototype.notebookPath = function() {
82 87 var path = $('body').data('notebookPath');
83 88 if (path != 'None') {
@@ -47,6 +47,8 b' var IPython = (function (IPython) {'
47 47 that.update_document_title();
48 48 });
49 49 $([IPython.events]).on('notebook_renamed.Notebook', function () {
50 that.update_notebook_name();
51 that.update_document_title();
50 52 that.update_address_bar();
51 53 });
52 54 $([IPython.events]).on('notebook_save_failed.Notebook', function () {
@@ -126,7 +128,8 b' var IPython = (function (IPython) {'
126 128 SaveWidget.prototype.update_address_bar = function(){
127 129 var nbname = IPython.notebook.notebook_name;
128 130 var path = IPython.notebook.notebookPath();
129 window.location = path + nbname;
131 var state = {"path": path+nbname}
132 window.history.pushState(state, "", "/notebook/" + path+nbname);
130 133 }
131 134
132 135
@@ -25,7 +25,7 b' var IPython = (function (IPython) {'
25 25 NotebookList.prototype.baseProjectUrl = function () {
26 26 return $('body').data('baseProjectUrl');
27 27 };
28
28
29 29 NotebookList.prototype.notebookPath = function() {
30 30 var path = $('body').data('notebookPath');
31 31 if (path != "") {
@@ -43,11 +43,9 b' class ProjectPathDashboardHandler(IPythonHandler):'
43 43 nbm = self.notebook_manager
44 44 name, path = nbm.named_notebook_path(notebook_path)
45 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))
46 self.redirect(self.base_project_url + 'notebooks/' + notebook_path)
50 47 else:
48 path = nbm.url_encode(path)
51 49 project = self.project + '/' + notebook_path
52 50 self.write(self.render_template('tree.html',
53 51 project=project,
General Comments 0
You need to be logged in to leave comments. Login now