diff --git a/IPython/html/notebook/handlers.py b/IPython/html/notebook/handlers.py
index b9c449541..42feea601 100644
--- a/IPython/html/notebook/handlers.py
+++ b/IPython/html/notebook/handlers.py
@@ -100,4 +100,5 @@ _notebook_path_regex = r"(?P.+)"
default_handlers = [
(r"/notebooks/%s" % _notebook_path_regex, NamedNotebookHandler),
(r"/notebooks/", NotebookHandler),
-]
\ No newline at end of file
+]
+
diff --git a/IPython/html/services/notebooks/filenbmanager.py b/IPython/html/services/notebooks/filenbmanager.py
index 07feefcf3..d313d634a 100644
--- a/IPython/html/services/notebooks/filenbmanager.py
+++ b/IPython/html/services/notebooks/filenbmanager.py
@@ -77,8 +77,7 @@ class FileNotebookManager(NotebookManager):
def get_notebook_names(self, path):
"""List all notebook names in the notebook dir."""
- names = glob.glob(os.path.join(self.notebook_dir, path,
- '*' + self.filename_ext))
+ names = glob.glob(self.get_os_path('*'+self.filename_ext, path))
names = [os.path.basename(name)
for name in names]
return names
diff --git a/IPython/html/services/notebooks/handlers.py b/IPython/html/services/notebooks/handlers.py
index b0e5992c9..5658c0c75 100644
--- a/IPython/html/services/notebooks/handlers.py
+++ b/IPython/html/services/notebooks/handlers.py
@@ -190,6 +190,7 @@ default_handlers = [
(r"api/notebooks/%s/checkpoints" % _notebook_path_regex, NotebookCheckpointsHandler),
(r"api/notebooks/%s/checkpoints/%s" % (_notebook_path_regex, _checkpoint_id_regex),
ModifyNotebookCheckpointsHandler),
+ (r"api/notebooks/%s/" % _notebook_path_regex, NotebookHandler),
(r"api/notebooks/%s" % _notebook_path_regex, NotebookHandler),
(r"api/notebooks/", NotebookRootRedirect),
(r"api/notebooks", NotebookRootHandler),
diff --git a/IPython/html/static/notebook/js/menubar.js b/IPython/html/static/notebook/js/menubar.js
index 6dd906e70..39f0f7912 100644
--- a/IPython/html/static/notebook/js/menubar.js
+++ b/IPython/html/static/notebook/js/menubar.js
@@ -52,14 +52,8 @@ var IPython = (function (IPython) {
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 '';
- }
+ path = decodeURIComponent(path);
+ return path
};
MenuBar.prototype.style = function () {
@@ -81,7 +75,7 @@ var IPython = (function (IPython) {
IPython.notebook.new_notebook();
});
this.element.find('#open_notebook').click(function () {
- window.open(that.baseProjectUrl() + 'tree/' + that.notebookPath());
+ window.open(that.baseProjectUrl() + 'tree' + that.notebookPath());
});
this.element.find('#copy_notebook').click(function () {
IPython.notebook.copy_notebook();
@@ -89,13 +83,13 @@ var IPython = (function (IPython) {
});
this.element.find('#download_ipynb').click(function () {
var notebook_name = IPython.notebook.get_notebook_name();
- var url = that.baseProjectUrl() + 'api/notebooks/' + that.notebookPath() +
+ var url = that.baseProjectUrl() + 'api/notebooks' + that.notebookPath() +
notebook_name + '?format=json'+ '&download=True';
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/' + that.notebookPath() +
+ var url = that.baseProjectUrl() + 'api/notebooks' + that.notebookPath() +
notebook_name + '?format=py' + '&download=True';
window.location.assign(url);
});
diff --git a/IPython/html/static/tree/js/notebooklist.js b/IPython/html/static/tree/js/notebooklist.js
index ff498cc60..464a0870c 100644
--- a/IPython/html/static/tree/js/notebooklist.js
+++ b/IPython/html/static/tree/js/notebooklist.js
@@ -29,14 +29,7 @@ var IPython = (function (IPython) {
NotebookList.prototype.notebookPath = function() {
var path = $('body').data('notebookPath');
path = decodeURIComponent(path);
- if (path != "") {
- if (path[path.length-1] != '/') {
- path = path.substring(0,path.length);
- };
- return path;
- } else {
- return path;
- };
+ return path;
};
NotebookList.prototype.url_name = function(name){
@@ -147,7 +140,7 @@ var IPython = (function (IPython) {
},this)
};
- var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebookPath();
+ var url = this.baseProjectUrl() + 'api/notebooks' + this.notebookPath();
$.ajax(url, settings);
};
@@ -209,7 +202,7 @@ var IPython = (function (IPython) {
item.data('path', path);
item.find(".item_name").text(nbname);
item.find("a.item_link")
- .attr('href', this.baseProjectUrl() + "notebooks/" + this.notebookPath() + nbname + ".ipynb")
+ .attr('href', this.baseProjectUrl() + "notebooks" + this.notebookPath() + nbname + ".ipynb")
.attr('target','_blank');
};
@@ -280,7 +273,7 @@ var IPython = (function (IPython) {
parent_item.remove();
}
};
- var url = notebooklist.baseProjectUrl() + 'api/notebooks/' + notebooklist.notebookPath() + nbname + '.ipynb';
+ var url = notebooklist.baseProjectUrl() + 'api/notebooks' + notebooklist.notebookPath() + nbname + '.ipynb';
$.ajax(url, settings);
}
},
@@ -347,10 +340,10 @@ var IPython = (function (IPython) {
dataType : "json",
success:$.proxy(function (data, status, xhr){
notebook_name = data.name;
- window.open(this.baseProjectUrl() +'notebooks/' + this.notebookPath()+ notebook_name);
+ window.open(this.baseProjectUrl() +'notebooks' + this.notebookPath()+ notebook_name, '_blank');
}, this)
};
- var url = this.baseProjectUrl() + 'notebooks/' + path;
+ var url = this.baseProjectUrl() + 'notebooks' + path;
$.ajax(url,settings);
};
diff --git a/IPython/html/tree/handlers.py b/IPython/html/tree/handlers.py
index 2d41dcac7..d0451bb70 100644
--- a/IPython/html/tree/handlers.py
+++ b/IPython/html/tree/handlers.py
@@ -31,7 +31,7 @@ class ProjectDashboardHandler(IPythonHandler):
self.write(self.render_template('tree.html',
project=self.project,
project_component=self.project.split('/'),
- notebook_path= "''"
+ notebook_path= "/"
))
@@ -41,7 +41,7 @@ class ProjectPathDashboardHandler(IPythonHandler):
def get(self, notebook_path):
nbm = self.notebook_manager
name, path = nbm.named_notebook_path(notebook_path)
- if name != None:
+ if name is not None:
# ends with .ipynb
self.redirect(self.base_project_url + 'notebooks' + path + name)
else:
@@ -49,7 +49,7 @@ class ProjectPathDashboardHandler(IPythonHandler):
path = nbm.url_encode(path)
self.write(self.render_template('tree.html',
project=project,
- project_component=project.split('/'),
+ project_component=project.split('/')[:-1],
notebook_path=path,
notebook_name=name))
@@ -65,7 +65,7 @@ class TreePathRedirectHandler(IPythonHandler):
@web.authenticated
def get(self, notebook_path):
- url = self.base_project_url + 'tree/'+ notebook_path
+ url = self.base_project_url + 'tree/'+ notebook_path+'/'
self.redirect(url)
class ProjectRedirectHandler(IPythonHandler):
@@ -84,8 +84,8 @@ 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/%s/" % _notebook_path_regex, ProjectPathDashboardHandler),
+ (r"/tree/%s" % _notebook_path_regex, TreePathRedirectHandler),
(r"/tree", ProjectDashboardHandler),
(r"/tree/", TreeRedirectHandler),
(r"/", ProjectRedirectHandler)