diff --git a/.gitignore b/.gitignore index 6397bfe93..af4aaade4 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/notebook/base/handlers.py b/notebook/base/handlers.py index 75805955c..cd3241fad 100644 --- a/notebook/base/handlers.py +++ b/notebook/base/handlers.py @@ -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 diff --git a/notebook/build.js b/notebook/build.js index 63e79182a..2e885e008 100644 --- a/notebook/build.js +++ b/notebook/build.js @@ -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])); diff --git a/notebook/static/base/js/utils.js b/notebook/static/base/js/utils.js index 67a090403..0a1ac5c28 100644 --- a/notebook/static/base/js/utils.js +++ b/notebook/static/base/js/utils.js @@ -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(); diff --git a/notebook/static/edit/js/main.js b/notebook/static/edit/js/main.js index 8ff17620a..eac072379 100644 --- a/notebook/static/edit/js/main.js +++ b/notebook/static/edit/js/main.js @@ -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); +}); diff --git a/notebook/static/notebook/js/main.js b/notebook/static/notebook/js/main.js index e681cdfce..c5b17503b 100644 --- a/notebook/static/notebook/js/main.js +++ b/notebook/static/notebook/js/main.js @@ -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); +}); diff --git a/notebook/static/services/contents.js b/notebook/static/services/contents.js index a1c5fe1c7..8f9bc7f45 100644 --- a/notebook/static/services/contents.js +++ b/notebook/static/services/contents.js @@ -251,3 +251,5 @@ }; exports.Contents = Contents; + + window.define([], function() { return {Contents: Contents}; }) diff --git a/notebook/static/tree/js/main.js b/notebook/static/tree/js/main.js index 644ffd7df..ec9ea6c36 100644 --- a/notebook/static/tree/js/main.js +++ b/notebook/static/tree/js/main.js @@ -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(); } +}); diff --git a/package.json b/package.json index 9190cac87..c40b83a69 100644 --- a/package.json +++ b/package.json @@ -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",