Merge pull request #1047 from jdfreder/webpack

use webpack
This commit is contained in:
Min RK 2016-02-24 08:52:35 +01:00
commit a1458ce8fc
76 changed files with 701 additions and 355 deletions

4
.gitignore vendored
View File

@ -8,7 +8,9 @@ docs/source/config.rst
docs/gh-pages
notebook/static/components
notebook/static/style/*.min.css*
notebook/static/*/js/main.min.js*
notebook/static/*/js/built/
notebook/static/*/built/
notebook/static/built/
node_modules
*.py[co]
__pycache__

View File

@ -7,7 +7,7 @@ cache:
python:
- 3.5.1 # Set to 3.5.1 since travis has not yet included as default for 3.5
- 2.7
sudo: false
env:
@ -19,16 +19,19 @@ env:
- GROUP=js/notebook
- GROUP=js/services
- GROUP=js/tree
before_install:
- pip install --upgrade pip
- pip install --upgrade setuptools wheel nose coverage codecov
- 'if [[ $GROUP == js* ]]; then npm install -g casperjs; fi'
- nvm install 5.6
- nvm use 5.6
- npm upgrade -g npm
- 'if [[ $GROUP == js* ]]; then npm install -g casperjs; fi'
- git clone --quiet --depth 1 https://github.com/minrk/travis-wheels travis-wheels
install:
- pip install -f travis-wheels/wheelhouse file://$PWD#egg=notebook[test]
script:
- 'if [[ $GROUP == js* ]]; then python -m notebook.jstest ${GROUP:3}; fi'
- 'if [[ $GROUP == python ]]; then nosetests -v --with-coverage --cover-package=notebook notebook; fi'
@ -39,6 +42,6 @@ matrix:
env: GROUP=python
- python: 3.4
env: GROUP=python
after_success:
- codecov
- codecov

View File

@ -16,13 +16,11 @@ To install the static dependencies, run:
You can also pass a `-f` flag to this command to force Bower to run, if necessary.
### Minified JavaScript
### JavaScript
To compile the minified JavaScript, run:
To compile the JavaScript, run:
python setup.py js
You can also run the notebook server without relying on the minified JavaScript by passing the `--NotebookApp.ignore_minified_js=True` flag when launching the notebook.
npm run build:js
### Compiling CSS

View File

@ -54,12 +54,9 @@ Prototyping tip
---------------
When doing prototyping which needs quick iteration of the Notebook's
JavaScript, the bundled and minified JavaScript may be deactivated. To do
this, start the Notebook with the option
``--NotebookApp.ignore_minified_js=True``. This increases
the number of requests that the browser makes to the server, but it allows
testing JavaScript file modification without going through the time consuming
compilation step that may take up to 30 seconds.
JavaScript, run `npm run build:watch` in the root of the repository.
This will cause WebPack to monitor the files you edit and recompile
them on the fly.
.. _Node.js: https://nodejs.org

View File

@ -118,7 +118,6 @@ class IPythonHandler(AuthenticatedHandler):
Mostly property shortcuts to IPython-specific settings.
"""
@property
def ignore_minified_js(self):
"""Wether to user bundle in template. (*.min files)
@ -175,8 +174,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/built/contents'))
return self.settings.get('contents_js_source', 'services/built/contents')
#---------------------------------------------------------------
# Manager objects
@ -314,7 +313,6 @@ class IPythonHandler(AuthenticatedHandler):
sys_info=sys_info,
contents_js_source=self.contents_js_source,
version_hash=self.version_hash,
ignore_minified_js=self.ignore_minified_js,
**self.jinja_template_vars
)

View File

@ -20,6 +20,7 @@ import signal
import socket
import sys
import threading
import warnings
import webbrowser
try: #PY3
@ -97,6 +98,15 @@ jupyter notebook # start the notebook
jupyter notebook --certfile=mycert.pem # use SSL/TLS certificate
"""
DEV_NOTE_NPM = """It looks like you're running the notebook from source.
If you're working on the Javascript of the notebook, try running
npm run build:watch
in another terminal window to have the system incrementally
watch and build the notebook's JavaScript for you, as you make changes.
"""
#-----------------------------------------------------------------------------
# Helper functions
#-----------------------------------------------------------------------------
@ -139,6 +149,13 @@ class NotebookWebApplication(web.Application):
config_manager, log,
base_url, default_url, settings_overrides, jinja_env_options):
# If the user is running the notebook in a git directory, make the assumption
# that this is a dev install and suggest to the developer `npm run build:watch`.
base_dir = os.path.realpath(os.path.join(__file__, '..', '..'))
dev_mode = os.path.exists(os.path.join(base_dir, '.git'))
if dev_mode:
log.info(DEV_NOTE_NPM)
settings = self.init_settings(
ipython_app, kernel_manager, contents_manager,
session_manager, kernel_spec_manager, config_manager, log, base_url,
@ -174,6 +191,12 @@ class NotebookWebApplication(web.Application):
# reset the cache on server restart
version_hash = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
if ipython_app.ignore_minified_js:
log.warn("""The `ignore_minified_js` flag is deprecated and no
longer works. Alternatively use `npm run build:watch` when
working on the notebook's Javascript and LESS""")
warnings.warn("The `ignore_minified_js` flag is deprecated and will be removed in Notebook 6.0", DeprecationWarning)
settings = dict(
# basics
log_function=log_request,
@ -190,7 +213,7 @@ class NotebookWebApplication(web.Application):
},
version_hash=version_hash,
ignore_minified_js=ipython_app.ignore_minified_js,
# rate limits
iopub_msg_rate_limit=ipython_app.iopub_msg_rate_limit,
iopub_data_rate_limit=ipython_app.iopub_data_rate_limit,
@ -416,7 +439,7 @@ class NotebookApp(JupyterApp):
ignore_minified_js = Bool(False,
config=True,
help='Use minified JS file or not, mainly use during dev to avoid JS recompilation',
help='Deprecated: Use minified JS file or not, mainly use during dev to avoid JS recompilation',
)
# file to be opened in the notebook server

View File

