diff --git a/IPython/frontend/html/notebook/handlers.py b/IPython/frontend/html/notebook/handlers.py index 55e4ccc..9d50415 100644 --- a/IPython/frontend/html/notebook/handlers.py +++ b/IPython/frontend/html/notebook/handlers.py @@ -123,6 +123,14 @@ def authenticate_unless_readonly(f, self, *args, **kwargs): else: return auth_f(self, *args, **kwargs) +def urljoin(*pieces): + """Join componenet of url into a relative url + + Use to prevent double slash when joining subpath + """ + striped = [s.strip('/') for s in pieces] + return '/'.join(s for s in striped if s) + #----------------------------------------------------------------------------- # Top-level handlers #----------------------------------------------------------------------------- @@ -267,17 +275,7 @@ class NewHandler(AuthenticatedHandler): nbm = self.application.notebook_manager project = nbm.notebook_dir notebook_id = nbm.new_notebook() - self.render( - 'notebook.html', project=project, - notebook_id=notebook_id, - base_project_url=self.application.ipython_app.base_project_url, - base_kernel_url=self.application.ipython_app.base_kernel_url, - kill_kernel=False, - read_only=False, - logged_in=self.logged_in, - login_available=self.login_available, - mathjax_url=self.application.ipython_app.mathjax_url, - ) + self.redirect('/'+urljoin(self.application.ipython_app.base_project_url, notebook_id)) class NamedNotebookHandler(AuthenticatedHandler): @@ -663,17 +661,7 @@ class NotebookCopyHandler(AuthenticatedHandler): nbm = self.application.notebook_manager project = nbm.notebook_dir notebook_id = nbm.copy_notebook(notebook_id) - self.render( - 'notebook.html', project=project, - notebook_id=notebook_id, - base_project_url=self.application.ipython_app.base_project_url, - base_kernel_url=self.application.ipython_app.base_kernel_url, - kill_kernel=False, - read_only=False, - logged_in=self.logged_in, - login_available=self.login_available, - mathjax_url=self.application.ipython_app.mathjax_url, - ) + self.redirect('/'+urljoin(self.application.ipython_app.base_project_url, notebook_id)) #----------------------------------------------------------------------------- diff --git a/IPython/frontend/html/notebook/static/js/notebookmain.js b/IPython/frontend/html/notebook/static/js/notebookmain.js index 27a1f21..7975900 100644 --- a/IPython/frontend/html/notebook/static/js/notebookmain.js +++ b/IPython/frontend/html/notebook/static/js/notebookmain.js @@ -60,7 +60,6 @@ $(document).ready(function () { IPython.layout_manager.do_resize(); $([IPython.events]).on('notebook_loaded.Notebook', function () { IPython.layout_manager.do_resize(); - IPython.save_widget.update_url(); }) IPython.notebook.load_notebook($('body').data('notebookId')); diff --git a/IPython/frontend/html/notebook/static/js/savewidget.js b/IPython/frontend/html/notebook/static/js/savewidget.js index 10fdfb4..7b3b058 100644 --- a/IPython/frontend/html/notebook/static/js/savewidget.js +++ b/IPython/frontend/html/notebook/static/js/savewidget.js @@ -120,15 +120,6 @@ var IPython = (function (IPython) { }; - SaveWidget.prototype.update_url = function () { - var notebook_id = IPython.notebook.get_notebook_id(); - if (notebook_id !== null) { - var new_url = $('body').data('baseProjectUrl') + notebook_id; - window.history.replaceState({}, '', new_url); - }; - }; - - SaveWidget.prototype.set_save_status = function (msg) { this.element.find('span#save_status').html(msg); }