Show More
@@ -366,6 +366,21 IPython.utils = (function (IPython) { | |||
|
366 | 366 | return Math.floor(points*pixel_per_point); |
|
367 | 367 | }; |
|
368 | 368 | |
|
369 | ||
|
370 | var url_path_join = function () { | |
|
371 | // join a sequence of url components with '/' | |
|
372 | var url = ''; | |
|
373 | for (var i = 0; i < arguments.length; i++) { | |
|
374 | if (url.length > 0 && url[url.length-1] != '/') { | |
|
375 | url = url + '/' + arguments[i]; | |
|
376 | } else { | |
|
377 | url = url + arguments[i]; | |
|
378 | } | |
|
379 | } | |
|
380 | return url; | |
|
381 | }; | |
|
382 | ||
|
383 | ||
|
369 | 384 | // http://stackoverflow.com/questions/2400935/browser-detection-in-javascript |
|
370 | 385 | var browser = (function() { |
|
371 | 386 | var N= navigator.appName, ua= navigator.userAgent, tem; |
@@ -384,7 +399,8 IPython.utils = (function (IPython) { | |||
|
384 | 399 | fixCarriageReturn : fixCarriageReturn, |
|
385 | 400 | autoLinkUrls : autoLinkUrls, |
|
386 | 401 | points_to_pixels : points_to_pixels, |
|
387 | browser : browser | |
|
402 | url_path_join : url_path_join, | |
|
403 | browser : browser | |
|
388 | 404 | }; |
|
389 | 405 | |
|
390 | 406 | }(IPython)); |
@@ -1,5 +1,5 | |||
|
1 | 1 | //---------------------------------------------------------------------------- |
|
2 |
// Copyright (C) 20 |
|
|
2 | // Copyright (C) 2011 The IPython Development Team | |
|
3 | 3 | // |
|
4 | 4 | // Distributed under the terms of the BSD License. The full license is in |
|
5 | 5 | // the file COPYING, distributed as part of this software. |
@@ -1683,7 +1683,12 var IPython = (function (IPython) { | |||
|
1683 | 1683 | error : $.proxy(this.save_notebook_error, this) |
|
1684 | 1684 | }; |
|
1685 | 1685 | $([IPython.events]).trigger('notebook_saving.Notebook'); |
|
1686 | var url = this.baseProjectUrl() + 'api/notebooks' + this.notebookPath()+ this.notebook_name; | |
|
1686 | var url = utils.url_path_join( | |
|
1687 | this.baseProjectUrl(), | |
|
1688 | 'api/notebooks', | |
|
1689 | this.notebookPath(), | |
|
1690 | this.notebook_name | |
|
1691 | ); | |
|
1687 | 1692 | $.ajax(url, settings); |
|
1688 | 1693 | }; |
|
1689 | 1694 | |
@@ -1747,7 +1752,15 var IPython = (function (IPython) { | |||
|
1747 | 1752 | dataType : "json", |
|
1748 | 1753 | success:$.proxy(function (data, status, xhr){ |
|
1749 | 1754 | var notebook_name = data.name; |
|
1750 | window.open(this.baseProjectUrl() +'notebooks' + this.notebookPath()+ notebook_name, '_blank'); | |
|
1755 | window.open( | |
|
1756 | utils.url_path_join( | |
|
1757 | this.baseProjectUrl(), | |
|
1758 | 'notebooks', | |
|
1759 | this.notebookPath(), | |
|
1760 | notebook_name | |
|
1761 | ), | |
|
1762 | '_blank' | |
|
1763 | ); | |
|
1751 | 1764 | }, this) |
|
1752 | 1765 | }; |
|
1753 | 1766 | var url = this.baseProjectUrl() + 'api/notebooks' + path; |
@@ -1766,10 +1779,19 var IPython = (function (IPython) { | |||
|
1766 | 1779 | dataType : "json", |
|
1767 | 1780 | success:$.proxy(function (data, status, xhr){ |
|
1768 | 1781 | notebook_name = data.name; |
|
1769 | window.open(this._baseProjectUrl +'notebooks' + this.notebookPath()+ notebook_name); | |
|
1782 | window.open(utils.url_path_join( | |
|
1783 | this._baseProjectUrl, | |
|
1784 | 'notebooks', | |
|
1785 | this.notebookPath(), | |
|
1786 | notebook_name | |
|
1787 | )); | |
|
1770 | 1788 | }, this) |
|
1771 | 1789 | }; |
|
1772 | var url = this._baseProjectUrl + 'notebooks' + path; | |
|
1790 | var url = utils.url_path_join( | |
|
1791 | this._baseProjectUrl, | |
|
1792 | 'notebooks', | |
|
1793 | path | |
|
1794 | ); | |
|
1773 | 1795 | $.ajax(url,settings); |
|
1774 | 1796 | }; |
|
1775 | 1797 | |
@@ -1788,7 +1810,12 var IPython = (function (IPython) { | |||
|
1788 | 1810 | error : $.proxy(that.rename_error, this) |
|
1789 | 1811 | }; |
|
1790 | 1812 | $([IPython.events]).trigger('notebook_rename.Notebook'); |
|
1791 | var url = this.baseProjectUrl() + 'api/notebooks' + this.notebookPath()+ this.notebook_name; | |
|
1813 | var url = utils.url_path_join( | |
|
1814 | this.baseProjectUrl(), | |
|
1815 | 'api/notebooks', | |
|
1816 | this.notebookPath(), | |
|
1817 | this.notebook_name | |
|
1818 | ); | |
|
1792 | 1819 | $.ajax(url, settings); |
|
1793 | 1820 | }; |
|
1794 | 1821 | |
@@ -1837,22 +1864,27 var IPython = (function (IPython) { | |||
|
1837 | 1864 | * @method load_notebook |
|
1838 | 1865 | * @param {String} notebook_naem and path A notebook to load |
|
1839 | 1866 | */ |
|
1840 |
|
|
|
1841 |
|
|
|
1842 |
|
|
|
1843 |
|
|
|
1844 |
|
|
|
1845 |
|
|
|
1846 |
|
|
|
1847 |
|
|
|
1848 |
|
|
|
1849 |
|
|
|
1850 |
|
|
|
1851 |
|
|
|
1852 |
|
|
|
1853 |
|
|
|
1854 | var url = this.baseProjectUrl() + 'api/notebooks' + this.notebookPath() + this.notebook_name; | |
|
1855 | $.ajax(url, settings); | |
|
1867 | Notebook.prototype.load_notebook = function (notebook_name, notebook_path) { | |
|
1868 | var that = this; | |
|
1869 | this.notebook_name = notebook_name; | |
|
1870 | this.notebook_path = notebook_path; | |
|
1871 | // We do the call with settings so we can set cache to false. | |
|
1872 | var settings = { | |
|
1873 | processData : false, | |
|
1874 | cache : false, | |
|
1875 | type : "GET", | |
|
1876 | dataType : "json", | |
|
1877 | success : $.proxy(this.load_notebook_success,this), | |
|
1878 | error : $.proxy(this.load_notebook_error,this), | |
|
1879 | }; | |
|
1880 | $([IPython.events]).trigger('notebook_loading.Notebook'); | |
|
1881 | var url = utils.url_path_join( | |
|
1882 | this._baseProjectUrl, | |
|
1883 | 'api/notebooks', | |
|
1884 | this.notebookPath(), | |
|
1885 | this.notebook_name | |
|
1886 | ); | |
|
1887 | $.ajax(url, settings); | |
|
1856 | 1888 | }; |
|
1857 | 1889 | |
|
1858 | 1890 | /** |
@@ -1983,14 +2015,20 var IPython = (function (IPython) { | |||
|
1983 | 2015 | * |
|
1984 | 2016 | * @method list_checkpoints |
|
1985 | 2017 | */ |
|
1986 |
|
|
|
1987 | var url = this.baseProjectUrl() + 'api/notebooks' + this.notebookPath() + this.notebook_name + '/checkpoints'; | |
|
1988 | $.get(url).done( | |
|
1989 | $.proxy(this.list_checkpoints_success, this) | |
|
1990 | ).fail( | |
|
1991 | $.proxy(this.list_checkpoints_error, this) | |
|
1992 | ); | |
|
1993 |
|
|
|
2018 | Notebook.prototype.list_checkpoints = function () { | |
|
2019 | var url = utils.url_path_join( | |
|
2020 | this.baseProjectUrl(), | |
|
2021 | 'api/notebooks', | |
|
2022 | this.notebookPath(), | |
|
2023 | this.notebook_name, | |
|
2024 | 'checkpoints' | |
|
2025 | ); | |
|
2026 | $.get(url).done( | |
|
2027 | $.proxy(this.list_checkpoints_success, this) | |
|
2028 | ).fail( | |
|
2029 | $.proxy(this.list_checkpoints_error, this) | |
|
2030 | ); | |
|
2031 | }; | |
|
1994 | 2032 | |
|
1995 | 2033 | /** |
|
1996 | 2034 | * Success callback for listing checkpoints. |
@@ -2028,14 +2066,20 var IPython = (function (IPython) { | |||
|
2028 | 2066 | * |
|
2029 | 2067 | * @method create_checkpoint |
|
2030 | 2068 | */ |
|
2031 |
|
|
|
2032 | var url = this.baseProjectUrl() + 'api/notebooks' + this.notebookPath() + this.notebook_name + '/checkpoints'; | |
|
2033 | $.post(url).done( | |
|
2034 | $.proxy(this.create_checkpoint_success, this) | |
|
2035 | ).fail( | |
|
2036 | $.proxy(this.create_checkpoint_error, this) | |
|
2037 | ); | |
|
2038 |
|
|
|
2069 | Notebook.prototype.create_checkpoint = function () { | |
|
2070 | var url = utils.url_path_join( | |
|
2071 | this.baseProjectUrl(), | |
|
2072 | 'api/notebooks', | |
|
2073 | this.notebookPath(), | |
|
2074 | this.notebook_name, | |
|
2075 | 'checkpoints' | |
|
2076 | ); | |
|
2077 | $.post(url).done( | |
|
2078 | $.proxy(this.create_checkpoint_success, this) | |
|
2079 | ).fail( | |
|
2080 | $.proxy(this.create_checkpoint_error, this) | |
|
2081 | ); | |
|
2082 | }; | |
|
2039 | 2083 | |
|
2040 | 2084 | /** |
|
2041 | 2085 | * Success callback for creating a checkpoint. |
@@ -2110,7 +2154,14 var IPython = (function (IPython) { | |||
|
2110 | 2154 | */ |
|
2111 | 2155 | Notebook.prototype.restore_checkpoint = function (checkpoint) { |
|
2112 | 2156 | $([IPython.events]).trigger('notebook_restoring.Notebook', checkpoint); |
|
2113 | var url = this.baseProjectUrl() + 'api/notebooks' + this.notebookPath() + this.notebook_name + '/checkpoints/' + checkpoint; | |
|
2157 | var url = utils.url_path_join( | |
|
2158 | this.baseProjectUrl(), | |
|
2159 | 'api/notebooks', | |
|
2160 | this.notebookPath(), | |
|
2161 | this.notebook_name, | |
|
2162 | 'checkpoints', | |
|
2163 | checkpoint | |
|
2164 | ); | |
|
2114 | 2165 | $.post(url).done( |
|
2115 | 2166 | $.proxy(this.restore_checkpoint_success, this) |
|
2116 | 2167 | ).fail( |
@@ -2151,7 +2202,14 var IPython = (function (IPython) { | |||
|
2151 | 2202 | */ |
|
2152 | 2203 | Notebook.prototype.delete_checkpoint = function (checkpoint) { |
|
2153 | 2204 | $([IPython.events]).trigger('notebook_restoring.Notebook', checkpoint); |
|
2154 | var url = this.baseProjectUrl() + 'api/notebooks' + this.notebookPath() + this.notebook_name + '/checkpoints/' + checkpoint; | |
|
2205 | var url = utils.url_path_join( | |
|
2206 | this.baseProjectUrl(), | |
|
2207 | 'api/notebooks', | |
|
2208 | this.notebookPath(), | |
|
2209 | this.notebook_name, | |
|
2210 | 'checkpoints', | |
|
2211 | checkpoint | |
|
2212 | ); | |
|
2155 | 2213 | $.ajax(url, { |
|
2156 | 2214 | type: 'DELETE', |
|
2157 | 2215 | success: $.proxy(this.delete_checkpoint_success, this), |
@@ -1,5 +1,5 | |||
|
1 | 1 | //---------------------------------------------------------------------------- |
|
2 |
// Copyright (C) 20 |
|
|
2 | // Copyright (C) 2011 The IPython Development Team | |
|
3 | 3 | // |
|
4 | 4 | // Distributed under the terms of the BSD License. The full license is in |
|
5 | 5 | // the file COPYING, distributed as part of this software. |
@@ -10,6 +10,9 | |||
|
10 | 10 | //============================================================================ |
|
11 | 11 | |
|
12 | 12 | var IPython = (function (IPython) { |
|
13 | "use strict"; | |
|
14 | ||
|
15 | var utils = IPython.utils; | |
|
13 | 16 | |
|
14 | 17 | var ClusterList = function (selector) { |
|
15 | 18 | this.selector = selector; |
@@ -48,14 +51,14 var IPython = (function (IPython) { | |||
|
48 | 51 | dataType : "json", |
|
49 | 52 | success : $.proxy(this.load_list_success, this) |
|
50 | 53 | }; |
|
51 |
var url = this.baseProjectUrl() |
|
|
54 | var url = utils.url_path_join(this.baseProjectUrl(), 'clusters'); | |
|
52 | 55 | $.ajax(url, settings); |
|
53 | 56 | }; |
|
54 | 57 | |
|
55 | 58 | |
|
56 | 59 | ClusterList.prototype.clear_list = function () { |
|
57 | 60 | this.element.children('.list_item').remove(); |
|
58 | } | |
|
61 | }; | |
|
59 | 62 | |
|
60 | 63 | ClusterList.prototype.load_list_success = function (data, status, xhr) { |
|
61 | 64 | this.clear_list(); |
@@ -66,7 +69,7 var IPython = (function (IPython) { | |||
|
66 | 69 | item.update_state(data[i]); |
|
67 | 70 | element.data('item', item); |
|
68 | 71 | this.element.append(element); |
|
69 |
} |
|
|
72 | } | |
|
70 | 73 | }; |
|
71 | 74 | |
|
72 | 75 | |
@@ -81,10 +84,9 var IPython = (function (IPython) { | |||
|
81 | 84 | }; |
|
82 | 85 | |
|
83 | 86 | |
|
84 | ||
|
85 | 87 | ClusterItem.prototype.style = function () { |
|
86 | 88 | this.element.addClass('list_item').addClass("row-fluid"); |
|
87 | } | |
|
89 | }; | |
|
88 | 90 | |
|
89 | 91 | ClusterItem.prototype.update_state = function (data) { |
|
90 | 92 | this.data = data; |
@@ -92,9 +94,8 var IPython = (function (IPython) { | |||
|
92 | 94 | this.state_running(); |
|
93 | 95 | } else if (data.status === 'stopped') { |
|
94 | 96 | this.state_stopped(); |
|
95 |
} |
|
|
96 | ||
|
97 | } | |
|
97 | } | |
|
98 | }; | |
|
98 | 99 | |
|
99 | 100 | |
|
100 | 101 | ClusterItem.prototype.state_stopped = function () { |
@@ -132,13 +133,18 var IPython = (function (IPython) { | |||
|
132 | 133 | that.update_state(data); |
|
133 | 134 | }, |
|
134 | 135 | error : function (data, status, xhr) { |
|
135 | status_col.html("error starting cluster") | |
|
136 | status_col.html("error starting cluster"); | |
|
136 | 137 | } |
|
137 | 138 | }; |
|
138 | 139 | status_col.html('starting'); |
|
139 | var url = that.baseProjectUrl() + 'clusters/' + that.data.profile + '/start'; | |
|
140 | var url = utils.url_path_join( | |
|
141 | that.baseProjectUrl(), | |
|
142 | 'clusters', | |
|
143 | that.data.profile, | |
|
144 | 'start' | |
|
145 | ); | |
|
140 | 146 | $.ajax(url, settings); |
|
141 |
} |
|
|
147 | } | |
|
142 | 148 | }); |
|
143 | 149 | }; |
|
144 | 150 | |
@@ -169,11 +175,16 var IPython = (function (IPython) { | |||
|
169 | 175 | }, |
|
170 | 176 | error : function (data, status, xhr) { |
|
171 | 177 | console.log('error',data); |
|
172 | status_col.html("error stopping cluster") | |
|
178 | status_col.html("error stopping cluster"); | |
|
173 | 179 | } |
|
174 | 180 | }; |
|
175 | status_col.html('stopping') | |
|
176 | var url = that.baseProjectUrl() + 'clusters/' + that.data.profile + '/stop'; | |
|
181 | status_col.html('stopping'); | |
|
182 | var url = utils.url_path_join( | |
|
183 | that.baseProjectUrl(), | |
|
184 | 'clusters', | |
|
185 | that.data.profile, | |
|
186 | 'stop' | |
|
187 | ); | |
|
177 | 188 | $.ajax(url, settings); |
|
178 | 189 | }); |
|
179 | 190 | }; |
@@ -1,5 +1,5 | |||
|
1 | 1 | //---------------------------------------------------------------------------- |
|
2 |
// Copyright (C) 20 |
|
|
2 | // Copyright (C) 2011 The IPython Development Team | |
|
3 | 3 | // |
|
4 | 4 | // Distributed under the terms of the BSD License. The full license is in |
|
5 | 5 | // the file COPYING, distributed as part of this software. |
@@ -10,6 +10,9 | |||
|
10 | 10 | //============================================================================ |
|
11 | 11 | |
|
12 | 12 | var IPython = (function (IPython) { |
|
13 | "use strict"; | |
|
14 | ||
|
15 | var utils = IPython.utils; | |
|
13 | 16 | |
|
14 | 17 | var NotebookList = function (selector) { |
|
15 | 18 | this.selector = selector; |
@@ -18,8 +21,8 var IPython = (function (IPython) { | |||
|
18 | 21 | this.style(); |
|
19 | 22 | this.bind_events(); |
|
20 | 23 | } |
|
21 |
this.notebooks_list = |
|
|
22 |
this.sessions = |
|
|
24 | this.notebooks_list = []; | |
|
25 | this.sessions = {}; | |
|
23 | 26 | }; |
|
24 | 27 | |
|
25 | 28 | NotebookList.prototype.baseProjectUrl = function () { |
@@ -27,15 +30,9 var IPython = (function (IPython) { | |||
|
27 | 30 | }; |
|
28 | 31 | |
|
29 | 32 | NotebookList.prototype.notebookPath = function() { |
|
30 |
|
|
|
31 | path = decodeURIComponent(path); | |
|
32 | return path; | |
|
33 | return $('body').data('notebookPath'); | |
|
33 | 34 | }; |
|
34 | 35 | |
|
35 | NotebookList.prototype.url_name = function(name){ | |
|
36 | return encodeURIComponent(name); | |
|
37 | }; | |
|
38 | ||
|
39 | 36 | NotebookList.prototype.style = function () { |
|
40 | 37 | $('#notebook_toolbar').addClass('list_toolbar'); |
|
41 | 38 | $('#drag_info').addClass('toolbar_info'); |
@@ -66,15 +63,16 var IPython = (function (IPython) { | |||
|
66 | 63 | files = event.originalEvent.dataTransfer.files; |
|
67 | 64 | } else |
|
68 | 65 | { |
|
69 | files = event.originalEvent.target.files | |
|
66 | files = event.originalEvent.target.files; | |
|
70 | 67 | } |
|
71 |
for (var i = 0 |
|
|
68 | for (var i = 0; i < files.length; i++) { | |
|
69 | var f = files[i]; | |
|
72 | 70 | var reader = new FileReader(); |
|
73 | 71 | reader.readAsText(f); |
|
74 | 72 | var fname = f.name.split('.'); |
|
75 | 73 | var nbname = fname.slice(0,-1).join('.'); |
|
76 | 74 | var nbformat = fname.slice(-1)[0]; |
|
77 |
if (nbformat === 'ipynb') {nbformat = 'json';} |
|
|
75 | if (nbformat === 'ipynb') {nbformat = 'json';} | |
|
78 | 76 | if (nbformat === 'py' || nbformat === 'json') { |
|
79 | 77 | var item = that.new_notebook_item(0); |
|
80 | 78 | that.add_name_input(nbname, item); |
@@ -87,10 +85,10 var IPython = (function (IPython) { | |||
|
87 | 85 | that.add_notebook_data(event.target.result, nbitem); |
|
88 | 86 | that.add_upload_button(nbitem); |
|
89 | 87 | }; |
|
90 |
} |
|
|
88 | } | |
|
91 | 89 | } |
|
92 | 90 | return false; |
|
93 |
|
|
|
91 | }; | |
|
94 | 92 | |
|
95 | 93 | NotebookList.prototype.clear_list = function () { |
|
96 | 94 | this.element.children('.list_item').remove(); |
@@ -111,20 +109,22 var IPython = (function (IPython) { | |||
|
111 | 109 | |
|
112 | 110 | |
|
113 | 111 | NotebookList.prototype.sessions_loaded = function(data){ |
|
114 |
this.sessions = |
|
|
115 | console.log(data) | |
|
112 | this.sessions = {}; | |
|
116 | 113 | var len = data.length; |
|
117 |
if (len |
|
|
114 | if (len > 0) { | |
|
118 | 115 | for (var i=0; i<len; i++) { |
|
119 |
if (data[i] |
|
|
120 |
nb_path = data[i] |
|
|
116 | if (!data[i].notebook.path) { | |
|
117 | nb_path = data[i].notebook.name; | |
|
121 | 118 | } |
|
122 | 119 | else { |
|
123 | nb_path = data[i]['notebook']['path'] + data[i]['notebook']['name']; | |
|
120 | nb_path = utils.url_path_join( | |
|
121 | data[i].notebook.path, | |
|
122 | data[i].notebook.name | |
|
123 | ); | |
|
124 | 124 | } |
|
125 |
this.sessions[nb_path]= data[i] |
|
|
125 | this.sessions[nb_path] = data[i].id; | |
|
126 | 126 | } |
|
127 |
} |
|
|
127 | } | |
|
128 | 128 | this.load_list(); |
|
129 | 129 | }; |
|
130 | 130 | |
@@ -141,7 +141,12 var IPython = (function (IPython) { | |||
|
141 | 141 | },this) |
|
142 | 142 | }; |
|
143 | 143 | |
|
144 | var url = this.baseProjectUrl() + 'api/notebooks' + this.notebookPath(); | |
|
144 | var url = utils.url_path_join( | |
|
145 | this.baseProjectUrl(), | |
|
146 | 'api', | |
|
147 | 'notebooks', | |
|
148 | this.notebookPath() | |
|
149 | ); | |
|
145 | 150 | $.ajax(url, settings); |
|
146 | 151 | }; |
|
147 | 152 | |
@@ -149,17 +154,16 var IPython = (function (IPython) { | |||
|
149 | 154 | NotebookList.prototype.list_loaded = function (data, status, xhr, param) { |
|
150 | 155 | var message = 'Notebook list empty.'; |
|
151 | 156 | if (param !== undefined && param.msg) { |
|
152 |
|
|
|
157 | message = param.msg; | |
|
153 | 158 | } |
|
154 | 159 | var len = data.length; |
|
155 | 160 | this.clear_list(); |
|
156 | if(len == 0) | |
|
157 | { | |
|
161 | if (len === 0) { | |
|
158 | 162 | $(this.new_notebook_item(0)) |
|
159 | 163 | .append( |
|
160 | 164 | $('<div style="margin:auto;text-align:center;color:grey"/>') |
|
161 | 165 | .text(message) |
|
162 |
|
|
|
166 | ); | |
|
163 | 167 | } |
|
164 | 168 | for (var i=0; i<len; i++) { |
|
165 | 169 | var name = data[i].name; |
@@ -168,12 +172,12 var IPython = (function (IPython) { | |||
|
168 | 172 | var item = this.new_notebook_item(i); |
|
169 | 173 | this.add_link(path, nbname, item); |
|
170 | 174 | name = this.notebookPath() + name; |
|
171 | if(this.sessions[name] == undefined){ | |
|
175 | if(this.sessions[name] === undefined){ | |
|
172 | 176 | this.add_delete_button(item); |
|
173 | 177 | } else { |
|
174 | 178 | this.add_shutdown_button(item,this.sessions[name]); |
|
175 | 179 | } |
|
176 |
} |
|
|
180 | } | |
|
177 | 181 | }; |
|
178 | 182 | |
|
179 | 183 | |
@@ -203,8 +207,14 var IPython = (function (IPython) { | |||
|
203 | 207 | item.data('path', path); |
|
204 | 208 | item.find(".item_name").text(nbname); |
|
205 | 209 | item.find("a.item_link") |
|
206 | .attr('href', this.baseProjectUrl() + "notebooks" + this.notebookPath() + nbname + ".ipynb") | |
|
207 | .attr('target','_blank'); | |
|
210 | .attr('href', | |
|
211 | utils.url_path_join( | |
|
212 | this.baseProjectUrl(), | |
|
213 | "notebooks", | |
|
214 | this.notebookPath(), | |
|
215 | nbname + ".ipynb" | |
|
216 | ) | |
|
217 | ).attr('target','_blank'); | |
|
208 | 218 | }; |
|
209 | 219 | |
|
210 | 220 | |
@@ -238,7 +248,11 var IPython = (function (IPython) { | |||
|
238 | 248 | that.load_sessions(); |
|
239 | 249 | } |
|
240 | 250 | }; |
|
241 | var url = that.baseProjectUrl() + 'api/sessions/' + session; | |
|
251 | var url = utils.url_path_join( | |
|
252 | that.baseProjectUrl(), | |
|
253 | 'api/sessions', | |
|
254 | session | |
|
255 | ); | |
|
242 | 256 | $.ajax(url, settings); |
|
243 | 257 | return false; |
|
244 | 258 | }); |
@@ -274,7 +288,12 var IPython = (function (IPython) { | |||
|
274 | 288 | parent_item.remove(); |
|
275 | 289 | } |
|
276 | 290 | }; |
|
277 | var url = notebooklist.baseProjectUrl() + 'api/notebooks' + notebooklist.notebookPath() + nbname + '.ipynb'; | |
|
291 | var url = utils.url_path_join( | |
|
292 | notebooklist.baseProjectUrl(), | |
|
293 | 'api/notebooks', | |
|
294 | notebooklist.notebookPath(), | |
|
295 | nbname + '.ipynb' | |
|
296 | ); | |
|
278 | 297 | $.ajax(url, settings); |
|
279 | 298 | } |
|
280 | 299 | }, |
@@ -300,7 +319,7 var IPython = (function (IPython) { | |||
|
300 | 319 | content_type = 'application/json'; |
|
301 | 320 | } else if (nbformat === 'py') { |
|
302 | 321 | content_type = 'application/x-python'; |
|
303 |
} |
|
|
322 | } | |
|
304 | 323 | var settings = { |
|
305 | 324 | processData : false, |
|
306 | 325 | cache : false, |
@@ -315,7 +334,10 var IPython = (function (IPython) { | |||
|
315 | 334 | }; |
|
316 | 335 | |
|
317 | 336 | var qs = $.param({name:nbname, format:nbformat}); |
|
318 | var url = that.baseProjectUrl() + 'notebooks?' + qs; | |
|
337 | var url = utils.url_path_join( | |
|
338 | that.baseProjectUrl(), | |
|
339 | 'notebooks?' + qs | |
|
340 | ); | |
|
319 | 341 | $.ajax(url, settings); |
|
320 | 342 | return false; |
|
321 | 343 | }); |
@@ -340,12 +362,23 var IPython = (function (IPython) { | |||
|
340 | 362 | type : "POST", |
|
341 | 363 | dataType : "json", |
|
342 | 364 | success:$.proxy(function (data, status, xhr){ |
|
343 | notebook_name = data.name; | |
|
344 | window.open(this.baseProjectUrl() +'notebooks' + this.notebookPath()+ notebook_name, '_blank'); | |
|
365 | var notebook_name = data.name; | |
|
366 | window.open( | |
|
367 | utils.url_path_join( | |
|
368 | this.baseProjectUrl(), | |
|
369 | 'notebooks', | |
|
370 | this.notebookPath(), | |
|
371 | notebook_name), | |
|
372 | '_blank' | |
|
373 | ); | |
|
345 | 374 | }, this) |
|
346 | 375 | }; |
|
347 | var url = this.baseProjectUrl() + 'api/notebooks' + path; | |
|
348 | $.ajax(url,settings); | |
|
376 | var url = utils.url_path_join( | |
|
377 | this.baseProjectUrl(), | |
|
378 | 'api/notebooks', | |
|
379 | path | |
|
380 | ); | |
|
381 | $.ajax(url, settings); | |
|
349 | 382 | }; |
|
350 | 383 | |
|
351 | 384 | IPython.NotebookList = NotebookList; |
General Comments 0
You need to be logged in to leave comments.
Login now