@ -3,8 +3,7 @@
define([
'base/js/utils',
'jquery',
], function(utils, $){
], function(utils){
"use strict";
var LoginWidget = function (selector, options) {

View File

@ -1,5 +1,6 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
__webpack_public_path__ = window['staticURL'] + 'auth/js/built/';
define(['./loginmain', './logoutmain'], function (login_main, logout_main) {
return {

View File

@ -5,9 +5,6 @@ define(function(require) {
"use strict";
var CodeMirror = require('codemirror/lib/codemirror');
var $ = require('jquery');
// bootstrap is required for calling .modal(...) on elements
require('bootstrap');
/**
* A wrapper around bootstrap modal for easier use

View File

@ -9,16 +9,18 @@
// events.on("event.Namespace", function () { do_stuff(); });
// });
define(['base/js/namespace', 'jquery'], function(IPython, $) {
define(['base/js/namespace'], function(Jupyter) {
"use strict";
var Events = function () {};
var events = new Events();
// Events singleton
if (!window._Events) {
window._Events = function () {};
window._events = new window._Events();
}
// Backwards compatability.
IPython.Events = Events;
IPython.events = events;
Jupyter.Events = window._Events;
Jupyter.events = window._events;
return $([events]);
return $([window._events]);
});

11
notebook/static/base/js/jquery.js vendored Normal file
View File

@ -0,0 +1,11 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
// TODO: Remove me in 6.0!
define([], function() {
console.warn(['Importing jquery and associated libraries, such as',
'bootstrap, is deprecated. This functionality will be remove in the',
'notebook 6.0 in favor of a fully loaded jQuery global'].join(' '));
return window.$;
});

View File

@ -9,10 +9,9 @@
*/
define([
'jquery',
'base/js/utils',
'underscore',
], function($, utils, _) {
], function(utils, _) {
"use strict";

View File

@ -2,76 +2,79 @@
// Distributed under the terms of the Modified BSD License.
var Jupyter = Jupyter || {};
var Jupyter;
if (typeof window !== 'undefined') {
Jupyter = window['Jupyter'] = window['Jupyter'] || {};
} else {
Jupyter = Jupyter || {};
}
var jprop = function(name, module_path){
var jprop = function(name, loadedModule, modulePath){
Object.defineProperty(Jupyter, name, {
get: function() {
console.warn('accessing `'+name+'` is deprecated. Use `require("'+module_path+'")`');
return require(module_path);
console.warn('accessing `'+name+'` is deprecated. Use `require("'+modulePath+'")`');
return loadedModule;
},
enumerable: true,
configurable: false
});
}
};
var jglobal = function(name, module_path){
var jglobal = function(name, loadedModule, modulePath){
Object.defineProperty(Jupyter, name, {
get: function() {
console.warn('accessing `'+name+'` is deprecated. Use `require("'+module_path+'").'+name+'`');
return require(module_path)[name];
console.warn('accessing `'+name+'` is deprecated. Use `require("'+modulePath+'").'+name+'`');
return loadedModule[name];
},
enumerable: true,
configurable: false
});
}
};
define(function(){
"use strict";
// expose modules
jprop('utils','base/js/utils')
//Jupyter.load_extensions = Jupyter.utils.load_extensions;
//
jprop('security','base/js/security');
jprop('keyboard','base/js/keyboard');
jprop('dialog','base/js/dialog');
jprop('mathjaxutils','notebook/js/mathjaxutils');
if (!Jupyter.hasOwnProperty('utils')) jprop('utils',require('base/js/utils'), 'base/js/utils');
if (!Jupyter.hasOwnProperty('security')) jprop('security',require('base/js/security'), 'base/js/security');
if (!Jupyter.hasOwnProperty('keyboard')) jprop('keyboard',require('base/js/keyboard'), 'base/js/keyboard');
if (!Jupyter.hasOwnProperty('dialog')) jprop('dialog',require('base/js/dialog'), 'base/js/dialog');
if (!Jupyter.hasOwnProperty('mathjaxutils')) jprop('mathjaxutils',require('notebook/js/mathjaxutils'), 'notebook/js/mathjaxutils');
//// exposed constructors
jglobal('CommManager','services/kernels/comm')
jglobal('Comm','services/kernels/comm')
if (!Jupyter.hasOwnProperty('CommManager')) jglobal('CommManager',require('services/kernels/comm'), 'services/kernels/comm');
if (!Jupyter.hasOwnProperty('Comm')) jglobal('Comm',require('services/kernels/comm'), 'services/kernels/comm');
jglobal('NotificationWidget','base/js/notificationwidget');
jglobal('Kernel','services/kernels/kernel');
jglobal('Session','services/sessions/session');
jglobal('LoginWidget','auth/js/loginwidget');
jglobal('Page','base/js/page');
if (!Jupyter.hasOwnProperty('NotificationWidget')) jglobal('NotificationWidget',require('base/js/notificationwidget'), 'base/js/notificationwidget');
if (!Jupyter.hasOwnProperty('Kernel')) jglobal('Kernel',require('services/kernels/kernel'), 'services/kernels/kernel');
if (!Jupyter.hasOwnProperty('Session')) jglobal('Session',require('services/sessions/session'), 'services/sessions/session');
if (!Jupyter.hasOwnProperty('LoginWidget')) jglobal('LoginWidget',require('auth/js/loginwidget'), 'auth/js/loginwidget');
if (!Jupyter.hasOwnProperty('Page')) jglobal('Page',require('base/js/page'), 'base/js/page');
// notebook
jglobal('TextCell','notebook/js/textcell');
jglobal('OutputArea','notebook/js/outputarea');
jglobal('KeyboardManager','notebook/js/keyboardmanager');
jglobal('Completer','notebook/js/completer');
jglobal('Notebook','notebook/js/notebook');
jglobal('Tooltip','notebook/js/tooltip');
jglobal('Toolbar','notebook/js/toolbar');
jglobal('SaveWidget','notebook/js/savewidget');
jglobal('Pager','notebook/js/pager');
jglobal('QuickHelp','notebook/js/quickhelp');
jglobal('MarkdownCell','notebook/js/textcell');
jglobal('RawCell','notebook/js/textcell');
jglobal('Cell','notebook/js/cell');
jglobal('MainToolBar','notebook/js/maintoolbar');
jglobal('NotebookNotificationArea','notebook/js/notificationarea');
jglobal('NotebookTour', 'notebook/js/tour');
jglobal('MenuBar', 'notebook/js/menubar');
if (!Jupyter.hasOwnProperty('TextCell')) jglobal('TextCell',require('notebook/js/textcell'), 'notebook/js/textcell');
if (!Jupyter.hasOwnProperty('OutputArea')) jglobal('OutputArea',require('notebook/js/outputarea'), 'notebook/js/outputarea');
if (!Jupyter.hasOwnProperty('KeyboardManager')) jglobal('KeyboardManager',require('notebook/js/keyboardmanager'), 'notebook/js/keyboardmanager');
if (!Jupyter.hasOwnProperty('Completer')) jglobal('Completer',require('notebook/js/completer'), 'notebook/js/completer');
if (!Jupyter.hasOwnProperty('Notebook')) jglobal('Notebook',require('notebook/js/notebook'), 'notebook/js/notebook');
if (!Jupyter.hasOwnProperty('Tooltip')) jglobal('Tooltip',require('notebook/js/tooltip'), 'notebook/js/tooltip');
if (!Jupyter.hasOwnProperty('Toolbar')) jglobal('Toolbar',require('notebook/js/toolbar'), 'notebook/js/toolbar');
if (!Jupyter.hasOwnProperty('SaveWidget')) jglobal('SaveWidget',require('notebook/js/savewidget'), 'notebook/js/savewidget');
if (!Jupyter.hasOwnProperty('Pager')) jglobal('Pager',require('notebook/js/pager'), 'notebook/js/pager');
if (!Jupyter.hasOwnProperty('QuickHelp')) jglobal('QuickHelp',require('notebook/js/quickhelp'), 'notebook/js/quickhelp');
if (!Jupyter.hasOwnProperty('MarkdownCell')) jglobal('MarkdownCell',require('notebook/js/textcell'), 'notebook/js/textcell');
if (!Jupyter.hasOwnProperty('RawCell')) jglobal('RawCell',require('notebook/js/textcell'), 'notebook/js/textcell');
if (!Jupyter.hasOwnProperty('Cell')) jglobal('Cell',require('notebook/js/cell'), 'notebook/js/cell');
if (!Jupyter.hasOwnProperty('MainToolBar')) jglobal('MainToolBar',require('notebook/js/maintoolbar'), 'notebook/js/maintoolbar');
if (!Jupyter.hasOwnProperty('NotebookNotificationArea')) jglobal('NotebookNotificationArea',require('notebook/js/notificationarea'), 'notebook/js/notificationarea');
if (!Jupyter.hasOwnProperty('NotebookTour')) jglobal('NotebookTour',require('notebook/js/tour'), 'notebook/js/tour');
if (!Jupyter.hasOwnProperty('MenuBar')) jglobal('MenuBar',require('notebook/js/menubar'), 'notebook/js/menubar');
// tree
jglobal('SessionList','tree/js/sessionlist');
if (!Jupyter.hasOwnProperty('SessionList')) jglobal('SessionList',require('tree/js/sessionlist'), 'tree/js/sessionlist');
Jupyter.version = "5.0.0.dev";
Jupyter._target = '_blank';
@ -79,4 +82,4 @@ define(function(){
});
// deprecated since 4.0, remove in 5+
var IPython = Jupyter
window['IPython'] = Jupyter;

View File

@ -2,9 +2,8 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/notificationwidget',
], function($, notificationwidget) {
], function(notificationwidget) {
"use strict";
// store reference to the NotificationWidget class

View File

@ -1,9 +1,7 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
], function($) {
define([], function() {
"use strict";
/**

View File

@ -2,9 +2,8 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/events',
], function($, events){
], function(events){
"use strict";
var Page = function () {

View File

@ -2,9 +2,8 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'components/google-caja/html-css-sanitizer-minified',
], function($, sanitize) {
], function(sanitize) {
"use strict";
var noop = function (x) { return x; };

View File

@ -0,0 +1,10 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
// TODO: Remove me in 6.0!
define([], function() {
console.warn(['Importing bootstrap tour is deprecated. This feature will',
'be remove in the notebook 6.0 in favor of the Tour global object.'].join(' '));
return window.Tour;
});

View File

@ -0,0 +1,12 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
// TODO: Remove me in 6.0!
define([], function() {
console.warn(['Importing typeahead is deprecated because it is associated',
'with a global jquery variable. This feature will be removed in the',
'notebook 6.0 in favor of a jquery global. Alternatively use',
'typeahead via `$.typeahead.`'].join(' '));
return $.typeahead;
});

View File

@ -2,12 +2,11 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'codemirror/lib/codemirror',
'moment',
// silently upgrades CodeMirror
'codemirror/mode/meta',
], function($, CodeMirror, moment){
], function(CodeMirror, moment){
"use strict";
// keep track of which extensions have been loaded already
@ -21,7 +20,7 @@ define([
var load_extension = function (extension) {
return new Promise(function(resolve, reject) {
var ext_path = "nbextensions/" + extension;
require([ext_path], function(module) {
requirejs([ext_path], function(module) {
try {
if (extensions_loaded.indexOf(ext_path) < 0) {
console.log("Loading extension: " + extension);
@ -623,7 +622,7 @@ define([
CodeMirror.findModeByMIME(modename) ||
{mode: modename, mime: modename};
require([
requirejs([
// might want to use CodeMirror.modeURL here
['codemirror/mode', info.mode, info.mode].join('/'),
], function() {
@ -710,7 +709,7 @@ define([
// Try loading the view module using require.js
if (module_name) {
require([module_name], function(module) {
requirejs([module_name], function(module) {
if (module[class_name] === undefined) {
reject(new Error('Class '+class_name+' not found in module '+module_name));
} else {

View File

@ -0,0 +1,79 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
// TODO: Remove me in notebook version 6.0
[
'edit/js/savewidget',
'edit/js/main',
'edit/js/menubar',
'edit/js/editor',
'edit/js/notificationarea',
'base/js/keyboard',
'base/js/dialog',
'base/js/notificationwidget',
'base/js/namespace',
'base/js/utils',
'base/js/notificationarea',
'base/js/events',
'base/js/security',
'base/js/page',
'auth/js/main',
'auth/js/logoutmain',
'auth/js/loginmain',
'auth/js/loginwidget',
'terminal/js/main',
'terminal/js/terminado',
'notebook/js/toolbar',
'notebook/js/savewidget',
'notebook/js/main',
'notebook/js/completer',
'notebook/js/contexthint',
'notebook/js/textcell',
'notebook/js/cell',
'notebook/js/tour',
'notebook/js/menubar',
'notebook/js/mathjaxutils',
'notebook/js/codecell',
'notebook/js/codemirror-ipython',
'notebook/js/kernelselector',
'notebook/js/codemirror-ipythongfm',
'notebook/js/celltoolbarpresets/example',
'notebook/js/celltoolbarpresets/default',
'notebook/js/celltoolbarpresets/slideshow',
'notebook/js/celltoolbarpresets/rawcell',
'notebook/js/tooltip',
'notebook/js/maintoolbar',
'notebook/js/about',
'notebook/js/notificationarea',
'notebook/js/quickhelp',
'notebook/js/actions',
'notebook/js/pager',
'notebook/js/searchandreplace',
'notebook/js/keyboardmanager',
'notebook/js/notebook',
'notebook/js/scrollmanager',
'notebook/js/outputarea',
'notebook/js/celltoolbar',
'notebook/js/commandpalette',
'tree/js/sessionlist',
'tree/js/main',
'tree/js/kernellist',
'tree/js/newnotebook',
'tree/js/terminallist',
'tree/js/notebooklist',
'services/sessions/session',
'services/contents',
'services/kernels/serialize',
'services/kernels/comm',
'services/kernels/kernel',
'services/config'
].forEach(function (modulePath) {
define(modulePath, ['notebook'], function(notebookApp) {
console.warn(["Direct module require deprecated. Instead of using",
"`define(['" + modulePath + "'], function(module) {});`, use",
"`define(['notebook'], function(notebookApp) { var module = ",
"notebookApp['" + modulePath + "']});`"].join(' '));
return notebookApp[modulePath];
});
});

View File

@ -2,7 +2,6 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/utils',
'codemirror/lib/codemirror',
'codemirror/mode/meta',
@ -16,7 +15,7 @@ define([
'codemirror/keymap/sublime',
'codemirror/keymap/vim',
],
function($,
function(
utils,
CodeMirror
) {

View File

@ -1,26 +1,23 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
__webpack_public_path__ = window['staticURL'] + 'edit/js/built/';
requirejs(['contents'], function(contents) {
require([
'jquery',
'base/js/namespace',
'base/js/utils',
'base/js/page',
'base/js/events',
'contents',
'services/config',
'edit/js/editor',
'edit/js/menubar',
'edit/js/savewidget',
'edit/js/notificationarea',
'custom/custom',
], function(
$,
IPython,
utils,
page,
events,
contents,
configmod,
editmod,
menubar,
@ -28,6 +25,8 @@ require([
notificationarea
){
"use strict";
requirejs(['custom/custom'], function() {});
page = new page.Page();
var base_url = utils.get_body_data('baseUrl');
@ -95,3 +94,4 @@ require([
// On document ready, resize codemirror.
$(document).ready(_handle_resize);
});
});

View File

@ -2,14 +2,12 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/namespace',
'base/js/utils',
'base/js/dialog',
'codemirror/lib/codemirror',
'codemirror/mode/meta',
'bootstrap',
], function($, IPython, utils, dialog, CodeMirror) {
], function(IPython, utils, dialog, CodeMirror) {
"use strict";
var MenuBar = function (selector, options) {

View File

@ -2,12 +2,11 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/utils',
'base/js/dialog',
'base/js/keyboard',
'moment',
], function($, utils, dialog, keyboard, moment) {
], function(utils, dialog, keyboard, moment) {
"use strict";
var SaveWidget = function (selector, options) {

70
notebook/static/index.js Normal file
View File

@ -0,0 +1,70 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
__webpack_public_path__ = window['staticURL'] + 'built/';
module.exports = {
'edit/js/savewidget': require('./edit/js/savewidget.js'),
// 'edit/js/main': require('./edit/js/main.js'),
'edit/js/menubar': require('./edit/js/menubar.js'),
'edit/js/editor': require('./edit/js/editor.js'),
'edit/js/notificationarea': require('./edit/js/notificationarea.js'),
'base/js/keyboard': require('./base/js/keyboard.js'),
'base/js/dialog': require('./base/js/dialog.js'),
'base/js/notificationwidget': require('./base/js/notificationwidget.js'),
'base/js/namespace': require('./base/js/namespace.js'),
'base/js/utils': require('./base/js/utils.js'),
'base/js/notificationarea': require('./base/js/notificationarea.js'),
'base/js/events': require('./base/js/events.js'),
'base/js/security': require('./base/js/security.js'),
'base/js/page': require('./base/js/page.js'),
'auth/js/main': require('./auth/js/main.js'),
'auth/js/logoutmain': require('./auth/js/logoutmain.js'),
'auth/js/loginmain': require('./auth/js/loginmain.js'),
'auth/js/loginwidget': require('./auth/js/loginwidget.js'),
// 'terminal/js/main': require('./terminal/js/main.js'),
'terminal/js/terminado': require('./terminal/js/terminado.js'),
'notebook/js/toolbar': require('./notebook/js/toolbar.js'),
'notebook/js/savewidget': require('./notebook/js/savewidget.js'),
// 'notebook/js/main': require('./notebook/js/main.js'),
'notebook/js/completer': require('./notebook/js/completer.js'),
'notebook/js/contexthint': require('./notebook/js/contexthint.js'),
'notebook/js/textcell': require('./notebook/js/textcell.js'),
'notebook/js/cell': require('./notebook/js/cell.js'),
'notebook/js/tour': require('./notebook/js/tour.js'),
'notebook/js/menubar': require('./notebook/js/menubar.js'),
'notebook/js/mathjaxutils': require('./notebook/js/mathjaxutils.js'),
'notebook/js/codecell': require('./notebook/js/codecell.js'),
'notebook/js/codemirror-ipython': require('./notebook/js/codemirror-ipython.js'),
'notebook/js/kernelselector': require('./notebook/js/kernelselector.js'),
'notebook/js/codemirror-ipythongfm': require('./notebook/js/codemirror-ipythongfm.js'),
'notebook/js/celltoolbarpresets/example': require('./notebook/js/celltoolbarpresets/example.js'),
'notebook/js/celltoolbarpresets/default': require('./notebook/js/celltoolbarpresets/default.js'),
'notebook/js/celltoolbarpresets/slideshow': require('./notebook/js/celltoolbarpresets/slideshow.js'),
'notebook/js/celltoolbarpresets/rawcell': require('./notebook/js/celltoolbarpresets/rawcell.js'),
'notebook/js/tooltip': require('./notebook/js/tooltip.js'),
'notebook/js/maintoolbar': require('./notebook/js/maintoolbar.js'),
'notebook/js/about': require('./notebook/js/about.js'),
'notebook/js/notificationarea': require('./notebook/js/notificationarea.js'),
'notebook/js/quickhelp': require('./notebook/js/quickhelp.js'),
'notebook/js/actions': require('./notebook/js/actions.js'),
'notebook/js/pager': require('./notebook/js/pager.js'),
'notebook/js/searchandreplace': require('./notebook/js/searchandreplace.js'),
'notebook/js/keyboardmanager': require('./notebook/js/keyboardmanager.js'),
'notebook/js/notebook': require('./notebook/js/notebook.js'),
'notebook/js/scrollmanager': require('./notebook/js/scrollmanager.js'),
'notebook/js/outputarea': require('./notebook/js/outputarea.js'),
'notebook/js/celltoolbar': require('./notebook/js/celltoolbar.js'),
'notebook/js/commandpalette': require('./notebook/js/commandpalette.js'),
'tree/js/sessionlist': require('./tree/js/sessionlist.js'),
// 'tree/js/main': require('./tree/js/main.js'),
'tree/js/kernellist': require('./tree/js/kernellist.js'),
'tree/js/newnotebook': require('./tree/js/newnotebook.js'),
'tree/js/terminallist': require('./tree/js/terminallist.js'),
'tree/js/notebooklist': require('./tree/js/notebooklist.js'),
'services/sessions/session': require('./services/sessions/session.js'),
'services/contents': require('./services/contents.js'),
'services/kernels/serialize': require('./services/kernels/serialize.js'),
'services/kernels/comm': require('./services/kernels/comm.js'),
'services/kernels/kernel': require('./services/kernels/kernel.js'),
'services/config': require('./services/config.js'),
};

View File

@ -1,11 +1,10 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
require([
'jquery',
'base/js/dialog',
'underscore',
'base/js/namespace'
], function ($, dialog, _, IPython) {
], function (dialog, _, IPython) {
'use strict';
$('#notebook_about').click(function () {
// use underscore template to auto html escape

View File

@ -34,7 +34,6 @@ define(function(require){
Object.seal(this);
};
var $ = require('jquery');
var events = require('base/js/events');
/**

View File

@ -10,13 +10,12 @@
define([
'jquery',
'base/js/utils',
'codemirror/lib/codemirror',
'codemirror/addon/edit/matchbrackets',
'codemirror/addon/edit/closebrackets',
'codemirror/addon/comment/comment'
], function($, utils, CodeMirror, cm_match, cm_closeb, cm_comment) {
], function(utils, CodeMirror, cm_match, cm_closeb, cm_comment) {
"use strict";
var overlayHack = CodeMirror.scrollbarModel.native.prototype.overlayHack;

View File

@ -3,9 +3,8 @@
define([
'base/js/namespace',
'jquery',
'base/js/events'
], function(IPython, $, events) {
], function(IPython, events) {
"use strict";
var CellToolbar = function (options) {

View File

@ -2,10 +2,9 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'notebook/js/celltoolbar',
'base/js/dialog',
], function($, celltoolbar, dialog) {
], function(celltoolbar, dialog) {
"use strict";
var CellToolbar = celltoolbar.CellToolbar;

View File

@ -9,9 +9,8 @@
// $.getScript('/static/js/celltoolbarpresets/example.js');
// ```
define([
'jquery',
'notebook/js/celltoolbar',
], function($, celltoolbar) {
], function(celltoolbar) {
"use strict";
var CellToolbar = celltoolbar.CellToolbar;

View File

@ -2,11 +2,10 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'notebook/js/celltoolbar',
'base/js/dialog',
'base/js/keyboard',
], function($, celltoolbar, dialog, keyboard) {
], function(celltoolbar, dialog, keyboard) {
"use strict";
var CellToolbar = celltoolbar.CellToolbar;

View File

@ -2,9 +2,8 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'notebook/js/celltoolbar',
], function($, celltoolbar) {
], function(celltoolbar) {
"use strict";

View File

@ -11,7 +11,6 @@
define([
'base/js/namespace',
'jquery',
'base/js/utils',
'base/js/keyboard',
'services/config',
@ -23,7 +22,6 @@ define([
'codemirror/mode/python/python',
'notebook/js/codemirror-ipython'
], function(IPython,
$,
utils,
keyboard,
configmod,

View File

@ -5,7 +5,6 @@ define(function(require){
"use strict";
var QH = require("notebook/js/quickhelp");
var $ = require("jquery");
/**
* Humanize the action name to be consumed by user.

View File

@ -2,12 +2,11 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/utils',
'base/js/keyboard',
'notebook/js/contexthint',
'codemirror/lib/codemirror',
], function($, utils, keyboard, CodeMirror) {
], function(utils, keyboard, CodeMirror) {
"use strict";
// easier key mapping

View File

@ -2,12 +2,10 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/namespace',
'base/js/dialog',
'base/js/utils',
'require',
], function($, IPython, dialog, utils, require) {
'base/js/utils'
], function(IPython, dialog, utils) {
"use strict";
var KernelSelector = function(selector, notebook) {
@ -155,8 +153,8 @@ define([
//
// > Uncaught (in promise) TypeError: require is not a function
//
console.info('Dynamically requiring kernel.js, `require` is ', require);
require([ks.resources['kernel.js']],
console.info('Dynamically requiring kernel.js, `requirejs` is ', requirejs);
requirejs([ks.resources['kernel.js']],
function (kernel_mod) {
if (kernel_mod && kernel_mod.onload) {
kernel_mod.onload();

View File

@ -9,10 +9,9 @@
*/
define([
'jquery',
'base/js/utils',
'base/js/keyboard',
], function($, utils, keyboard) {
], function(utils, keyboard) {
"use strict";
// Main keyboard manager for the notebook

View File

@ -1,11 +1,12 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
__webpack_public_path__ = window['staticURL'] + 'notebook/js/built/';
requirejs(['contents'], function(contentsModule) {
require([
'base/js/namespace',
'jquery',
'notebook/js/notebook',
'contents',
'services/config',
'base/js/utils',
'base/js/page',
@ -22,38 +23,36 @@ require([
'notebook/js/kernelselector',
'codemirror/lib/codemirror',
'notebook/js/about',
'typeahead',
'notebook/js/searchandreplace',
// only loaded, not used, please keep sure this is loaded last
'custom/custom'
'notebook/js/searchandreplace'
], function(
IPython,
IPython,
$,
notebook,
contents,
notebook,
configmod,
utils,
page,
utils,
page,
events,
loginwidget,
maintoolbar,
pager,
quickhelp,
menubar,
notificationarea,
loginwidget,
maintoolbar,
pager,
quickhelp,
menubar,
notificationarea,
savewidget,
actions,
keyboardmanager,
kernelselector,
CodeMirror,
about,
typeahead,
searchandreplace,
// please keep sure that even if not used, this is loaded last
custom
searchandreplace
) {
"use strict";
// Pull typeahead from the global jquery object
var typeahead = $.typeahead;
requirejs(['custom/custom'], function() {});
// BEGIN HARDCODED WIDGETS HACK
// Try to load the new extension
utils.load_extension('widgets/extension').catch(function () {
@ -83,14 +82,14 @@ require([
events: events});
var acts = new actions.init();
var keyboard_manager = new keyboardmanager.KeyboardManager({
pager: pager,
events: events,
pager: pager,
events: events,
actions: acts });
var save_widget = new savewidget.SaveWidget('span#save_widget', {
events: events,
events: events,
keyboard_manager: keyboard_manager});
acts.extend_env({save_widget:save_widget})
var contents = new contents.Contents({
var contents = new contentsModule.Contents({
base_url: common_options.base_url,
common_config: common_config
});
@ -103,27 +102,27 @@ require([
common_options));
var login_widget = new loginwidget.LoginWidget('span#login_widget', common_options);
var toolbar = new maintoolbar.MainToolBar('#maintoolbar-container', {
notebook: notebook,
events: events,
actions: acts});
notebook: notebook,
events: events,
actions: acts});
var quick_help = new quickhelp.QuickHelp({
keyboard_manager: keyboard_manager,
keyboard_manager: keyboard_manager,
events: events,
notebook: notebook});
keyboard_manager.set_notebook(notebook);
keyboard_manager.set_quickhelp(quick_help);
var menubar = new menubar.MenuBar('#menubar', $.extend({
notebook: notebook,
notebook: notebook,
contents: contents,
events: events,
save_widget: save_widget,
events: events,
save_widget: save_widget,
quick_help: quick_help,
actions: acts},
actions: acts},
common_options));
var notification_area = new notificationarea.NotebookNotificationArea(
'#notification_area', {
events: events,
save_widget: save_widget,
events: events,
save_widget: save_widget,
notebook: notebook,
keyboard_manager: keyboard_manager});
notification_area.init_notification_widgets();
@ -152,7 +151,7 @@ require([
}
notebook.set_autosave_interval(notebook.minimum_autosave_interval);
});
IPython.page = page;
IPython.notebook = notebook;
IPython.contents = contents;
@ -173,7 +172,7 @@ require([
}
Object.defineProperty( IPython, 'actions', {
get: function() {
get: function() {
console.warn('accessing "actions" on the global IPython/Jupyter is not recommended. Pass it to your objects contructors at creation time');
return acts;
},
@ -186,3 +185,4 @@ require([
notebook.load_notebook(common_options.notebook_path);
});
});

View File

@ -3,10 +3,9 @@
define([
'require',
'jquery',
'./toolbar',
'./celltoolbar'
], function(require, $, toolbar, celltoolbar) {
], function(require, toolbar, celltoolbar) {
"use strict";
var MainToolBar = function (selector, options) {

View File

@ -2,10 +2,9 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/utils',
'base/js/dialog',
], function($, utils, dialog) {
], function(utils, dialog) {
"use strict";
var init = function () {

View File

@ -2,14 +2,13 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/namespace',
'base/js/dialog',
'base/js/utils',
'./celltoolbar',
'./tour',
'moment',
], function($, IPython, dialog, utils, celltoolbar, tour, moment) {
], function(IPython, dialog, utils, celltoolbar, tour, moment) {
"use strict";
var MenuBar = function (selector, options) {
@ -399,7 +398,7 @@ define([
.append($("<a>")
.attr('target', '_blank')
.attr('title', 'Opens in a new window')
.attr('href', require.toUrl(link.url))
.attr('href', requirejs.toUrl(link.url))
.append($("<i>")
.addClass("fa fa-external-link menu-icon pull-right")
)

View File

@ -7,7 +7,6 @@
define(function (require) {
"use strict";
var IPython = require('base/js/namespace');
var $ = require('jquery');
var _ = require('underscore');
var utils = require('base/js/utils');
var dialog = require('base/js/dialog');

View File

@ -1,10 +1,9 @@
define([
'jquery',
'base/js/utils',
'base/js/dialog',
'base/js/notificationarea',
'moment'
], function($, utils, dialog, notificationarea, moment) {
], function(utils, dialog, notificationarea, moment) {
"use strict";
var NotificationArea = notificationarea.NotificationArea;

View File

@ -2,13 +2,12 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery-ui',
'base/js/utils',
'base/js/security',
'base/js/keyboard',
'notebook/js/mathjaxutils',
'components/marked/lib/marked',
], function($, utils, security, keyboard, mathjaxutils, marked) {
], function(utils, security, keyboard, mathjaxutils, marked) {
"use strict";
/**

View File

@ -2,9 +2,8 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery-ui',
'base/js/utils',
], function($, utils) {
], function(utils) {
"use strict";
var Pager = function (pager_selector, options) {

View File

@ -2,10 +2,10 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/utils',
'base/js/dialog',
], function($, utils, dialog) {
'underscore'
], function(utils, dialog, _) {
"use strict";
var platform = utils.platform;

View File

@ -2,12 +2,11 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/utils',
'base/js/dialog',
'base/js/keyboard',
'moment',
], function($, utils, dialog, keyboard, moment) {
], function(utils, dialog, keyboard, moment) {
"use strict";
var SaveWidget = function (selector, options) {

View File

@ -1,6 +1,6 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
define(['jquery'], function($){
define([], function() {
"use strict";
var ScrollManager = function(notebook, options) {

View File

@ -3,7 +3,6 @@
define([
'base/js/utils',
'jquery',
'notebook/js/cell',
'base/js/security',
'services/config',
@ -15,7 +14,6 @@ define([
'notebook/js/codemirror-ipythongfm'
], function(
utils,
$,
cell,
security,
configmod,

View File

@ -1,9 +1,7 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
define([
'jquery'
], function($) {
define([], function() {
"use strict";
/**

View File

@ -2,9 +2,8 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/utils',
], function($, utils) {
], function(utils) {
"use strict";
// tooltip constructor

View File

@ -1,10 +1,7 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'bootstraptour',
], function($, Tour) {
define([], function() {
"use strict";
var tour_style = "<div class='popover tour'>\n" +

View File

@ -2,10 +2,9 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/utils',
],
function($, utils) {
function(utils) {
"use strict";
var ConfigSection = function(section_name, options) {
this.section_name = section_name;

View File

@ -1,10 +1,10 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
__webpack_public_path__ = window['staticURL'] + 'services/built/';
define(function(require) {
"use strict";
var $ = require('jquery');
var utils = require('base/js/utils');
var Contents = function(options) {

View File

@ -2,9 +2,8 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/utils',
], function($, utils) {
], function(utils) {
"use strict";
//-----------------------------------------------------------------------

View File

@ -2,12 +2,11 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/utils',
'./comm',
'./serialize',
'base/js/events'
], function($, utils, comm, serialize, events) {
], function(utils, comm, serialize, events) {
"use strict";
/**

View File

@ -2,10 +2,9 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/utils',
'services/kernels/kernel',
], function($, utils, kernel) {
], function(utils, kernel) {
"use strict";
/**

View File

@ -1,23 +1,21 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
__webpack_public_path__ = window['staticURL'] + 'terminal/js/built/';
requirejs(['termjs'], function(termjs) {
require([
'jquery',
'termjs',
'base/js/utils',
'base/js/page',
'services/config',
'terminal/js/terminado',
'custom/custom',
], function(
$,
termjs,
utils,
page,
configmod,
terminado
){
"use strict";
requirejs(['custom/custom'], function() {});
page = new page.Page();
var common_config = new configmod.ConfigSection('common',
@ -64,3 +62,4 @@ require([
window.terminal = terminal;
});
});

View File

@ -3,9 +3,8 @@
define([
'base/js/namespace',
'jquery',
'tree/js/notebooklist',
], function(IPython, $, notebooklist) {
], function(IPython, notebooklist) {
"use strict";
var KernelList = function (selector, options) {

View File

@ -1,34 +1,28 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
__webpack_public_path__ = window['staticURL'] + 'tree/js/built/';
requirejs(['contents'], function(contents_service) {
require([
'jquery',
'base/js/namespace',
'base/js/dialog',
'base/js/events',
'base/js/page',
'base/js/utils',
'services/config',
'contents',
'tree/js/notebooklist',
'tree/js/sessionlist',
'tree/js/kernellist',
'tree/js/terminallist',
'tree/js/newnotebook',
'auth/js/loginwidget',
// only loaded, not used:
'jquery-ui',
'bootstrap',
'custom/custom',
], function(
$,
IPython,
dialog,
events,
page,
utils,
config,
contents_service,
notebooklist,
sesssionlist,
kernellist,
@ -36,6 +30,7 @@ require([
newnotebook,
loginwidget){
"use strict";
requirejs(['custom/custom'], function() {});
IPython.NotebookList = notebooklist.NotebookList;
@ -175,3 +170,4 @@ require([
$("#tabs").find("a[href=" + window.location.hash + "]").click();
}
});
});

View File

@ -2,11 +2,10 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/namespace',
'base/js/utils',
'base/js/dialog',
], function ($, IPython, utils, dialog) {
], function (IPython, utils, dialog) {
"use strict";
var NewNotebookWidget = function (selector, options) {

View File

@ -3,14 +3,14 @@
define([
'base/js/namespace',
'jquery',
'base/js/utils',
'base/js/dialog',
'base/js/events',
'base/js/keyboard',
], function(IPython, $, utils, dialog, events, keyboard) {
'moment'
], function(IPython, utils, dialog, events, keyboard, moment) {
"use strict";
var NotebookList = function (selector, options) {
/**
* Constructor
@ -42,7 +42,7 @@ define([
this.notebook_path = options.notebook_path || utils.get_body_data("notebookPath");
this.contents = options.contents;
if (this.session_list && this.session_list.events) {
this.session_list.events.on('sessions_loaded.Dashboard',
this.session_list.events.on('sessions_loaded.Dashboard',
function(e, d) { that.sessions_loaded(d); });
}
this.selected = [];
@ -277,7 +277,7 @@ define([
reader.onerror = reader_onerror;
}
// Replace the file input form wth a clone of itself. This is required to
// reset the form. Otherwise, if you upload a file, delete it and try to
// reset the form. Otherwise, if you upload a file, delete it and try to
// upload it again, the changed event won't fire.
var form = $('input.fileinput');
form.replaceWith(form.clone(true));
@ -295,7 +295,7 @@ define([
if (remove_uploads) {
this.element.children('.list_item').remove();
} else {
this.element.children('.list_item:not(.new-file)').remove();
this.element.children('.list_item:not(.new-file)').remove();
}
};
@ -397,7 +397,7 @@ define([
}
}
});
this._selection_changed();
this._selection_changed();
};
@ -442,7 +442,7 @@ define([
.addClass("item_modified")
.addClass("pull-right")
.appendTo(item);
if (selectable === false) {
checkbox.css('visibility', 'hidden');
} else if (selectable === true) {
@ -465,7 +465,7 @@ define([
.text('Running')
.css('visibility', 'hidden')
.appendTo(buttons);
if (index === -1) {
this.element.append(row);
} else {
@ -597,13 +597,13 @@ define([
var total = 0;
$('.list_item input[type=checkbox]').each(function(index, item) {
var parent = $(item).parent().parent();
// If the item doesn't have an upload button and it's not the
// If the item doesn't have an upload button and it's not the
// breadcrumbs, it can be selected. Breadcrumbs path == ''.
if (parent.find('.upload_button').length === 0 && parent.data('path') !== '' && parent.data('path') !== utils.url_path_split(that.notebook_path)[0]) {
total++;
}
});
var select_all = $("#select-all");
if (checked === 0) {
select_all.prop('checked', false);
@ -651,7 +651,7 @@ define([
// send text/unidentified files to editor, others go to raw viewer
uri_prefix = 'files';
}
item.find(".item_icon").addClass(icon).addClass('icon-fixed-width');
var link = item.find("a.item_link")
.attr('href',
@ -763,7 +763,7 @@ define([
that.load_list();
// Deselect items after successful rename.
that.select('select-none');
}).catch(function(e) {
}).catch(function(e) {
dialog.modal({
title: "Rename Failed",
body: $('<div/>')
@ -899,7 +899,7 @@ define([
Delete : {
class: "btn-danger",
click: function() {
// Shutdown any/all selected notebooks before deleting
// Shutdown any/all selected notebooks before deleting
// the files.
that.shutdown_selected();
@ -907,7 +907,7 @@ define([
that.selected.forEach(function(item) {
that.contents.delete(item.path).then(function() {
that.notebook_deleted(item.path);
}).catch(function(e) {
}).catch(function(e) {
dialog.modal({
title: "Delete Failed",
body: $('<div/>')
@ -950,7 +950,7 @@ define([
that.load_list();
// Deselect items after successful duplication.
that.select('select-none');
}).catch(function(e) {
}).catch(function(e) {
dialog.modal({
title: "Duplicate Failed",
body: $('<div/>')
@ -1053,12 +1053,12 @@ define([
that.add_link(model, item);
that.session_list.load_sessions();
};
var exists = false;
$.each(that.element.find('.list_item:not(.new-file)'), function(k,v){
if ($(v).data('name') === filename) { exists = true; return false; }
});
if (exists) {
dialog.modal({
title : "Replace file",

View File

@ -2,9 +2,8 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/utils',
], function($, utils) {
], function(utils) {
"use strict";
var SesssionList = function (options) {

View File

@ -4,9 +4,8 @@
define([
'base/js/namespace',
'base/js/utils',
'jquery',
'tree/js/notebooklist',
], function(IPython, utils, $, notebooklist) {
], function(IPython, utils, notebooklist) {
"use strict";
var TerminalList = function (selector, options) {

View File

@ -95,9 +95,5 @@ data-file-path="{{file_path}}"
{{super()}}
{% if ignore_minified_js %}
<script src="{{ static_url("edit/js/main.js") }}" type="text/javascript" charset="utf-8"></script>
{% else %}
<script src="{{ static_url("edit/js/main.min.js") }}" type="text/javascript" charset="utf-8"></script>
{% endif %}
<script src="{{ static_url("edit/js/built/main.min.js") }}" type="text/javascript" charset="utf-8"></script>
{% endblock %}

View File

@ -344,10 +344,6 @@ data-notebook-path="{{notebook_path | urlencode}}"
<script src="{{ static_url("components/text-encoding/lib/encoding.js") }}" charset="utf-8"></script>
{% if ignore_minified_js %}
<script src="{{ static_url("notebook/js/main.js") }}" type="text/javascript" charset="utf-8"></script>
{% else %}
<script src="{{ static_url("notebook/js/main.min.js") }}" type="text/javascript" charset="utf-8"></script>
{% endif %}
<script src="{{ static_url("notebook/js/built/main.min.js") }}" type="text/javascript" charset="utf-8"></script>
{% endblock %}

View File

@ -10,39 +10,49 @@
<link rel="stylesheet" href="{{static_url("components/jquery-ui/themes/smoothness/jquery-ui.min.css") }}" type="text/css" />
<link rel="stylesheet" href="{{static_url("components/jquery-typeahead/dist/jquery.typeahead.min.css") }}" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% block stylesheet %}
<link rel="stylesheet" href="{{ static_url("style/style.min.css") }}" type="text/css"/>
{% endblock %}
<link rel="stylesheet" href="{{ base_url }}custom/custom.css" type="text/css" />
<script src="{{static_url("components/es6-promise/promise.min.js")}}" type="text/javascript" charset="utf-8"></script>
<script src="{{static_url("components/jquery/jquery.min.js") }}" type="text/javascript" charset="utf-8"></script> <!-- window.$ -->
<script src="{{static_url("components/jquery-ui/ui/minified/jquery-ui.min.js") }}" type="text/javascript" charset="utf-8"></script> <!-- extends window.$ -->
<script src="{{static_url("components/bootstrap/js/bootstrap.min.js") }}" type="text/javascript" charset="utf-8"></script> <!-- extends window.$ -->
<script src="{{static_url("components/bootstrap-tour/build/js/bootstrap-tour.min.js") }}" type="text/javascript" charset="utf-8"></script> <!-- window.Tour -->
<script src="{{static_url("components/jquery-typeahead/dist/jquery.typeahead.js") }}" type="text/javascript" charset="utf-8"></script> <!-- extends window.$ -->
<script src="{{static_url("components/requirejs/require.js") }}" type="text/javascript" charset="utf-8"></script>
<script>
window['staticURL'] = "{{static_url("", include_version=False)}}";
require.config({
{% if version_hash %}
urlArgs: "v={{version_hash}}",
{% endif %}
baseUrl: '{{static_url("", include_version=False)}}',
paths: {
{% if ignore_minified_js %}
'auth/js/main': 'auth/js/main',
{% else %}
'auth/js/main': 'auth/js/main.min',
{% endif %}
'auth/js/main': 'auth/js/built/main.min',
custom : '{{ base_url }}custom',
nbextensions : '{{ base_url }}nbextensions',
widgets : '{{ base_url }}deprecatedwidgets',
kernelspecs : '{{ base_url }}kernelspecs',
underscore : 'components/underscore/underscore-min',
backbone : 'components/backbone/backbone-min',
jquery: 'components/jquery/jquery.min',
bootstrap: 'components/bootstrap/js/bootstrap.min',
bootstraptour: 'components/bootstrap-tour/build/js/bootstrap-tour.min',
'jquery-ui': 'components/jquery-ui/ui/minified/jquery-ui.min',
moment: 'components/moment/moment',
codemirror: 'components/codemirror',
termjs: 'components/term.js/src/term',
typeahead: 'components/jquery-typeahead/dist/jquery.typeahead'
// Define aliases for requirejs webpack imports
notebook: 'built/index',
// Anything jQuery related is loaded globally because it will
// pollute the global object regardless and we want to avoid one
// jQuery thinger from clompering another.
jquery: 'base/js/jquery',
bootstrap: 'base/js/jquery',
bootstraptour: 'base/js/tour',
'jquery-ui': 'base/js/jquery',
jqueryui: 'base/js/jquery',
typeahead: 'base/js/typeahead'
},
map: { // for backward compatibility
"*": {
@ -75,6 +85,75 @@
}
},
waitSeconds: 30,
// TODO: Remove me in notebook version 6.0
bundles: {
'deprecated-imports': [
'edit/js/savewidget',
'edit/js/main',
'edit/js/menubar',
'edit/js/editor',
'edit/js/notificationarea',
'base/js/keyboard',
'base/js/dialog',
'base/js/notificationwidget',
'base/js/namespace',
'base/js/utils',
'base/js/notificationarea',
'base/js/events',
'base/js/security',
'base/js/page',
'auth/js/main',
'auth/js/logoutmain',
'auth/js/loginmain',
'auth/js/loginwidget',
'terminal/js/main',
'terminal/js/terminado',
'notebook/js/toolbar',
'notebook/js/savewidget',
'notebook/js/main',
'notebook/js/completer',
'notebook/js/contexthint',
'notebook/js/textcell',
'notebook/js/cell',
'notebook/js/tour',
'notebook/js/menubar',
'notebook/js/mathjaxutils',
'notebook/js/codecell',
'notebook/js/codemirror-ipython',
'notebook/js/kernelselector',
'notebook/js/codemirror-ipythongfm',
'notebook/js/celltoolbarpresets/example',
'notebook/js/celltoolbarpresets/default',
'notebook/js/celltoolbarpresets/slideshow',
'notebook/js/celltoolbarpresets/rawcell',
'notebook/js/tooltip',
'notebook/js/maintoolbar',
'notebook/js/about',
'notebook/js/notificationarea',
'notebook/js/quickhelp',
'notebook/js/actions',
'notebook/js/pager',
'notebook/js/searchandreplace',
'notebook/js/keyboardmanager',
'notebook/js/notebook',
'notebook/js/scrollmanager',
'notebook/js/outputarea',
'notebook/js/celltoolbar',
'notebook/js/commandpalette',
'tree/js/sessionlist',
'tree/js/main',
'tree/js/kernellist',
'tree/js/newnotebook',
'tree/js/terminallist',
'tree/js/notebooklist',
'services/sessions/session',
'services/contents',
'services/kernels/serialize',
'services/kernels/comm',
'services/kernels/kernel',
'services/config'
]
}
});
require.config({
@ -82,7 +161,7 @@
'*':{
'contents': '{{ contents_js_source }}',
}
}
},
});
</script>
@ -105,7 +184,7 @@
<div id="ipython_notebook" class="nav navbar-brand pull-left"><a href="{{default_url}}" title='dashboard'>{% block logo %}<img src='{{static_url("base/images/logo.png") }}' alt='Jupyter Notebook'/>{% endblock %}</a></div>
{% block header_buttons %}
{% block login_widget %}
<span id="login_widget">

View File

@ -60,5 +60,5 @@ data-ws-path="{{ws_path}}"
{{super()}}
<script src="{{ static_url("terminal/js/main.min.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ static_url("terminal/js/built/main.min.js") }}" type="text/javascript" charset="utf-8"></script>
{% endblock %}

View File

@ -181,9 +181,6 @@ data-terminals-available="{{terminals_available}}"
{% block script %}
{{super()}}
{% if ignore_minified_js %}
<script src="{{ static_url("tree/js/main.js") }}" type="text/javascript" charset="utf-8"></script>
{% else %}
<script src="{{ static_url("tree/js/main.min.js") }}" type="text/javascript" charset="utf-8"></script>
{% endif %}
<script src="{{ static_url("tree/js/built/main.min.js") }}" type="text/javascript" charset="utf-8"></script>
{% endblock %}

View File

@ -0,0 +1,100 @@
/**
* This module tests the deprecated requirejs module path based loading API
*/
// TODO: Remove these tests in notebook 6.0!
function guid() {
return Math.random().toString(36).replace(/[^a-z]+/g, '');
}
casper.notebook_test(function () {
var that = this;
[
'edit/js/savewidget',
// 'edit/js/main',
'edit/js/menubar',
'edit/js/editor',
'edit/js/notificationarea',
'base/js/keyboard',
'base/js/dialog',
'base/js/notificationwidget',
'base/js/namespace',
'base/js/utils',
'base/js/notificationarea',
'base/js/events',
'base/js/security',
'base/js/page',
'auth/js/main',
'auth/js/logoutmain',
'auth/js/loginmain',
'auth/js/loginwidget',
// 'terminal/js/main',
'terminal/js/terminado',
'notebook/js/toolbar',
'notebook/js/savewidget',
// 'notebook/js/main',
'notebook/js/completer',
'notebook/js/contexthint',
'notebook/js/textcell',
'notebook/js/cell',
'notebook/js/tour',
'notebook/js/menubar',
'notebook/js/mathjaxutils',
'notebook/js/codecell',
'notebook/js/codemirror-ipython',
'notebook/js/kernelselector',
'notebook/js/codemirror-ipythongfm',
'notebook/js/celltoolbarpresets/example',
'notebook/js/celltoolbarpresets/default',
'notebook/js/celltoolbarpresets/slideshow',
'notebook/js/celltoolbarpresets/rawcell',
'notebook/js/tooltip',
'notebook/js/maintoolbar',
'notebook/js/about',
'notebook/js/notificationarea',
'notebook/js/quickhelp',
'notebook/js/actions',
'notebook/js/pager',
'notebook/js/searchandreplace',
'notebook/js/keyboardmanager',
'notebook/js/notebook',
'notebook/js/scrollmanager',
'notebook/js/outputarea',
'notebook/js/celltoolbar',
'notebook/js/commandpalette',
'tree/js/sessionlist',
// 'tree/js/main',
'tree/js/kernellist',
'tree/js/newnotebook',
'tree/js/terminallist',
'tree/js/notebooklist',
'services/sessions/session',
'services/contents',
'services/kernels/serialize',
'services/kernels/comm',
'services/kernels/kernel',
'services/config'
].forEach(function (name) {
var guid = that.evaluate(function(name) {
var guid = Math.random().toString(36).replace(/[^a-z]+/g, '');
require(['notebook', name], function(notebookApp, module) {
window[guid] = (notebookApp[name] === module);
});
return guid;
}, {name: name});
that.waitFor(function() {
return this.evaluate(function(guid) {
return window[guid] !== undefined;
}, {guid: guid});
});
that.then(function() {
this.test.assertEquals(this.evaluate(function(guid) {
return window[guid];
}, {guid: guid}), true, name + ' can be loaded directly with requirejs');
});
});
});

View File

@ -10,11 +10,22 @@
},
"scripts": {
"bower": "bower install",
"build": "python setup.py js css"
"build:watch": "concurrent \"npm run build:css:watch\" \"npm run build:js:watch\"",
"build": "npm run build:css && npm run build:js",
"build:css": "python setup.py css",
"build:css:watch": "echo Not implemented yet...",
"build:js": "webpack",
"build:js:watch": "npm run build:js -- --watch"
},
"devDependencies": {
"bower": "*",
"concurrently": "^1.0.0",
"less": "~2",
"requirejs": "^2.1.17"
"requirejs": "^2.1.17",
"underscore": "^1.8.3",
"webpack": "^1.12.13"
},
"dependencies": {
"moment": "^2.8.4"
}
}

View File

@ -118,7 +118,16 @@ def find_package_data():
# for verification purposes, explicitly add main.min.js
# so that installation will fail if they are missing
for app in ['auth', 'edit', 'notebook', 'terminal', 'tree']:
static_data.append(pjoin('static', app, 'js', 'main.min.js'))
static_data.extend([
pjoin('static', app, 'js', 'built', '*main.min.js'),
pjoin('static', app, 'js', 'built', '*main.min.js.map'),
])
static_data.extend([
pjoin('static', 'built', '*index.js'),
pjoin('static', 'built', '*index.js.map'),
pjoin('static', 'services', 'built', '*contents.js'),
pjoin('static', 'services', 'built', '*contents.js.map'),
])
components = pjoin("static", "components")
# select the components we actually need to install
@ -436,17 +445,18 @@ class CompileJS(Command):
self.force = bool(self.force)
apps = ['notebook', 'tree', 'edit', 'terminal', 'auth']
targets = [ pjoin(static, app, 'js', 'main.min.js') for app in apps ]
targets = [ pjoin(static, app, 'js', 'built', 'main.min.js') for app in apps ]
def sources(self, name):
"""Generator yielding .js sources that an application depends on"""
yield pjoin(static, name, 'js', 'main.js')
yield pjoin(static, name, 'js', 'built', 'main.min.js')
for sec in [name, 'base', 'auth']:
for f in glob(pjoin(static, sec, 'js', '*.js')):
if not f.endswith('.min.js'):
yield f
yield pjoin(static, 'services', 'config.js')
yield pjoin(static, 'services', 'built', 'config.js')
yield pjoin(static, 'built', 'index.js')
if name == 'notebook':
for f in glob(pjoin(static, 'services', '*', '*.js')):
yield f
@ -470,13 +480,13 @@ class CompileJS(Command):
def build_main(self, name):
"""Build main.min.js"""
target = pjoin(static, name, 'js', 'main.min.js')
target = pjoin(static, name, 'js', 'built', 'main.min.js')
if not self.should_run(name, target):
log.info("%s up to date" % target)
return
log.info("Rebuilding %s" % target)
run(['node', 'tools/build-main.js', name])
run(['npm', 'run', 'build'])
def run(self):
self.run_command('jsdeps')

View File

@ -1,67 +0,0 @@
// build main.min.js
// spawned by gulp to allow parallelism
var rjs = require('requirejs').optimize;
var name = process.argv[2];
var rjs_config = {
name: name + '/js/main',
out: './notebook/static/' + name + '/js/main.min.js',
baseUrl: 'notebook/static',
preserveLicenseComments: false, // license comments conflict with sourcemap generation
generateSourceMaps: true,
optimize: "none",
paths: {
underscore : 'components/underscore/underscore-min',
backbone : 'components/backbone/backbone-min',
jquery: 'components/jquery/jquery.min',
bootstrap: 'components/bootstrap/js/bootstrap.min',
bootstraptour: 'components/bootstrap-tour/build/js/bootstrap-tour.min',
"jquery-ui": 'components/jquery-ui/ui/minified/jquery-ui.min',
moment: 'components/moment/moment',
codemirror: 'components/codemirror',
termjs: 'components/term.js/src/term',
typeahead: 'components/jquery-typeahead/dist/jquery.typeahead',
contents: 'empty:'
},
map: { // for backward compatibility
"*": {
"jqueryui": "jquery-ui",
}
},
shim: {
typeahead: {
deps: ["jquery"],
exports: "typeahead"
},
underscore: {
exports: '_'
},
backbone: {
deps: ["underscore", "jquery"],
exports: "Backbone"
},
bootstrap: {
deps: ["jquery"],
exports: "bootstrap"
},
bootstraptour: {
deps: ["bootstrap"],
exports: "Tour"
},
"jquery-ui": {
deps: ["jquery"],
exports: "$"
}
},
exclude: [
"custom/custom",
]
};
rjs(rjs_config, console.log, function (err) {
console.log("Failed to build", name, err);
process.exit(1);
});

74
webpack.config.js Normal file
View File

@ -0,0 +1,74 @@
var _ = require('underscore');
var path = require('path');
var commonConfig = {
resolve: {
root: [
'.', /* allows npm packages to be loaded */
'./notebook/static'
].map(x =>path.resolve(x)),
modulesDirectories: [
"components", /* bower */
"node_modules" /* npm */
]
},
module: {
loaders: [
{ test: /\.css$/, loader: "style-loader!css-loader" },
{ test: /\.json$/, loader: "json-loader" },
// jquery-ui loads some images
{ test: /\.(jpg|png|gif)$/, loader: "file" },
// required to load font-awesome
{ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&minetype=application/font-woff" },
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&minetype=application/font-woff" },
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&minetype=application/octet-stream" },
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file" },
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&minetype=image/svg+xml" }
]
},
externals: {
jquery: '$',
bootstrap: '$',
bootstraptour: 'Tour',
'jquery-ui': '$',
typeahead: '$.typeahead'
}
};
function buildConfig(appName) {
if (typeof appName !== 'string') return appName;
return _.extend({}, commonConfig, {
entry: './notebook/static/' + appName + '/js/main.js',
output: {
filename: 'main.min.js',
path: './notebook/static/' + appName + '/js/built'
},
devtool: 'source-map',
});
}
module.exports = [
'auth',
'edit',
'terminal',
'tree',
'notebook',
_.extend({}, commonConfig, {
entry: './notebook/static/services/contents.js',
output: {
filename: 'contents.js',
path: './notebook/static/services/built',
libraryTarget: 'amd'
},
devtool: 'source-map',
}),
_.extend({}, commonConfig, {
entry: './notebook/static/index.js',
output: {
filename: 'index.js',
path: './notebook/static/built',
libraryTarget: 'amd'
},
devtool: 'source-map',
}),
].map(x => buildConfig(x));