diff --git a/IPython/html/static/base/js/contentmanager.js b/IPython/html/static/base/js/contentmanager.js
index 8211e4b..e993af2 100644
--- a/IPython/html/static/base/js/contentmanager.js
+++ b/IPython/html/static/base/js/contentmanager.js
@@ -25,6 +25,10 @@ define([
};
/**
+ * Notebook Functions
+ */
+
+ /**
* Creates a new notebook file at the specified path, and
* opens that notebook in a new window.
*
@@ -165,6 +169,10 @@ define([
$.ajax(url, settings);
};
+ /**
+ * Checkpointing Functions
+ */
+
ContentManager.prototype.save_checkpoint = function() {
// This is not necessary - integrated into save
};
@@ -203,6 +211,44 @@ define([
);
};
+ /**
+ * File management functions
+ */
+
+ /**
+ * List notebooks and directories at a given path
+ *
+ * On success, load_callback is called with an array of dictionaries
+ * representing individual files or directories. Each dictionary has
+ * the keys:
+ * type: "notebook" or "directory"
+ * name: the name of the file or directory
+ * created: created date
+ * last_modified: last modified dat
+ * path: the path
+ * @method list_notebooks
+ * @param {String} path The path to list notebooks in
+ * @param {Function} load_callback called with list of notebooks on success
+ * @param {Function} error_callback called with ajax results on error
+ */
+ ContentManager.prototype.list_contents = function(path, load_callback,
+ error_callback) {
+ var that = this;
+ var settings = {
+ processData : false,
+ cache : false,
+ type : "GET",
+ dataType : "json",
+ success : load_callback,
+ error : error_callback
+ };
+
+ var url = utils.url_join_encode(this.base_url, 'api', 'notebooks',
+ path);
+ $.ajax(url, settings);
+ }
+
+
IPython.ContentManager = ContentManager;
return {'ContentManager': ContentManager};
diff --git a/IPython/html/static/tree/js/notebooklist.js b/IPython/html/static/tree/js/notebooklist.js
index 31f2928..ea1a2c7 100644
--- a/IPython/html/static/tree/js/notebooklist.js
+++ b/IPython/html/static/tree/js/notebooklist.js
@@ -156,37 +156,26 @@ define([
};
NotebookList.prototype.load_list = function () {
- var that = this;
- var settings = {
- processData : false,
- cache : false,
- type : "GET",
- dataType : "json",
- success : $.proxy(this.list_loaded, this),
- error : $.proxy( function(xhr, status, error){
+ this.content_manager.list_contents(
+ this.notebook_path,
+ $.proxy(this.draw_notebook_list, this),
+ $.proxy( function(xhr, status, error) {
utils.log_ajax_error(xhr, status, error);
- that.list_loaded([], null, null, {msg:"Error connecting to server."});
- },this)
- };
-
- var url = utils.url_join_encode(
- this.base_url,
- 'api',
- 'contents',
- this.notebook_path
+ that.draw_notebook_list([], "Error connecting to server.");
+ }, this)
);
- $.ajax(url, settings);
};
-
- NotebookList.prototype.list_loaded = function (data, status, xhr, param) {
- var message = 'Notebook list empty.';
- if (param !== undefined && param.msg) {
- message = param.msg;
- }
+ /**
+ * Draw the list of notebooks
+ * @method draw_notebook_list
+ * @param {Array} list An array of dictionaries representing files or
+ * direcotories.
+ * @param {String} error_msg An error message
+ */
+ NotebookList.prototype.draw_notebook_list = function (list, error_msg) {
+ var message = error_msg || 'Notebook list empty.';
var item = null;
- var model = null;
- var list = data.content;
var len = list.length;
this.clear_list();
var n_uploads = this.element.children('.list_item').length;
@@ -209,9 +198,21 @@ define([
offset += 1;
}
for (var i=0; i