From 1f06a280cac44eddfe6eb74fa85682c8c34d5f70 Mon Sep 17 00:00:00 2001 From: "Brian E. Granger" Date: Tue, 6 Sep 2011 17:12:40 -0700 Subject: [PATCH] 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. --- IPython/frontend/html/notebook/static/js/kernel.js | 7 +++---- IPython/frontend/html/notebook/static/js/notebook.js | 6 ++++-- IPython/frontend/html/notebook/static/js/notebooklist.js | 9 ++++++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/IPython/frontend/html/notebook/static/js/kernel.js b/IPython/frontend/html/notebook/static/js/kernel.js index f3797e2f3..75fe272dd 100644 --- a/IPython/frontend/html/notebook/static/js/kernel.js +++ b/IPython/frontend/html/notebook/static/js/kernel.js @@ -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); }, diff --git a/IPython/frontend/html/notebook/static/js/notebook.js b/IPython/frontend/html/notebook/static/js/notebook.js index d149ac36e..65795bb1d 100644 --- a/IPython/frontend/html/notebook/static/js/notebook.js +++ b/IPython/frontend/html/notebook/static/js/notebook.js @@ -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); } diff --git a/IPython/frontend/html/notebook/static/js/notebooklist.js b/IPython/frontend/html/notebook/static/js/notebooklist.js index 7fac3b7c6..9963bf7f2 100644 --- a/IPython/frontend/html/notebook/static/js/notebooklist.js +++ b/IPython/frontend/html/notebook/static/js/notebooklist.js @@ -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(). click(function (e) {