##// END OF EJS Templates
Merge pull request #7263 from takluyver/nb-common-config...
Min RK -
r20023:982ae339 merge
parent child Browse files
Show More
@@ -11,7 +11,7 b' define(['
11 ], function(IPython, $, CodeMirror, moment){
11 ], function(IPython, $, CodeMirror, moment){
12 "use strict";
12 "use strict";
13
13
14 IPython.load_extensions = function () {
14 var load_extensions = function () {
15 // load one or more IPython notebook extensions with requirejs
15 // load one or more IPython notebook extensions with requirejs
16
16
17 var extensions = [];
17 var extensions = [];
@@ -38,6 +38,22 b' define(['
38 }
38 }
39 );
39 );
40 };
40 };
41
42 IPython.load_extensions = load_extensions;
43
44 /**
45 * Wait for a config section to load, and then load the extensions specified
46 * in a 'load_extensions' key inside it.
47 */
48 function load_extensions_from_config(section) {
49 section.loaded.then(function() {
50 if (section.data.load_extensions) {
51 var nbextension_paths = Object.getOwnPropertyNames(
52 section.data.load_extensions);
53 load_extensions.apply(this, nbextension_paths);
54 }
55 });
56 }
41
57
42 //============================================================================
58 //============================================================================
43 // Cross-browser RegEx Split
59 // Cross-browser RegEx Split
@@ -822,6 +838,8 b' define(['
822 };
838 };
823
839
824 var utils = {
840 var utils = {
841 load_extensions: load_extensions,
842 load_extensions_from_config: load_extensions_from_config,
825 regex_split : regex_split,
843 regex_split : regex_split,
826 uuid : uuid,
844 uuid : uuid,
827 fixConsole : fixConsole,
845 fixConsole : fixConsole,
@@ -32,6 +32,8 b' require(['
32 contents = new contents.Contents({base_url: base_url});
32 contents = new contents.Contents({base_url: base_url});
33 var config = new configmod.ConfigSection('edit', {base_url: base_url});
33 var config = new configmod.ConfigSection('edit', {base_url: base_url});
34 config.load();
34 config.load();
35 var common_config = new configmod.ConfigSection('common', {base_url: base_url});
36 common_config.load();
35
37
36 var editor = new editmod.Editor('#texteditor-container', {
38 var editor = new editmod.Editor('#texteditor-container', {
37 base_url: base_url,
39 base_url: base_url,
@@ -62,13 +64,8 b' require(['
62 });
64 });
63 notification_area.init_notification_widgets();
65 notification_area.init_notification_widgets();
64
66
65 config.loaded.then(function() {
67 utils.load_extensions_from_config(config);
66 if (config.data.load_extensions) {
68 utils.load_extensions_from_config(common_config);
67 var nbextension_paths = Object.getOwnPropertyNames(
68 config.data.load_extensions);
69 IPython.load_extensions.apply(this, nbextension_paths);
70 }
71 });
72 editor.load();
69 editor.load();
73 page.show();
70 page.show();
74
71
@@ -62,6 +62,8 b' require(['
62
62
63 var config_section = new configmod.ConfigSection('notebook', common_options);
63 var config_section = new configmod.ConfigSection('notebook', common_options);
64 config_section.load();
64 config_section.load();
65 var common_config = new configmod.ConfigSection('common', common_options);
66 common_config.load();
65 var page = new page.Page();
67 var page = new page.Page();
66 var pager = new pager.Pager('div#pager', {
68 var pager = new pager.Pager('div#pager', {
67 events: events});
69 events: events});
@@ -150,13 +152,8 b' require(['
150 IPython.tooltip = notebook.tooltip;
152 IPython.tooltip = notebook.tooltip;
151
153
152 events.trigger('app_initialized.NotebookApp');
154 events.trigger('app_initialized.NotebookApp');
153 config_section.loaded.then(function() {
155 utils.load_extensions_from_config(config_section);
154 if (config_section.data.load_extensions) {
156 utils.load_extensions_from_config(common_config);
155 var nbextension_paths = Object.getOwnPropertyNames(
156 config_section.data.load_extensions);
157 IPython.load_extensions.apply(this, nbextension_paths);
158 }
159 });
160 notebook.load_notebook(common_options.notebook_path);
157 notebook.load_notebook(common_options.notebook_path);
161
158
162 });
159 });
@@ -6,6 +6,7 b' require(['
6 'termjs',
6 'termjs',
7 'base/js/utils',
7 'base/js/utils',
8 'base/js/page',
8 'base/js/page',
9 'services/config',
9 'terminal/js/terminado',
10 'terminal/js/terminado',
10 'custom/custom',
11 'custom/custom',
11 ], function(
12 ], function(
@@ -13,10 +14,16 b' require(['
13 termjs,
14 termjs,
14 utils,
15 utils,
15 page,
16 page,
17 configmod,
16 terminado
18 terminado
17 ){
19 ){
18 "use strict";
20 "use strict";
19 page = new page.Page();
21 page = new page.Page();
22
23 var common_config = new configmod.ConfigSection('common',
24 {base_url: utils.get_body_data('baseUrl')});
25 common_config.load();
26
20 // Test size: 25x80
27 // Test size: 25x80
21 var termRowHeight = function(){ return 1.00 * $("#dummy-screen")[0].offsetHeight / 25;};
28 var termRowHeight = function(){ return 1.00 * $("#dummy-screen")[0].offsetHeight / 25;};
22 // 1.02 here arrived at by trial and error to make the spacing look right
29 // 1.02 here arrived at by trial and error to make the spacing look right
@@ -44,6 +51,8 b' require(['
44
51
45 page.show_site();
52 page.show_site();
46
53
54 utils.load_extensions_from_config(common_config);
55
47 window.onresize = function() {
56 window.onresize = function() {
48 var geom = calculate_size();
57 var geom = calculate_size();
49 terminal.term.resize(geom.cols, geom.rows);
58 terminal.term.resize(geom.cols, geom.rows);
@@ -48,6 +48,8 b' require(['
48 var cfg = new config.ConfigSection('tree', common_options);
48 var cfg = new config.ConfigSection('tree', common_options);
49 cfg.load();
49 cfg.load();
50 common_options.config = cfg;
50 common_options.config = cfg;
51 var common_config = new config.ConfigSection('common', common_options);
52 common_config.load();
51
53
52 var session_list = new sesssionlist.SesssionList($.extend({
54 var session_list = new sesssionlist.SesssionList($.extend({
53 events: events},
55 events: events},
@@ -133,6 +135,8 b' require(['
133 IPython.new_notebook_widget = new_buttons;
135 IPython.new_notebook_widget = new_buttons;
134
136
135 events.trigger('app_initialized.DashboardApp');
137 events.trigger('app_initialized.DashboardApp');
138 utils.load_extensions_from_config(cfg);
139 utils.load_extensions_from_config(common_config);
136
140
137 // bound the upload method to the on change of the file select list
141 // bound the upload method to the on change of the file select list
138 $("#alternate_upload").change(function (event){
142 $("#alternate_upload").change(function (event){
General Comments 0
You need to be logged in to leave comments. Login now