##// END OF EJS Templates
make sure to encode URL components for API requests...
MinRK -
Show More
@@ -77,7 +77,7 b' var IPython = (function (IPython) {'
77 IPython.notebook.new_notebook();
77 IPython.notebook.new_notebook();
78 });
78 });
79 this.element.find('#open_notebook').click(function () {
79 this.element.find('#open_notebook').click(function () {
80 window.open(utils.url_path_join(
80 window.open(utils.url_join_encode(
81 that.baseProjectUrl(),
81 that.baseProjectUrl(),
82 'tree',
82 'tree',
83 that.notebookPath()
83 that.notebookPath()
@@ -93,7 +93,7 b' var IPython = (function (IPython) {'
93 IPython.notebook.save_notebook({async : false});
93 IPython.notebook.save_notebook({async : false});
94 }
94 }
95
95
96 var url = utils.url_path_join(
96 var url = utils.url_join_encode(
97 that.baseProjectUrl(),
97 that.baseProjectUrl(),
98 'files',
98 'files',
99 that.notebookPath(),
99 that.notebookPath(),
@@ -79,15 +79,11 b' var IPython = (function (IPython) {'
79 };
79 };
80
80
81 Notebook.prototype.notebookName = function() {
81 Notebook.prototype.notebookName = function() {
82 var name = $('body').data('notebookName');
82 return $('body').data('notebookName');
83 name = decodeURIComponent(name);
84 return name;
85 };
83 };
86
84
87 Notebook.prototype.notebookPath = function() {
85 Notebook.prototype.notebookPath = function() {
88 var path = $('body').data('notebookPath');
86 return $('body').data('notebookPath');
89 path = decodeURIComponent(path);
90 return path
91 };
87 };
92
88
93 /**
89 /**
@@ -1689,10 +1685,10 b' var IPython = (function (IPython) {'
1689 }
1685 }
1690 }
1686 }
1691 $([IPython.events]).trigger('notebook_saving.Notebook');
1687 $([IPython.events]).trigger('notebook_saving.Notebook');
1692 var url = utils.url_path_join(
1688 var url = utils.url_join_encode(
1693 this.baseProjectUrl(),
1689 this._baseProjectUrl,
1694 'api/notebooks',
1690 'api/notebooks',
1695 this.notebookPath(),
1691 this.notebook_path,
1696 this.notebook_name
1692 this.notebook_name
1697 );
1693 );
1698 $.ajax(url, settings);
1694 $.ajax(url, settings);
@@ -1750,8 +1746,8 b' var IPython = (function (IPython) {'
1750 };
1746 };
1751
1747
1752 Notebook.prototype.new_notebook = function(){
1748 Notebook.prototype.new_notebook = function(){
1753 var path = this.notebookPath();
1749 var path = this.notebook_path;
1754 var base_project_url = this.baseProjectUrl();
1750 var base_project_url = this._baseProjectUrl;
1755 var settings = {
1751 var settings = {
1756 processData : false,
1752 processData : false,
1757 cache : false,
1753 cache : false,
@@ -1761,7 +1757,7 b' var IPython = (function (IPython) {'
1761 success : function (data, status, xhr){
1757 success : function (data, status, xhr){
1762 var notebook_name = data.name;
1758 var notebook_name = data.name;
1763 window.open(
1759 window.open(
1764 utils.url_path_join(
1760 utils.url_join_encode(
1765 base_project_url,
1761 base_project_url,
1766 'notebooks',
1762 'notebooks',
1767 path,
1763 path,
@@ -1771,7 +1767,7 b' var IPython = (function (IPython) {'
1771 );
1767 );
1772 }
1768 }
1773 };
1769 };
1774 var url = utils.url_path_join(
1770 var url = utils.url_join_encode(
1775 base_project_url,
1771 base_project_url,
1776 'api/notebooks',
1772 'api/notebooks',
1777 path
1773 path
@@ -1781,8 +1777,8 b' var IPython = (function (IPython) {'
1781
1777
1782
1778
1783 Notebook.prototype.copy_notebook = function(){
1779 Notebook.prototype.copy_notebook = function(){
1784 var path = this.notebookPath();
1780 var path = this.notebook_path;
1785 var base_project_url = this.baseProjectUrl();
1781 var base_project_url = this._baseProjectUrl;
1786 var settings = {
1782 var settings = {
1787 processData : false,
1783 processData : false,
1788 cache : false,
1784 cache : false,
@@ -1791,7 +1787,7 b' var IPython = (function (IPython) {'
1791 data : JSON.stringify({copy_from : this.notebook_name}),
1787 data : JSON.stringify({copy_from : this.notebook_name}),
1792 async : false,
1788 async : false,
1793 success : function (data, status, xhr) {
1789 success : function (data, status, xhr) {
1794 window.open(utils.url_path_join(
1790 window.open(utils.url_join_encode(
1795 base_project_url,
1791 base_project_url,
1796 'notebooks',
1792 'notebooks',
1797 data.path,
1793 data.path,
@@ -1799,7 +1795,7 b' var IPython = (function (IPython) {'
1799 ), '_blank');
1795 ), '_blank');
1800 }
1796 }
1801 };
1797 };
1802 var url = utils.url_path_join(
1798 var url = utils.url_join_encode(
1803 base_project_url,
1799 base_project_url,
1804 'api/notebooks',
1800 'api/notebooks',
1805 path
1801 path
@@ -1821,10 +1817,10 b' var IPython = (function (IPython) {'
1821 error : $.proxy(that.rename_error, this)
1817 error : $.proxy(that.rename_error, this)
1822 };
1818 };
1823 $([IPython.events]).trigger('rename_notebook.Notebook', data);
1819 $([IPython.events]).trigger('rename_notebook.Notebook', data);
1824 var url = utils.url_path_join(
1820 var url = utils.url_join_encode(
1825 this.baseProjectUrl(),
1821 this._baseProjectUrl,
1826 'api/notebooks',
1822 'api/notebooks',
1827 this.notebookPath(),
1823 this.notebook_path,
1828 this.notebook_name
1824 this.notebook_name
1829 );
1825 );
1830 $.ajax(url, settings);
1826 $.ajax(url, settings);
@@ -1832,9 +1828,9 b' var IPython = (function (IPython) {'
1832
1828
1833
1829
1834 Notebook.prototype.rename_success = function (json, status, xhr) {
1830 Notebook.prototype.rename_success = function (json, status, xhr) {
1835 this.notebook_name = json.name
1831 this.notebook_name = json.name;
1836 var name = this.notebook_name
1832 var name = this.notebook_name;
1837 var path = json.path
1833 var path = json.path;
1838 this.session.rename_notebook(name, path);
1834 this.session.rename_notebook(name, path);
1839 $([IPython.events]).trigger('notebook_renamed.Notebook', json);
1835 $([IPython.events]).trigger('notebook_renamed.Notebook', json);
1840 }
1836 }
@@ -1889,10 +1885,10 b' var IPython = (function (IPython) {'
1889 error : $.proxy(this.load_notebook_error,this),
1885 error : $.proxy(this.load_notebook_error,this),
1890 };
1886 };
1891 $([IPython.events]).trigger('notebook_loading.Notebook');
1887 $([IPython.events]).trigger('notebook_loading.Notebook');
1892 var url = utils.url_path_join(
1888 var url = utils.url_join_encode(
1893 this._baseProjectUrl,
1889 this._baseProjectUrl,
1894 'api/notebooks',
1890 'api/notebooks',
1895 this.notebookPath(),
1891 this.notebook_path,
1896 this.notebook_name
1892 this.notebook_name
1897 );
1893 );
1898 $.ajax(url, settings);
1894 $.ajax(url, settings);
@@ -2027,10 +2023,10 b' var IPython = (function (IPython) {'
2027 * @method list_checkpoints
2023 * @method list_checkpoints
2028 */
2024 */
2029 Notebook.prototype.list_checkpoints = function () {
2025 Notebook.prototype.list_checkpoints = function () {
2030 var url = utils.url_path_join(
2026 var url = utils.url_join_encode(
2031 this.baseProjectUrl(),
2027 this._baseProjectUrl,
2032 'api/notebooks',
2028 'api/notebooks',
2033 this.notebookPath(),
2029 this.notebook_path,
2034 this.notebook_name,
2030 this.notebook_name,
2035 'checkpoints'
2031 'checkpoints'
2036 );
2032 );
@@ -2078,8 +2074,8 b' var IPython = (function (IPython) {'
2078 * @method create_checkpoint
2074 * @method create_checkpoint
2079 */
2075 */
2080 Notebook.prototype.create_checkpoint = function () {
2076 Notebook.prototype.create_checkpoint = function () {
2081 var url = utils.url_path_join(
2077 var url = utils.url_join_encode(
2082 this.baseProjectUrl(),
2078 this._baseProjectUrl,
2083 'api/notebooks',
2079 'api/notebooks',
2084 this.notebookPath(),
2080 this.notebookPath(),
2085 this.notebook_name,
2081 this.notebook_name,
@@ -2165,8 +2161,8 b' var IPython = (function (IPython) {'
2165 */
2161 */
2166 Notebook.prototype.restore_checkpoint = function (checkpoint) {
2162 Notebook.prototype.restore_checkpoint = function (checkpoint) {
2167 $([IPython.events]).trigger('notebook_restoring.Notebook', checkpoint);
2163 $([IPython.events]).trigger('notebook_restoring.Notebook', checkpoint);
2168 var url = utils.url_path_join(
2164 var url = utils.url_join_encode(
2169 this.baseProjectUrl(),
2165 this._baseProjectUrl,
2170 'api/notebooks',
2166 'api/notebooks',
2171 this.notebookPath(),
2167 this.notebookPath(),
2172 this.notebook_name,
2168 this.notebook_name,
@@ -2213,8 +2209,8 b' var IPython = (function (IPython) {'
2213 */
2209 */
2214 Notebook.prototype.delete_checkpoint = function (checkpoint) {
2210 Notebook.prototype.delete_checkpoint = function (checkpoint) {
2215 $([IPython.events]).trigger('notebook_restoring.Notebook', checkpoint);
2211 $([IPython.events]).trigger('notebook_restoring.Notebook', checkpoint);
2216 var url = utils.url_path_join(
2212 var url = utils.url_join_encode(
2217 this.baseProjectUrl(),
2213 this._baseProjectUrl,
2218 'api/notebooks',
2214 'api/notebooks',
2219 this.notebookPath(),
2215 this.notebookPath(),
2220 this.notebook_name,
2216 this.notebook_name,
@@ -128,8 +128,8 b' var IPython = (function (IPython) {'
128 SaveWidget.prototype.update_address_bar = function(){
128 SaveWidget.prototype.update_address_bar = function(){
129 var nbname = IPython.notebook.notebook_name;
129 var nbname = IPython.notebook.notebook_name;
130 var path = IPython.notebook.notebookPath();
130 var path = IPython.notebook.notebookPath();
131 var state = {path : utils.url_path_join(path,nbname)};
131 var state = {path : utils.url_join_encode(path, nbname)};
132 window.history.replaceState(state, "", utils.url_path_join(
132 window.history.replaceState(state, "", utils.url_join_encode(
133 "/notebooks",
133 "/notebooks",
134 path,
134 path,
135 nbname)
135 nbname)
@@ -113,7 +113,7 b' var IPython = (function (IPython) {'
113 $([IPython.events]).trigger('status_restarting.Kernel', {kernel: this});
113 $([IPython.events]).trigger('status_restarting.Kernel', {kernel: this});
114 if (this.running) {
114 if (this.running) {
115 this.stop_channels();
115 this.stop_channels();
116 var url = utils.url_path_join(this.kernel_url, "restart");
116 var url = utils.url_join_encode(this.kernel_url, "restart");
117 $.post(url,
117 $.post(url,
118 $.proxy(this._kernel_started, this),
118 $.proxy(this._kernel_started, this),
119 'json'
119 'json'
@@ -133,7 +133,7 b' var IPython = (function (IPython) {'
133 ws_url = prot + location.host + ws_url;
133 ws_url = prot + location.host + ws_url;
134 }
134 }
135 this.ws_url = ws_url;
135 this.ws_url = ws_url;
136 this.kernel_url = utils.url_path_join(this.base_url, this.kernel_id);
136 this.kernel_url = utils.url_join_encode(this.base_url, this.kernel_id);
137 this.start_channels();
137 this.start_channels();
138 };
138 };
139
139
@@ -44,7 +44,7 b' var IPython = (function (IPython) {'
44 }
44 }
45 },
45 },
46 };
46 };
47 var url = utils.url_path_join(this._baseProjectUrl, 'api/sessions');
47 var url = utils.url_join_encode(this._baseProjectUrl, 'api/sessions');
48 $.ajax(url, settings);
48 $.ajax(url, settings);
49 };
49 };
50
50
@@ -64,7 +64,7 b' var IPython = (function (IPython) {'
64 data: JSON.stringify(model),
64 data: JSON.stringify(model),
65 dataType : "json",
65 dataType : "json",
66 };
66 };
67 var url = utils.url_path_join(this._baseProjectUrl, 'api/sessions', this.id);
67 var url = utils.url_join_encode(this._baseProjectUrl, 'api/sessions', this.id);
68 $.ajax(url, settings);
68 $.ajax(url, settings);
69 };
69 };
70
70
@@ -76,7 +76,7 b' var IPython = (function (IPython) {'
76 dataType : "json",
76 dataType : "json",
77 };
77 };
78 this.kernel.running = false;
78 this.kernel.running = false;
79 var url = utils.url_path_join(this._baseProjectUrl, 'api/sessions', this.id);
79 var url = utils.url_join_encode(this._baseProjectUrl, 'api/sessions', this.id);
80 $.ajax(url, settings);
80 $.ajax(url, settings);
81 };
81 };
82
82
@@ -51,7 +51,7 b' var IPython = (function (IPython) {'
51 dataType : "json",
51 dataType : "json",
52 success : $.proxy(this.load_list_success, this)
52 success : $.proxy(this.load_list_success, this)
53 };
53 };
54 var url = utils.url_path_join(this.baseProjectUrl(), 'clusters');
54 var url = utils.url_join_encode(this.baseProjectUrl(), 'clusters');
55 $.ajax(url, settings);
55 $.ajax(url, settings);
56 };
56 };
57
57
@@ -137,7 +137,7 b' var IPython = (function (IPython) {'
137 }
137 }
138 };
138 };
139 status_col.html('starting');
139 status_col.html('starting');
140 var url = utils.url_path_join(
140 var url = utils.url_join_encode(
141 that.baseProjectUrl(),
141 that.baseProjectUrl(),
142 'clusters',
142 'clusters',
143 that.data.profile,
143 that.data.profile,
@@ -179,7 +179,7 b' var IPython = (function (IPython) {'
179 }
179 }
180 };
180 };
181 status_col.html('stopping');
181 status_col.html('stopping');
182 var url = utils.url_path_join(
182 var url = utils.url_join_encode(
183 that.baseProjectUrl(),
183 that.baseProjectUrl(),
184 'clusters',
184 'clusters',
185 that.data.profile,
185 that.data.profile,
@@ -147,7 +147,7 b' var IPython = (function (IPython) {'
147 },this)
147 },this)
148 };
148 };
149
149
150 var url = utils.url_path_join(
150 var url = utils.url_join_encode(
151 this.baseProjectUrl(),
151 this.baseProjectUrl(),
152 'api',
152 'api',
153 'notebooks',
153 'notebooks',
@@ -177,7 +177,7 b' var IPython = (function (IPython) {'
177 var nbname = utils.splitext(name)[0];
177 var nbname = utils.splitext(name)[0];
178 var item = this.new_notebook_item(i);
178 var item = this.new_notebook_item(i);
179 this.add_link(path, nbname, item);
179 this.add_link(path, nbname, item);
180 name = utils.url_path_join(this.notebookPath(), name);
180 name = utils.url_path_join(path, name);
181 if(this.sessions[name] === undefined){
181 if(this.sessions[name] === undefined){
182 this.add_delete_button(item);
182 this.add_delete_button(item);
183 } else {
183 } else {
@@ -214,10 +214,10 b' var IPython = (function (IPython) {'
214 item.find(".item_name").text(nbname);
214 item.find(".item_name").text(nbname);
215 item.find("a.item_link")
215 item.find("a.item_link")
216 .attr('href',
216 .attr('href',
217 utils.url_path_join(
217 utils.url_join_encode(
218 this.baseProjectUrl(),
218 this.baseProjectUrl(),
219 "notebooks",
219 "notebooks",
220 this.notebookPath(),
220 path,
221 nbname + ".ipynb"
221 nbname + ".ipynb"
222 )
222 )
223 ).attr('target','_blank');
223 ).attr('target','_blank');
@@ -254,7 +254,7 b' var IPython = (function (IPython) {'
254 that.load_sessions();
254 that.load_sessions();
255 }
255 }
256 };
256 };
257 var url = utils.url_path_join(
257 var url = utils.url_join_encode(
258 that.baseProjectUrl(),
258 that.baseProjectUrl(),
259 'api/sessions',
259 'api/sessions',
260 session
260 session
@@ -294,11 +294,11 b' var IPython = (function (IPython) {'
294 parent_item.remove();
294 parent_item.remove();
295 }
295 }
296 };
296 };
297 var url = utils.url_path_join(
297 var url = utils.url_join_encode(
298 notebooklist.baseProjectUrl(),
298 notebooklist.baseProjectUrl(),
299 'api/notebooks',
299 'api/notebooks',
300 notebooklist.notebookPath(),
300 notebooklist.notebookPath(),
301 nbname + '.ipynb'
301 nbname + '.ipynb'
302 );
302 );
303 $.ajax(url, settings);
303 $.ajax(url, settings);
304 }
304 }
@@ -339,7 +339,7 b' var IPython = (function (IPython) {'
339 }
339 }
340 };
340 };
341
341
342 var url = utils.url_path_join(
342 var url = utils.url_join_encode(
343 that.baseProjectUrl(),
343 that.baseProjectUrl(),
344 'api/notebooks',
344 'api/notebooks',
345 that.notebookPath(),
345 that.notebookPath(),
@@ -373,7 +373,7 b' var IPython = (function (IPython) {'
373 success : function (data, status, xhr) {
373 success : function (data, status, xhr) {
374 var notebook_name = data.name;
374 var notebook_name = data.name;
375 window.open(
375 window.open(
376 utils.url_path_join(
376 utils.url_join_encode(
377 base_project_url,
377 base_project_url,
378 'notebooks',
378 'notebooks',
379 path,
379 path,
@@ -382,7 +382,7 b' var IPython = (function (IPython) {'
382 );
382 );
383 }
383 }
384 };
384 };
385 var url = utils.url_path_join(
385 var url = utils.url_join_encode(
386 base_project_url,
386 base_project_url,
387 'api/notebooks',
387 'api/notebooks',
388 path
388 path
General Comments 0
You need to be logged in to leave comments. Login now