From c24238f9e00c8c7df3386f82c5ad7a19f733c093 2014-11-11 20:32:13 From: Thomas Kluyver Date: 2014-11-11 20:32:13 Subject: [PATCH] Expose and use get requests specifying type in the JS --- diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js index 21bcba2..bd2b49e 100644 --- a/IPython/html/static/notebook/js/notebook.js +++ b/IPython/html/static/notebook/js/notebook.js @@ -2102,6 +2102,7 @@ define([ this.notebook_name = utils.url_path_split(this.notebook_path)[1]; this.events.trigger('notebook_loading.Notebook'); this.contents.get(notebook_path, { + type: 'notebook', success: $.proxy(this.load_notebook_success, this), error: $.proxy(this.load_notebook_error, this) }); diff --git a/IPython/html/static/services/contents.js b/IPython/html/static/services/contents.js index 481015c..0d4d7cb 100644 --- a/IPython/html/static/services/contents.js +++ b/IPython/html/static/services/contents.js @@ -87,6 +87,9 @@ define([ error : this.create_basic_error_handler(options.error) }; var url = this.api_url(path); + if (options.type) { + url += '?type=' + options.type; + } $.ajax(url, settings); }; @@ -250,20 +253,11 @@ define([ * last_modified: last modified dat * @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 called with ajax results on error + * @param {Object} options including success and error callbacks */ Contents.prototype.list_contents = function(path, options) { - var settings = { - processData : false, - cache : false, - type : "GET", - dataType : "json", - success : options.success, - error : this.create_basic_error_handler(options.error) - }; - - $.ajax(this.api_url(path), settings); + options.type = 'directory'; + this.get(path, options); };