Updating JS URL scheme to use embedded data.

All ajax requests from JS now use the data-base-project-url
and data-base-kernel-url data attributes set on the body.
This commit is contained in:
Brian E. Granger 2011-09-06 17:12:40 -07:00 committed by MinRK
parent 36e15cb5c2
commit 1f06a280ca
3 changed files with 13 additions and 9 deletions

View File

@ -15,12 +15,10 @@ var IPython = (function (IPython) {
var Kernel = function () {
this.kernel_id = null;
this.base_url = "/kernels";
this.kernel_url = null;
this.shell_channel = null;
this.iopub_channel = null;
this.base_url = $('body').data('baseKernelUrl') + "kernels";
this.running = false;
this.username = "username";
this.session_id = utils.uuid();
@ -52,7 +50,8 @@ var IPython = (function (IPython) {
var that = this;
if (!this.running) {
var qs = $.param({notebook:notebook_id});
$.post(this.base_url + '?' + qs,
var url = this.base_url + '?' + qs
$.post(url,
function (kernel_id) {
that._handle_start_kernel(kernel_id, callback);
},

View File

@ -929,7 +929,8 @@ var IPython = (function (IPython) {
error : $.proxy(this.notebook_save_failed,this)
};
IPython.save_widget.status_saving();
$.ajax("/notebooks/" + notebook_id, settings);
var url = $('body').data('baseProjectUrl') + 'notebooks/' + notebook_id
$.ajax(url, settings);
};
};
@ -966,7 +967,8 @@ var IPython = (function (IPython) {
}
};
IPython.save_widget.status_loading();
$.ajax("/notebooks/" + notebook_id, settings);
var url = $('body').data('baseProjectUrl') + 'notebooks/' + notebook_id
$.ajax(url, settings);
}

View File

@ -67,7 +67,8 @@ var IPython = (function (IPython) {
dataType : "json",
success : $.proxy(this.list_loaded, this)
};
$.ajax("/notebooks", settings);
var url = $('body').data('baseProjectUrl') + 'notebooks'
$.ajax(url, settings);
};
@ -170,7 +171,8 @@ var IPython = (function (IPython) {
parent_item.remove();
}
};
$.ajax("/notebooks/" + notebook_id, settings);
var url = $('body').data('baseProjectUrl') + 'notebooks/' + notebook_id
$.ajax(url, settings);
$(this).dialog('close');
},
"Cancel": function () {
@ -217,7 +219,8 @@ var IPython = (function (IPython) {
};
var qs = $.param({name:nbname, format:nbformat});
$.ajax('/notebooks?' + qs, settings);
var url = $('body').data('baseProjectUrl') + 'notebooks?' + qs
$.ajax(url, settings);
});
var cancel_button = $('<button>Cancel</button>').button().
click(function (e) {