Dynamically load contents, also browserify contents.

This commit is contained in:
Jonathan Frederic 2015-08-12 10:51:13 -07:00
parent c180719fa8
commit 81a2998fe0
9 changed files with 23 additions and 60 deletions

1
.gitignore vendored
View File

@ -32,6 +32,7 @@ src
notebook/static/auth/js/main.bundle.js
notebook/static/edit/js/main.bundle.js
notebook/static/notebook/js/main.bundle.js
notebook/static/services/contents.bundle.js
notebook/static/terminal/js/main.bundle.js
notebook/static/tree/js/main.bundle.js

View File

@ -172,8 +172,8 @@ class IPythonHandler(AuthenticatedHandler):
@property
def contents_js_source(self):
self.log.debug("Using contents: %s", self.settings.get('contents_js_source',
'services/contents'))
return self.settings.get('contents_js_source', 'services/contents')
'services/contents.bundle'))
return self.settings.get('contents_js_source', 'services/contents.bundle')
#---------------------------------------------------------------
# Manager objects

View File

@ -26,6 +26,5 @@ var b = browserify({
});
b.transform(aliasify, aliasifyConfig);
b.exclude('contents');
b.add(__dirname + '/static/' + process.argv[2]);
b.bundle().pipe(fs.createWriteStream(__dirname + '/static/' + process.argv[3]));

View File

@ -15,7 +15,7 @@
*/
var load_extension = function (extension) {
return new Promise(function(resolve, reject) {
require(["nbextensions/" + extension], function(module) {
requirejs(["nbextensions/" + extension], function(module) {
console.log("Loaded extension: " + extension);
try {
module.load_ipython_extension();

View File

@ -1,13 +1,14 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
"use strict";
"use strict";
// Contents must be loaded at runtime.
requirejs(['contents'], function(contents_service) {
var $ = require('jquery');
var IPython = require('base/js/namespace');
var utils = require('base/js/utils');
var page = require('base/js/page');
var events = require('base/js/events');
var contents = require('contents');
var configmod = require('services/config');
var editmod = require('edit/js/editor');
var menubar = require('edit/js/menubar');
@ -81,3 +82,4 @@
// On document ready, resize codemirror.
$(document).ready(_handle_resize);
});

View File

@ -1,58 +1,12 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
"use strict";
require([
'base/js/namespace',
'jquery',
'notebook/js/notebook',
'contents',
'services/config',
'base/js/utils',
'base/js/page',
'base/js/events',
'auth/js/loginwidget',
'notebook/js/maintoolbar',
'notebook/js/pager',
'notebook/js/quickhelp',
'notebook/js/menubar',
'notebook/js/notificationarea',
'notebook/js/savewidget',
'notebook/js/actions',
'notebook/js/keyboardmanager',
'notebook/js/kernelselector',
'codemirror/lib/codemirror',
'notebook/js/about',
'typeahead',
require([
'base/js/namespace',
'jquery',
'notebook/js/notebook',
'contents',
'services/config',
'base/js/utils',
'base/js/page',
'base/js/events',
'auth/js/loginwidget',
'notebook/js/maintoolbar',
'notebook/js/pager',
'notebook/js/quickhelp',
'notebook/js/menubar',
'notebook/js/notificationarea',
'notebook/js/savewidget',
'notebook/js/actions',
'notebook/js/keyboardmanager',
'notebook/js/kernelselector',
'codemirror/lib/codemirror',
'notebook/js/about',
'typeahead',
'notebook/js/searchandreplace',
"use strict";
// Contents must be loaded at runtime.
requirejs(['contents'], function(contents_service) {
var IPython = require('base/js/namespace');
var $ = require('jquery');
var notebook = require('notebook/js/notebook');
var contents = require('contents');
var configmod = require('services/config');
var utils = require('base/js/utils');
var page = require('base/js/page');
@ -187,3 +141,4 @@ require([
utils.load_extensions_from_config(config_section);
utils.load_extensions_from_config(common_config);
notebook.load_notebook(common_options.notebook_path);
});

View File

@ -251,3 +251,5 @@
};
exports.Contents = Contents;
window.define([], function() { return {Contents: Contents}; })

View File

@ -1,6 +1,9 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
"use strict";
"use strict";
// Contents must be loaded at runtime.
requirejs(['contents'], function(contents_service) {
var $ = require('jquery');
var IPython = require('base/js/namespace');
@ -9,7 +12,6 @@
var page = require('base/js/page');
var utils = require('base/js/utils');
var config = require('services/config');
var contents_service = require('contents');
var notebooklist = require('tree/js/notebooklist');
var sesssionlist = require('tree/js/sessionlist');
var kernellist = require('tree/js/kernellist');
@ -20,7 +22,7 @@
require('jqueryui');
require('bootstrap');
require('custom/custom');
IPython.NotebookList = notebooklist.NotebookList;
page = new page.Page();
@ -158,3 +160,4 @@
if (window.location.hash) {
$("#tabs").find("a[href=" + window.location.hash + "]").click();
}
});

View File

@ -15,8 +15,9 @@
"build:css": "concurrent \"npm run build:css:ipython\" \"npm run build:css:style\"",
"build:css:ipython": "lessc --source-map --include-path=./notebook/static/ ./notebook/static/style/ipython.less ./notebook/static/style/ipython.min.css",
"build:css:style": "lessc --source-map --include-path=./notebook/static/ ./notebook/static/style/style.less ./notebook/static/style/style.min.css",
"build:js": "concurrent \"npm run build:js:tree\" \"npm run build:js:terminal\" \"npm run build:js:notebook\" \"npm run build:js:edit\" \"npm run build:js:auth\"",
"build:js": "concurrent \"npm run build:js:tree\" \"npm run build:js:terminal\" \"npm run build:js:notebook\" \"npm run build:js:edit\" \"npm run build:js:auth\" \"npm run build:js:contents\"",
"build:js:notebook": "node ./notebook/build.js notebook/js/main.js notebook/js/main.bundle.js",
"build:js:contents": "node ./notebook/build.js services/contents.js services/contents.bundle.js",
"build:js:edit": "node ./notebook/build.js edit/js/main.js edit/js/main.bundle.js",
"build:js:tree": "node ./notebook/build.js tree/js/main.js tree/js/main.bundle.js",
"build:js:auth": "node ./notebook/build.js auth/js/main.js auth/js/main.bundle.js",