From e45f7061a508daebcd63695b538ee72b0f4215a5 2011-10-19 00:55:25
From: Brian E. Granger <ellisonbg@gmail.com>
Date: 2011-10-19 00:55:25
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.

---

diff --git a/IPython/frontend/html/notebook/static/js/kernel.js b/IPython/frontend/html/notebook/static/js/kernel.js
index f3797e2..75fe272 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 d149ac3..65795bb 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 7fac3b7..9963bf7 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>Cancel</button>').button().
             click(function (e) {