Merge pull request #7263 from takluyver/nb-common-config

Add common config section for frontend config
Min RK 11 years ago
commit 4335486bdc

@ -11,7 +11,7 @@ define([
], function(IPython, $, CodeMirror, moment){
"use strict";
IPython.load_extensions = function () {
var load_extensions = function () {
// load one or more IPython notebook extensions with requirejs
var extensions = [];
@ -38,6 +38,22 @@ define([
}
);
};
IPython.load_extensions = load_extensions;
/**
* Wait for a config section to load, and then load the extensions specified
* in a 'load_extensions' key inside it.
*/
function load_extensions_from_config(section) {
section.loaded.then(function() {
if (section.data.load_extensions) {
var nbextension_paths = Object.getOwnPropertyNames(
section.data.load_extensions);
load_extensions.apply(this, nbextension_paths);
}
});
}
//============================================================================
// Cross-browser RegEx Split
@ -822,6 +838,8 @@ define([
};
var utils = {
load_extensions: load_extensions,
load_extensions_from_config: load_extensions_from_config,
regex_split : regex_split,
uuid : uuid,
fixConsole : fixConsole,

@ -32,6 +32,8 @@ require([
contents = new contents.Contents({base_url: base_url});
var config = new configmod.ConfigSection('edit', {base_url: base_url});
config.load();
var common_config = new configmod.ConfigSection('common', {base_url: base_url});
common_config.load();
var editor = new editmod.Editor('#texteditor-container', {
base_url: base_url,
@ -62,13 +64,8 @@ require([
});
notification_area.init_notification_widgets();
config.loaded.then(function() {
if (config.data.load_extensions) {
var nbextension_paths = Object.getOwnPropertyNames(
config.data.load_extensions);
IPython.load_extensions.apply(this, nbextension_paths);
}
});
utils.load_extensions_from_config(config);
utils.load_extensions_from_config(common_config);
editor.load();
page.show();

@ -62,6 +62,8 @@ require([
var config_section = new configmod.ConfigSection('notebook', common_options);
config_section.load();
var common_config = new configmod.ConfigSection('common', common_options);
common_config.load();
var page = new page.Page();
var pager = new pager.Pager('div#pager', {
events: events});
@ -150,13 +152,8 @@ require([
IPython.tooltip = notebook.tooltip;
events.trigger('app_initialized.NotebookApp');
config_section.loaded.then(function() {
if (config_section.data.load_extensions) {
var nbextension_paths = Object.getOwnPropertyNames(
config_section.data.load_extensions);
IPython.load_extensions.apply(this, nbextension_paths);
}
});
utils.load_extensions_from_config(config_section);
utils.load_extensions_from_config(common_config);
notebook.load_notebook(common_options.notebook_path);
});

@ -6,6 +6,7 @@ require([
'termjs',
'base/js/utils',
'base/js/page',
'services/config',
'terminal/js/terminado',
'custom/custom',
], function(
@ -13,10 +14,16 @@ require([
termjs,
utils,
page,
configmod,
terminado
){
"use strict";
page = new page.Page();
var common_config = new configmod.ConfigSection('common',
{base_url: utils.get_body_data('baseUrl')});
common_config.load();
// Test size: 25x80
var termRowHeight = function(){ return 1.00 * $("#dummy-screen")[0].offsetHeight / 25;};
// 1.02 here arrived at by trial and error to make the spacing look right
@ -44,6 +51,8 @@ require([
page.show_site();
utils.load_extensions_from_config(common_config);
window.onresize = function() {
var geom = calculate_size();
terminal.term.resize(geom.cols, geom.rows);

@ -48,6 +48,8 @@ require([
var cfg = new config.ConfigSection('tree', common_options);
cfg.load();
common_options.config = cfg;
var common_config = new config.ConfigSection('common', common_options);
common_config.load();
var session_list = new sesssionlist.SesssionList($.extend({
events: events},
@ -133,6 +135,8 @@ require([
IPython.new_notebook_widget = new_buttons;
events.trigger('app_initialized.DashboardApp');
utils.load_extensions_from_config(cfg);
utils.load_extensions_from_config(common_config);
// bound the upload method to the on change of the file select list
$("#alternate_upload").change(function (event){

Loading…
Cancel
Save