##// END OF EJS Templates
Move contentmanager to contents
Jeff Hemmelgarn -
Show More
@@ -138,11 +138,11 b' class IPythonHandler(AuthenticatedHandler):'
138 return self.settings.get('websocket_url', '')
138 return self.settings.get('websocket_url', '')
139
139
140 @property
140 @property
141 def contentmanager_js_source(self):
141 def contents_js_source(self):
142 self.log.debug("Using contentmanager: %s", self.settings.get('contentmanager_js_source',
142 self.log.debug("Using contents: %s", self.settings.get('contents_js_source',
143 'base/js/contentmanager'))
143 'base/js/contents'))
144 return self.settings.get('contentmanager_js_source',
144 return self.settings.get('contents_js_source',
145 'base/js/contentmanager')
145 'base/js/contents')
146
146
147 #---------------------------------------------------------------
147 #---------------------------------------------------------------
148 # Manager objects
148 # Manager objects
@@ -232,7 +232,7 b' class IPythonHandler(AuthenticatedHandler):'
232 login_available=self.login_available,
232 login_available=self.login_available,
233 static_url=self.static_url,
233 static_url=self.static_url,
234 sys_info=sys_info,
234 sys_info=sys_info,
235 contentmanager_js_source=self.contentmanager_js_source,
235 contents_js_source=self.contents_js_source,
236 )
236 )
237
237
238 def get_json_body(self):
238 def get_json_body(self):
@@ -7,10 +7,10 b' define(['
7 'base/js/utils',
7 'base/js/utils',
8 'base/js/dialog',
8 'base/js/dialog',
9 ], function(IPython, $, utils, dialog) {
9 ], function(IPython, $, utils, dialog) {
10 var ContentManager = function(options) {
10 var Contents = function(options) {
11 // Constructor
11 // Constructor
12 //
12 //
13 // A contentmanager handles passing file operations
13 // A contents handles passing file operations
14 // to the back-end. This includes checkpointing
14 // to the back-end. This includes checkpointing
15 // with the normal file operations.
15 // with the normal file operations.
16 //
16 //
@@ -40,7 +40,7 b' define(['
40 * @param {Function} success_callback
40 * @param {Function} success_callback
41 * @param {Function} error_callback
41 * @param {Function} error_callback
42 */
42 */
43 ContentManager.prototype.load_notebook = function (path, name, success_callback,
43 Contents.prototype.load_notebook = function (path, name, success_callback,
44 error_callback) {
44 error_callback) {
45 // We do the call with settings so we can set cache to false.
45 // We do the call with settings so we can set cache to false.
46 var settings = {
46 var settings = {
@@ -69,7 +69,7 b' define(['
69 * @method scroll_to_cell
69 * @method scroll_to_cell
70 * @param {String} path The path to create the new notebook at
70 * @param {String} path The path to create the new notebook at
71 */
71 */
72 ContentManager.prototype.new_notebook = function(path) {
72 Contents.prototype.new_notebook = function(path) {
73 var base_url = this.base_url;
73 var base_url = this.base_url;
74 var settings = {
74 var settings = {
75 processData : false,
75 processData : false,
@@ -112,14 +112,14 b' define(['
112 $.ajax(url,settings);
112 $.ajax(url,settings);
113 };
113 };
114
114
115 ContentManager.prototype.delete_notebook = function(name, path) {
115 Contents.prototype.delete_notebook = function(name, path) {
116 var settings = {
116 var settings = {
117 processData : false,
117 processData : false,
118 cache : false,
118 cache : false,
119 type : "DELETE",
119 type : "DELETE",
120 dataType : "json",
120 dataType : "json",
121 success : $.proxy(this.events.trigger, this.events,
121 success : $.proxy(this.events.trigger, this.events,
122 'notebook_deleted.ContentManager',
122 'notebook_deleted.Contents',
123 {
123 {
124 name: name,
124 name: name,
125 path: path
125 path: path
@@ -135,7 +135,7 b' define(['
135 $.ajax(url, settings);
135 $.ajax(url, settings);
136 };
136 };
137
137
138 ContentManager.prototype.rename_notebook = function(path, name, new_name) {
138 Contents.prototype.rename_notebook = function(path, name, new_name) {
139 var that = this;
139 var that = this;
140 var data = {name: new_name};
140 var data = {name: new_name};
141 var settings = {
141 var settings = {
@@ -146,11 +146,11 b' define(['
146 dataType: "json",
146 dataType: "json",
147 contentType: 'application/json',
147 contentType: 'application/json',
148 success : function (json, status, xhr) {
148 success : function (json, status, xhr) {
149 that.events.trigger('notebook_rename_success.ContentManager',
149 that.events.trigger('notebook_rename_success.Contents',
150 json);
150 json);
151 },
151 },
152 error : function (xhr, status, error) {
152 error : function (xhr, status, error) {
153 that.events.trigger('notebook_rename_error.ContentManager',
153 that.events.trigger('notebook_rename_error.Contents',
154 [xhr, status, error]);
154 [xhr, status, error]);
155 }
155 }
156 };
156 };
@@ -163,7 +163,7 b' define(['
163 $.ajax(url, settings);
163 $.ajax(url, settings);
164 };
164 };
165
165
166 ContentManager.prototype.save_notebook = function(path, name, content,
166 Contents.prototype.save_notebook = function(path, name, content,
167 extra_settings) {
167 extra_settings) {
168 var that = content;
168 var that = content;
169 // Create a JSON model to be sent to the server.
169 // Create a JSON model to be sent to the server.
@@ -183,10 +183,10 b' define(['
183 data : JSON.stringify(model),
183 data : JSON.stringify(model),
184 contentType: 'application/json',
184 contentType: 'application/json',
185 success : $.proxy(this.events.trigger, this.events,
185 success : $.proxy(this.events.trigger, this.events,
186 'notebook_save_success.ContentManager',
186 'notebook_save_success.Contents',
187 $.extend(model, { start : start })),
187 $.extend(model, { start : start })),
188 error : function (xhr, status, error) {
188 error : function (xhr, status, error) {
189 that.events.trigger('notebook_save_error.ContentManager',
189 that.events.trigger('notebook_save_error.Contents',
190 [xhr, status, error, model]);
190 [xhr, status, error, model]);
191 }
191 }
192 };
192 };
@@ -208,11 +208,11 b' define(['
208 * Checkpointing Functions
208 * Checkpointing Functions
209 */
209 */
210
210
211 ContentManager.prototype.save_checkpoint = function() {
211 Contents.prototype.save_checkpoint = function() {
212 // This is not necessary - integrated into save
212 // This is not necessary - integrated into save
213 };
213 };
214
214
215 ContentManager.prototype.restore_checkpoint = function(notebook, id) {
215 Contents.prototype.restore_checkpoint = function(notebook, id) {
216 that = notebook;
216 that = notebook;
217 this.events.trigger('notebook_restoring.Notebook', checkpoint);
217 this.events.trigger('notebook_restoring.Notebook', checkpoint);
218 var url = utils.url_join_encode(
218 var url = utils.url_join_encode(
@@ -230,7 +230,7 b' define(['
230 );
230 );
231 };
231 };
232
232
233 ContentManager.prototype.list_checkpoints = function(notebook) {
233 Contents.prototype.list_checkpoints = function(notebook) {
234 that = notebook;
234 that = notebook;
235 var url = utils.url_join_encode(
235 var url = utils.url_join_encode(
236 that.base_url,
236 that.base_url,
@@ -266,7 +266,7 b' define(['
266 * @param {Function} load_callback called with list of notebooks on success
266 * @param {Function} load_callback called with list of notebooks on success
267 * @param {Function} error_callback called with ajax results on error
267 * @param {Function} error_callback called with ajax results on error
268 */
268 */
269 ContentManager.prototype.list_contents = function(path, load_callback,
269 Contents.prototype.list_contents = function(path, load_callback,
270 error_callback) {
270 error_callback) {
271 var that = this;
271 var that = this;
272 var settings = {
272 var settings = {
@@ -284,7 +284,7 b' define(['
284 }
284 }
285
285
286
286
287 IPython.ContentManager = ContentManager;
287 IPython.Contents = Contents;
288
288
289 return {'ContentManager': ContentManager};
289 return {'Contents': Contents};
290 });
290 });
@@ -5,7 +5,7 b' require(['
5 'base/js/namespace',
5 'base/js/namespace',
6 'jquery',
6 'jquery',
7 'notebook/js/notebook',
7 'notebook/js/notebook',
8 'contentmanager',
8 'contents',
9 'base/js/utils',
9 'base/js/utils',
10 'base/js/page',
10 'base/js/page',
11 'notebook/js/layoutmanager',
11 'notebook/js/layoutmanager',
@@ -28,7 +28,7 b' require(['
28 IPython,
28 IPython,
29 $,
29 $,
30 notebook,
30 notebook,
31 contentmanager,
31 contents,
32 utils,
32 utils,
33 page,
33 page,
34 layoutmanager,
34 layoutmanager,
@@ -72,14 +72,14 b' require(['
72 var save_widget = new savewidget.SaveWidget('span#save_widget', {
72 var save_widget = new savewidget.SaveWidget('span#save_widget', {
73 events: events,
73 events: events,
74 keyboard_manager: keyboard_manager});
74 keyboard_manager: keyboard_manager});
75 var content_manager = new contentmanager.ContentManager($.extend({
75 var contents = new contents.Contents($.extend({
76 events: events},
76 events: events},
77 common_options));
77 common_options));
78 var notebook = new notebook.Notebook('div#notebook', $.extend({
78 var notebook = new notebook.Notebook('div#notebook', $.extend({
79 events: events,
79 events: events,
80 keyboard_manager: keyboard_manager,
80 keyboard_manager: keyboard_manager,
81 save_widget: save_widget,
81 save_widget: save_widget,
82 content_manager: content_manager,
82 contents: contents,
83 config: user_config},
83 config: user_config},
84 common_options));
84 common_options));
85 var login_widget = new loginwidget.LoginWidget('span#login_widget', common_options);
85 var login_widget = new loginwidget.LoginWidget('span#login_widget', common_options);
@@ -92,7 +92,7 b' require(['
92 notebook: notebook});
92 notebook: notebook});
93 var menubar = new menubar.MenuBar('#menubar', $.extend({
93 var menubar = new menubar.MenuBar('#menubar', $.extend({
94 notebook: notebook,
94 notebook: notebook,
95 content_manager: content_manager,
95 contents: contents,
96 layout_manager: layout_manager,
96 layout_manager: layout_manager,
97 events: events,
97 events: events,
98 save_widget: save_widget,
98 save_widget: save_widget,
@@ -138,7 +138,7 b' require(['
138 IPython.page = page;
138 IPython.page = page;
139 IPython.layout_manager = layout_manager;
139 IPython.layout_manager = layout_manager;
140 IPython.notebook = notebook;
140 IPython.notebook = notebook;
141 IPython.content_manager = content_manager;
141 IPython.contents = contents;
142 IPython.pager = pager;
142 IPython.pager = pager;
143 IPython.quick_help = quick_help;
143 IPython.quick_help = quick_help;
144 IPython.login_widget = login_widget;
144 IPython.login_widget = login_widget;
@@ -21,7 +21,7 b' define(['
21 // options: dictionary
21 // options: dictionary
22 // Dictionary of keyword arguments.
22 // Dictionary of keyword arguments.
23 // notebook: Notebook instance
23 // notebook: Notebook instance
24 // content_manager: ContentManager instance
24 // contents: ContentManager instance
25 // layout_manager: LayoutManager instance
25 // layout_manager: LayoutManager instance
26 // events: $(Events) instance
26 // events: $(Events) instance
27 // save_widget: SaveWidget instance
27 // save_widget: SaveWidget instance
@@ -33,7 +33,7 b' define(['
33 this.base_url = options.base_url || utils.get_body_data("baseUrl");
33 this.base_url = options.base_url || utils.get_body_data("baseUrl");
34 this.selector = selector;
34 this.selector = selector;
35 this.notebook = options.notebook;
35 this.notebook = options.notebook;
36 this.content_manager = options.content_manager;
36 this.contents = options.contents;
37 this.layout_manager = options.layout_manager;
37 this.layout_manager = options.layout_manager;
38 this.events = options.events;
38 this.events = options.events;
39 this.save_widget = options.save_widget;
39 this.save_widget = options.save_widget;
@@ -89,7 +89,7 b' define(['
89 this.element.find('#new_notebook').click(function () {
89 this.element.find('#new_notebook').click(function () {
90 // Create a new notebook in the same path as the current
90 // Create a new notebook in the same path as the current
91 // notebook's path.
91 // notebook's path.
92 that.content_manager.new_notebook(that.notebook.notebook_path);
92 that.contents.new_notebook(that.notebook.notebook_path);
93 });
93 });
94 this.element.find('#open_notebook').click(function () {
94 this.element.find('#open_notebook').click(function () {
95 window.open(utils.url_join_encode(
95 window.open(utils.url_join_encode(
@@ -50,7 +50,7 b' define(['
50 // Dictionary of keyword arguments.
50 // Dictionary of keyword arguments.
51 // events: $(Events) instance
51 // events: $(Events) instance
52 // keyboard_manager: KeyboardManager instance
52 // keyboard_manager: KeyboardManager instance
53 // content_manager: ContentManager instance
53 // contents: Contents instance
54 // save_widget: SaveWidget instance
54 // save_widget: SaveWidget instance
55 // config: dictionary
55 // config: dictionary
56 // base_url : string
56 // base_url : string
@@ -62,7 +62,7 b' define(['
62 this.notebook_name = options.notebook_name;
62 this.notebook_name = options.notebook_name;
63 this.events = options.events;
63 this.events = options.events;
64 this.keyboard_manager = options.keyboard_manager;
64 this.keyboard_manager = options.keyboard_manager;
65 this.content_manager = options.content_manager;
65 this.contents = options.contents;
66 this.save_widget = options.save_widget;
66 this.save_widget = options.save_widget;
67 this.tooltip = new tooltip.Tooltip(this.events);
67 this.tooltip = new tooltip.Tooltip(this.events);
68 this.ws_url = options.ws_url;
68 this.ws_url = options.ws_url;
@@ -178,7 +178,7 b' define(['
178 Notebook.prototype.bind_events = function () {
178 Notebook.prototype.bind_events = function () {
179 var that = this;
179 var that = this;
180
180
181 this.content_manager.events.on('notebook_rename_success.ContentManager',
181 this.contents.events.on('notebook_rename_success.Contents',
182 function (event, data) {
182 function (event, data) {
183 var name = that.notebook_name = data.name;
183 var name = that.notebook_name = data.name;
184 var path = data.path;
184 var path = data.path;
@@ -186,15 +186,15 b' define(['
186 that.events.trigger('notebook_renamed.Notebook', data);
186 that.events.trigger('notebook_renamed.Notebook', data);
187 });
187 });
188
188
189 this.content_manager.events.on('notebook_rename_error.ContentManager',
189 this.contents.events.on('notebook_rename_error.Contents',
190 function (event, data) {
190 function (event, data) {
191 that.rename_error(data[0], data[1], data[2]);
191 that.rename_error(data[0], data[1], data[2]);
192 });
192 });
193
193
194 this.content_manager.events.on('notebook_save_success.ContentManager',
194 this.contents.events.on('notebook_save_success.Contents',
195 $.proxy(this.save_notebook_success, this));
195 $.proxy(this.save_notebook_success, this));
196
196
197 this.content_manager.events.on('notebook_save_error.ContentManager',
197 this.contents.events.on('notebook_save_error.Contents',
198 $.proxy(this.events.trigger, this.events,
198 $.proxy(this.events.trigger, this.events,
199 'notebook_save_failed.Notebook'));
199 'notebook_save_failed.Notebook'));
200
200
@@ -1929,7 +1929,7 b' define(['
1929 nbformat : this.nbformat,
1929 nbformat : this.nbformat,
1930 nbformat_minor : this.nbformat_minor
1930 nbformat_minor : this.nbformat_minor
1931 })
1931 })
1932 this.content_manager.save_notebook(this.notebook_path,
1932 this.contents.save_notebook(this.notebook_path,
1933 this.notebook_name,
1933 this.notebook_name,
1934 content,
1934 content,
1935 extra_settings);
1935 extra_settings);
@@ -2092,12 +2092,12 b' define(['
2092 nbname = nbname + ".ipynb";
2092 nbname = nbname + ".ipynb";
2093 }
2093 }
2094
2094
2095 this.content_manager.rename_notebook(this.notebook_path,
2095 this.contents.rename_notebook(this.notebook_path,
2096 this.notebook_name, nbname);
2096 this.notebook_name, nbname);
2097 };
2097 };
2098
2098
2099 Notebook.prototype.delete = function () {
2099 Notebook.prototype.delete = function () {
2100 this.content_manager.delete_notebook(this.notebook_name,
2100 this.contents.delete_notebook(this.notebook_name,
2101 this.notebook_path);
2101 this.notebook_path);
2102 };
2102 };
2103
2103
@@ -2142,7 +2142,7 b' define(['
2142 Notebook.prototype.load_notebook = function (notebook_name, notebook_path) {
2142 Notebook.prototype.load_notebook = function (notebook_name, notebook_path) {
2143 this.notebook_name = notebook_name;
2143 this.notebook_name = notebook_name;
2144 this.notebook_path = notebook_path;
2144 this.notebook_path = notebook_path;
2145 this.content_manager.load_notebook(
2145 this.contents.load_notebook(
2146 notebook_path,
2146 notebook_path,
2147 notebook_name,
2147 notebook_name,
2148 $.proxy(this.load_notebook_success,this),
2148 $.proxy(this.load_notebook_success,this),
@@ -7,7 +7,7 b' require(['
7 'base/js/events',
7 'base/js/events',
8 'base/js/page',
8 'base/js/page',
9 'base/js/utils',
9 'base/js/utils',
10 'contentmanager',
10 'contents',
11 'tree/js/notebooklist',
11 'tree/js/notebooklist',
12 'tree/js/clusterlist',
12 'tree/js/clusterlist',
13 'tree/js/sessionlist',
13 'tree/js/sessionlist',
@@ -24,7 +24,7 b' require(['
24 events,
24 events,
25 page,
25 page,
26 utils,
26 utils,
27 contentmanager,
27 contents,
28 notebooklist,
28 notebooklist,
29 clusterlist,
29 clusterlist,
30 sesssionlist,
30 sesssionlist,
@@ -41,11 +41,11 b' require(['
41 session_list = new sesssionlist.SesssionList($.extend({
41 session_list = new sesssionlist.SesssionList($.extend({
42 events: events},
42 events: events},
43 common_options));
43 common_options));
44 content_manager = new contentmanager.ContentManager($.extend({
44 contents = new contents.Contents($.extend({
45 events: events},
45 events: events},
46 common_options));
46 common_options));
47 notebook_list = new notebooklist.NotebookList('#notebook_list', $.extend({
47 notebook_list = new notebooklist.NotebookList('#notebook_list', $.extend({
48 content_manager: content_manager,
48 contents: contents,
49 session_list: session_list},
49 session_list: session_list},
50 common_options));
50 common_options));
51 cluster_list = new clusterlist.ClusterList('#cluster_list', common_options);
51 cluster_list = new clusterlist.ClusterList('#cluster_list', common_options);
@@ -60,7 +60,7 b' require(['
60 login_widget = new loginwidget.LoginWidget('#login_widget', common_options);
60 login_widget = new loginwidget.LoginWidget('#login_widget', common_options);
61
61
62 $('#new_notebook').button().click(function (e) {
62 $('#new_notebook').button().click(function (e) {
63 content_manager.new_notebook(common_options.notebook_path);
63 contents.new_notebook(common_options.notebook_path);
64 });
64 });
65
65
66 var interval_id=0;
66 var interval_id=0;
@@ -127,7 +127,7 b' require(['
127
127
128 // For backwards compatability.
128 // For backwards compatability.
129 IPython.page = page;
129 IPython.page = page;
130 IPython.content_manager = content_manager;
130 IPython.contents = contents;
131 IPython.notebook_list = notebook_list;
131 IPython.notebook_list = notebook_list;
132 IPython.cluster_list = cluster_list;
132 IPython.cluster_list = cluster_list;
133 IPython.session_list = session_list;
133 IPython.session_list = session_list;
@@ -20,7 +20,7 b' define(['
20 // element_name: string
20 // element_name: string
21 // base_url: string
21 // base_url: string
22 // notebook_path: string
22 // notebook_path: string
23 // content_manager: ContentManager instance
23 // contents: Contents instance
24 var that = this;
24 var that = this;
25 this.session_list = options.session_list;
25 this.session_list = options.session_list;
26 // allow code re-use by just changing element_name in kernellist.js
26 // allow code re-use by just changing element_name in kernellist.js
@@ -35,15 +35,15 b' define(['
35 this.sessions = {};
35 this.sessions = {};
36 this.base_url = options.base_url || utils.get_body_data("baseUrl");
36 this.base_url = options.base_url || utils.get_body_data("baseUrl");
37 this.notebook_path = options.notebook_path || utils.get_body_data("notebookPath");
37 this.notebook_path = options.notebook_path || utils.get_body_data("notebookPath");
38 this.content_manager = options.content_manager;
38 this.contents = options.contents;
39 if (this.session_list && this.session_list.events) {
39 if (this.session_list && this.session_list.events) {
40 this.session_list.events.on('sessions_loaded.Dashboard',
40 this.session_list.events.on('sessions_loaded.Dashboard',
41 function(e, d) { that.sessions_loaded(d); });
41 function(e, d) { that.sessions_loaded(d); });
42 }
42 }
43
43
44
44
45 if (this.content_manager && this.content_manager.events) {
45 if (this.contents && this.contents.events) {
46 this.content_manager.events.on('notebook_deleted.ContentManager',
46 this.contents.events.on('notebook_deleted.Contents',
47 function(e, d) {
47 function(e, d) {
48 // Remove the deleted notebook.
48 // Remove the deleted notebook.
49 $( ":data(nbname)" ).each(function() {
49 $( ":data(nbname)" ).each(function() {
@@ -157,7 +157,7 b' define(['
157
157
158 NotebookList.prototype.load_list = function () {
158 NotebookList.prototype.load_list = function () {
159 var that = this
159 var that = this
160 this.content_manager.list_contents(
160 this.contents.list_contents(
161 that.notebook_path,
161 that.notebook_path,
162 $.proxy(that.draw_notebook_list, that),
162 $.proxy(that.draw_notebook_list, that),
163 $.proxy( function(xhr, status, error) {
163 $.proxy( function(xhr, status, error) {
@@ -347,7 +347,7 b' define(['
347 Delete : {
347 Delete : {
348 class: "btn-danger",
348 class: "btn-danger",
349 click: function() {
349 click: function() {
350 notebooklist.content_manager.delete_notebook(nbname, path);
350 notebooklist.contents.delete_notebook(nbname, path);
351 }
351 }
352 },
352 },
353 Cancel : {}
353 Cancel : {}
@@ -30,7 +30,7 b''
30 moment: "components/moment/moment",
30 moment: "components/moment/moment",
31 codemirror: 'components/codemirror',
31 codemirror: 'components/codemirror',
32 termjs: "components/term.js/src/term"
32 termjs: "components/term.js/src/term"
33 contentmanager: '{{ contentmanager_js_source }}',
33 contents: '{{ contents_js_source }}',
34 },
34 },
35 shim: {
35 shim: {
36 underscore: {
36 underscore: {
General Comments 0
You need to be logged in to leave comments. Login now