diff --git a/IPython/html/services/notebooks/handlers.py b/IPython/html/services/notebooks/handlers.py
index ce3cffb..95fb3fa 100644
--- a/IPython/html/services/notebooks/handlers.py
+++ b/IPython/html/services/notebooks/handlers.py
@@ -100,7 +100,7 @@ class NotebookHandler(IPythonHandler):
notebook_name = nbm.save_new_notebook(body, notebook_path=notebook_path, name=name, format=format)
else:
notebook_name = nbm.new_notebook(notebook_path=notebook_path)
- if path==None:
+ if notebook_path==None:
self.set_header('Location', nbm.notebook_dir + '/'+ notebook_name)
else:
self.set_header('Location', nbm.notebook_dir + '/'+ notebook_path + '/' + notebook_name)
diff --git a/IPython/html/static/notebook/js/menubar.js b/IPython/html/static/notebook/js/menubar.js
index ea1fc27..e1b2e99 100644
--- a/IPython/html/static/notebook/js/menubar.js
+++ b/IPython/html/static/notebook/js/menubar.js
@@ -50,8 +50,16 @@ var IPython = (function (IPython) {
return this._baseProjectUrl || $('body').data('baseProjectUrl');
};
- MenuBar.prototype.notebookPath = function(){
- return this._notebookPath || $('body').data('notebookPath');
+ MenuBar.prototype.notebookPath = function() {
+ var path = $('body').data('notebookPath');
+ if (path != 'None') {
+ if (path[path.length-1] != '/') {
+ path = path.substring(0,path.length);
+ };
+ return path;
+ } else {
+ return '';
+ }
};
MenuBar.prototype.style = function () {
@@ -69,60 +77,30 @@ var IPython = (function (IPython) {
MenuBar.prototype.bind_events = function () {
// File
var that = this;
- if (this.notebookPath() != 'None') {
- this.element.find('#new_notebook').click(function () {
- window.open(that.baseProjectUrl() + 'notebooks/' + that.notebookPath() +'/new');
- });
- this.element.find('#open_notebook').click(function () {
- window.open(that.baseProjectUrl() + 'tree/' + that.notebookPath());
- });
- this.element.find('#copy_notebook').click(function () {
- var notebook_name = IPython.notebook.get_notebook_name();
- var url = that.baseProjectUrl() + 'notebooks/' + that.notebookPath() + '/'+ notebook_name + '/copy';
- window.open(url,'_blank');
- return false;
- });
- this.element.find('#download_ipynb').click(function () {
- var notebook_name = IPython.notebook.get_notebook_name();
- var url = that.baseProjectUrl() + 'api/notebooks/' +
- notebook_name + '?format=json';
- window.location.assign(url);
- });
- this.element.find('#download_py').click(function () {
- var notebook_name = IPython.notebook.get_notebook_name();
- var url = that.baseProjectUrl() + 'api/notebooks/' +
- notebook_name + '?format=py';
- window.location.assign(url);
- });
- }
- else {
- this.element.find('#new_notebook').click(function () {
- window.open(that.baseProjectUrl()+'notebooks/new');
- });
- this.element.find('#open_notebook').click(function () {
- window.open(that.baseProjectUrl() + 'tree');
- });
- this.element.find('#copy_notebook').click(function () {
- var notebook_name = IPython.notebook.get_notebook_name();
- var url = that.baseProjectUrl() + 'notebooks/' + notebook_name + '/copy';
- window.open(url,'_blank');
- return false;
- });
- this.element.find('#download_ipynb').click(function () {
- var notebook_name = IPython.notebook.get_notebook_name();
- var url = that.baseProjectUrl() + 'api/notebooks/' +
- notebook_name + '?format=json';
- window.location.assign(url);
- });
- this.element.find('#download_py').click(function () {
- var notebook_name = IPython.notebook.get_notebook_name();
- var url = that.baseProjectUrl() + 'api/notebooks/' +
- notebook_name + '?format=py';
- window.location.assign(url);
- });
-
-
- }
+ this.element.find('#new_notebook').click(function () {
+ window.open(that.baseProjectUrl() + 'notebooks/' + that.notebookPath() +'new');
+ });
+ this.element.find('#open_notebook').click(function () {
+ window.open(that.baseProjectUrl() + 'tree/' + that.notebookPath());
+ });
+ this.element.find('#copy_notebook').click(function () {
+ var notebook_name = IPython.notebook.get_notebook_name();
+ var url = that.baseProjectUrl() + 'notebooks/' + that.notebookPath() + notebook_name + '/copy';
+ window.open(url,'_blank');
+ return false;
+ });
+ this.element.find('#download_ipynb').click(function () {
+ var notebook_name = IPython.notebook.get_notebook_name();
+ var url = that.baseProjectUrl() + 'api/notebooks/' +
+ notebook_name + '?format=json';
+ window.location.assign(url);
+ });
+ this.element.find('#download_py').click(function () {
+ var notebook_name = IPython.notebook.get_notebook_name();
+ var url = that.baseProjectUrl() + 'api/notebooks/' +
+ notebook_name + '?format=py';
+ window.location.assign(url);
+ });
this.element.find('#rename_notebook').click(function () {
IPython.save_widget.rename_notebook();
});
diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js
index 068098e..a8261b4 100644
--- a/IPython/html/static/notebook/js/notebook.js
+++ b/IPython/html/static/notebook/js/notebook.js
@@ -1391,7 +1391,6 @@ var IPython = (function (IPython) {
*/
Notebook.prototype.start_session = function () {
var notebook_info = this.notebookPath() + this.notebook_name;
- console.log(notebook_info)
this.session = new IPython.Session(notebook_info, this);
this.session.start();
};
@@ -1654,12 +1653,7 @@ var IPython = (function (IPython) {
error : $.proxy(this.save_notebook_error, this)
};
$([IPython.events]).trigger('notebook_saving.Notebook');
- if (this.notebook_path != "") {
- var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebook_path+ this.notebook_name;
- }
- else {
- var url = this.baseProjectUrl() + 'api/notebooks/' +this.notebook_name;
- }
+ var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebookPath()+ this.notebook_name;
$.ajax(url, settings);
};
@@ -1734,7 +1728,7 @@ var IPython = (function (IPython) {
error : $.proxy(this.load_notebook_error,this),
};
$([IPython.events]).trigger('notebook_loading.Notebook');
- var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebook_path + this.notebook_name;
+ var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebookPath() + this.notebook_name;
$.ajax(url, settings);
};
@@ -1867,12 +1861,7 @@ var IPython = (function (IPython) {
* @method list_checkpoints
*/
Notebook.prototype.list_checkpoints = function () {
- if (this.notebook_path != "") {
- var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebook_path+ this.notebook_name + '/checkpoints';
- }
- else {
- var url = this.baseProjectUrl() + 'api/notebooks/' +this.notebook_name + '/checkpoints';
- }
+ var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebookPath() + this.notebook_name + '/checkpoints';
$.get(url).done(
$.proxy(this.list_checkpoints_success, this)
).fail(
@@ -1917,12 +1906,7 @@ var IPython = (function (IPython) {
* @method create_checkpoint
*/
Notebook.prototype.create_checkpoint = function () {
- if (this.notebook_path != "") {
- var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebook_path + this.notebook_name + '/checkpoints';
- }
- else {
- var url = this.baseProjectUrl() + 'api/notebooks/' +this.notebook_name + '/checkpoints';
- }
+ var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebookPath() + this.notebook_name + '/checkpoints';
$.post(url).done(
$.proxy(this.create_checkpoint_success, this)
).fail(
@@ -2002,6 +1986,7 @@ var IPython = (function (IPython) {
* @param {String} checkpoint ID
*/
Notebook.prototype.restore_checkpoint = function (checkpoint) {
+<<<<<<< HEAD
$([IPython.events]).trigger('checkpoint_restoring.Notebook', checkpoint);
if (this.notebook_path != "") {
var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebook_path + this.notebook_name + '/checkpoints/' + checkpoint;
@@ -2009,6 +1994,10 @@ var IPython = (function (IPython) {
else {
var url = this.baseProjectUrl() + 'api/notebooks/' +this.notebook_name + '/checkpoints/' + checkpoint;
}
+=======
+ $([IPython.events]).trigger('notebook_restoring.Notebook', checkpoint);
+ var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebookPath() + this.notebook_name + '/checkpoints/' + checkpoint;
+>>>>>>> fixing path redirects, cleaning path logic
$.post(url).done(
$.proxy(this.restore_checkpoint_success, this)
).fail(
@@ -2048,13 +2037,8 @@ var IPython = (function (IPython) {
* @param {String} checkpoint ID
*/
Notebook.prototype.delete_checkpoint = function (checkpoint) {
- $([IPython.events]).trigger('checkpoint_restoring.Notebook', checkpoint);
- if (this.notebook_path != "") {
- var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebook_path + this.notebook_name + '/checkpoints/' + checkpoint;
- }
- else {
- var url = this.baseProjectUrl() + 'api/notebooks/' +this.notebook_name + '/checkpoints/' + checkpoint;
- }
+ $([IPython.events]).trigger('notebook_restoring.Notebook', checkpoint);
+ var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebookPath() + this.notebook_name + '/checkpoints/' + checkpoint;
$.ajax(url, {
type: 'DELETE',
success: $.proxy(this.delete_checkpoint_success, this),
diff --git a/IPython/html/tree/handlers.py b/IPython/html/tree/handlers.py
index 2fd67a6..0d7b8c2 100644
--- a/IPython/html/tree/handlers.py
+++ b/IPython/html/tree/handlers.py
@@ -63,6 +63,13 @@ class TreeRedirectHandler(IPythonHandler):
url = self.base_project_url + 'tree'
self.redirect(url)
+class TreePathRedirectHandler(IPythonHandler):
+
+ @authenticate_unless_readonly
+ def get(self, notebook_path):
+ url = self.base_project_url + 'tree/'+ notebook_path
+ self.redirect(url)
+
class ProjectRedirectHandler(IPythonHandler):
@authenticate_unless_readonly
@@ -78,6 +85,7 @@ class ProjectRedirectHandler(IPythonHandler):
_notebook_path_regex = r"(?P.+)"
default_handlers = [
+ (r"/tree/%s/" % _notebook_path_regex, TreePathRedirectHandler),
(r"/tree/%s" % _notebook_path_regex, ProjectPathDashboardHandler),
(r"/tree", ProjectDashboardHandler),
(r"/tree/", TreeRedirectHandler),