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