Merge pull request #2011 from minrk/unwebpack

unwebpackify
Thomas Kluyver 9 years ago committed by GitHub
commit 666ecbf35c

@ -29,7 +29,10 @@ before_install:
- npm --version
- npm upgrade -g npm
- npm install
- 'if [[ $GROUP == js* ]]; then npm install -g casperjs@1.1.0-beta5; fi'
- |
if [[ $GROUP == js* ]]; then
npm install -g casperjs@1.1.3 phantomjs-prebuilt@2.1.7
fi
- git clone --quiet --depth 1 https://github.com/minrk/travis-wheels travis-wheels
install:
@ -37,7 +40,6 @@ install:
script:
- 'if [[ $GROUP == js* ]]; then travis_retry python -m notebook.jstest ${GROUP:3}; fi'
- 'if [[ $GROUP == "js/notebook" ]]; then npm run lint; fi'
- 'if [[ $GROUP == python ]]; then nosetests -v --with-coverage --cover-package=notebook notebook; fi'
matrix:

@ -6,6 +6,7 @@
"bootstrap": "components/bootstrap#~3.3",
"bootstrap-tour": "0.9.0",
"codemirror": "components/codemirror#~5.16",
"es6-promise": "~1.0",
"font-awesome": "components/font-awesome#~4.2.0",
"google-caja": "5669",
"jquery": "components/jquery#~2.0",
@ -13,8 +14,10 @@
"jquery-ui": "components/jqueryui#~1.10",
"marked": "~0.3",
"MathJax": "components/MathJax#~2.6",
"moment": "~2.8.4",
"requirejs": "~2.1",
"text-encoding": "~0.1",
"underscore": "components/underscore#~1.8.3"
"underscore": "components/underscore#~1.8.3",
"xterm.js": "sourcelair/xterm.js#~2.1.0"
}
}

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

@ -1,7 +1,7 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
define(['base/js/namespace', 'base/js/page'], function(IPython, page) {
define(['jquery', 'base/js/namespace', 'base/js/page'], function($, IPython, page) {
function login_main() {
var page_instance = new page.Page();
$('button#login_submit').addClass("btn btn-default");

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

@ -1,6 +1,5 @@
// 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 {

@ -5,6 +5,8 @@ define(function(require) {
"use strict";
var CodeMirror = require('codemirror/lib/codemirror');
var bs = require('bootstrap');
var $ = require('jquery');
/**
* A wrapper around bootstrap modal for easier use

@ -9,7 +9,7 @@
// events.on("event.Namespace", function () { do_stuff(); });
// });
define(['base/js/namespace'], function(Jupyter) {
define(['jquery', 'base/js/namespace'], function($, Jupyter) {
"use strict";
// Events singleton

@ -1,11 +0,0 @@
// 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.$;
});

@ -9,9 +9,10 @@
*/
define([
'jquery',
'base/js/utils',
'underscore',
], function(utils, _) {
], function($, utils, _) {
"use strict";
@ -416,8 +417,8 @@ define([
shortcut = shortcut.toLowerCase();
this.remove_shortcut(shortcut);
const patch = {keys:{}};
const b = {bind:{}};
var patch = {keys: {}};
var b = {bind: {}};
patch.keys[this._mode] = {bind:{}};
patch.keys[this._mode].bind[shortcut] = null;
this._config.update(patch);
@ -425,16 +426,16 @@ define([
// if the shortcut we unbind is a default one, we add it to the list of
// things to unbind at startup
if( this._defaults_bindings.indexOf(shortcut) !== -1 ){
const cnf = (this._config.data.keys||{})[this._mode];
const unbind_array = cnf.unbind||[];
var cnf = (this._config.data.keys || {})[this._mode];
var unbind_array = cnf.unbind || [];
// unless it's already there (like if we have remapped a default
// shortcut to another command): unbind it)
if(unbind_array.indexOf(shortcut) === -1){
const _parray = unbind_array.concat(shortcut);
const unbind_patch = {keys:{}};
unbind_patch.keys[this._mode] = {unbind:_parray}
var _parray = unbind_array.concat(shortcut);
var unbind_patch = {keys:{}};
unbind_patch.keys[this._mode] = {unbind:_parray};
console.warn('up:', unbind_patch);
this._config.update(unbind_patch);
}

@ -2,79 +2,76 @@
// Distributed under the terms of the Modified BSD License.
var Jupyter;
if (typeof window !== 'undefined') {
Jupyter = window['Jupyter'] = window['Jupyter'] || {};
} else {
Jupyter = Jupyter || {};
}
var Jupyter = Jupyter || {};
var jprop = function(name, loadedModule, modulePath){
var jprop = function(name, module_path){
Object.defineProperty(Jupyter, name, {
get: function() {
console.warn('accessing `'+name+'` is deprecated. Use `require("'+modulePath+'")`');
return loadedModule;
console.warn('accessing `'+name+'` is deprecated. Use `require("'+module_path+'")`');
return require(module_path);
},
enumerable: true,
configurable: false
});
};
}
var jglobal = function(name, loadedModule, modulePath){
var jglobal = function(name, module_path){
Object.defineProperty(Jupyter, name, {
get: function() {
console.warn('accessing `'+name+'` is deprecated. Use `require("'+modulePath+'").'+name+'`');
return loadedModule[name];
console.warn('accessing `'+name+'` is deprecated. Use `require("'+module_path+'").'+name+'`');
return require(module_path)[name];
},
enumerable: true,
configurable: false
});
};
}
define(function(){
"use strict";
// expose modules
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');
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');
//// exposed constructors
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('CommManager','services/kernels/comm')
jglobal('Comm','services/kernels/comm')
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');
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');
// notebook
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');
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');
// tree
if (!Jupyter.hasOwnProperty('SessionList')) jglobal('SessionList',require('tree/js/sessionlist'), 'tree/js/sessionlist');
jglobal('SessionList','tree/js/sessionlist');
Jupyter.version = "5.0.0.dev";
Jupyter._target = '_blank';
@ -82,4 +79,4 @@ define(function(){
});
// deprecated since 4.0, remove in 5+
window['IPython'] = Jupyter;
var IPython = Jupyter;

@ -2,8 +2,9 @@
// 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

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

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

@ -2,8 +2,9 @@
// 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; };
@ -116,7 +117,7 @@ define([
if (allow_css) {
// sanitize style tags as stylesheets
sanitized = sanitize_stylesheets(result.sanitized, policy);
sanitized = sanitize_stylesheets(sanitized, policy);
}
return sanitized;

@ -1,10 +0,0 @@
// 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;
});

@ -1,12 +0,0 @@
// 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;
});

@ -2,12 +2,13 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'codemirror/lib/codemirror',
'moment',
'underscore',
// silently upgrades CodeMirror
'codemirror/mode/meta',
], function(CodeMirror, moment, _){
], function($, CodeMirror, moment, _){
"use strict";
// keep track of which extensions have been loaded already
@ -34,7 +35,7 @@ define([
requirejs([ext_path], function(module) {
if (!is_loaded(extension)) {
console.log("Loading extension: " + extension);
if (module.load_ipython_extension) {
if (module && module.load_ipython_extension) {
Promise.resolve(module.load_ipython_extension()).then(function() {
resolve(module);
}).catch(reject);

@ -1,79 +0,0 @@
// 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];
});
});

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

@ -1,9 +1,9 @@
// 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',
'contents',
'base/js/namespace',
'base/js/utils',
'base/js/page',
@ -14,6 +14,8 @@ require([
'edit/js/savewidget',
'edit/js/notificationarea',
], function(
$,
contents_service,
IPython,
utils,
page,
@ -41,7 +43,7 @@ require([
config.load();
var common_config = new configmod.ConfigSection('common', {base_url: base_url});
common_config.load();
contents = new contents.Contents({
contents = new contents_service.Contents({
base_url: base_url,
common_config: common_config
});
@ -100,4 +102,3 @@ require([
// On document ready, resize codemirror.
$(document).ready(_handle_resize);
});
});

@ -2,12 +2,13 @@
// 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',
], function(IPython, utils, dialog, CodeMirror) {
], function($, IPython, utils, dialog, CodeMirror) {
"use strict";
var MenuBar = function (selector, options) {

@ -2,11 +2,12 @@
// 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) {

@ -1,70 +0,0 @@
// 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'),
};

@ -1,10 +1,11 @@
// 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

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

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

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

@ -2,10 +2,11 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/namespace',
'base/js/utils',
'base/js/dialog'
], function(Jupyter, utils, dialog) {
], function($, Jupyter, utils, dialog) {
var jcbprefix = '<pre class="jupyter-nb-cells-json">';
var jcbsuffix = '</pre>';

@ -10,6 +10,7 @@
define([
'jquery',
'base/js/namespace',
'base/js/utils',
'base/js/keyboard',
@ -21,7 +22,9 @@ define([
'codemirror/lib/codemirror',
'codemirror/mode/python/python',
'notebook/js/codemirror-ipython'
], function(IPython,
], function(
$,
IPython,
utils,
keyboard,
configmod,

@ -5,35 +5,34 @@
(function(mod) {
if (typeof exports == "object" && typeof module == "object"){ // CommonJS
mod(require("codemirror/lib/codemirror")
mod(require("codemirror/lib/codemirror"),
require("codemirror/mode/python/python")
);
} else if (typeof define == "function" && define.amd){ // AMD
define(["codemirror/lib/codemirror"], mod);
define(["codemirror/lib/codemirror",
"codemirror/mode/python/python"], mod);
} else {// Plain browser env
mod(CodeMirror);
}
})(function(CodeMirror) {
"use strict";
requirejs(['codemirror/mode/python/python'], function () {
CodeMirror.defineMode("ipython", function(conf, parserConf) {
var pythonConf = {};
for (var prop in parserConf) {
if (parserConf.hasOwnProperty(prop)) {
pythonConf[prop] = parserConf[prop];
}
CodeMirror.defineMode("ipython", function(conf, parserConf) {
var pythonConf = {};
for (var prop in parserConf) {
if (parserConf.hasOwnProperty(prop)) {
pythonConf[prop] = parserConf[prop];
}
pythonConf.name = 'python';
pythonConf.singleOperators = new RegExp("^[\\+\\-\\*/%&|@\\^~<>!\\?]");
if (pythonConf.version === 3) {
pythonConf.identifiers = new RegExp("^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*");
} else if (pythonConf.version === 2) {
pythonConf.identifiers = new RegExp("^[_A-Za-z][_A-Za-z0-9]*");
}
return CodeMirror.getMode(conf, pythonConf);
}, 'python');
CodeMirror.defineMIME("text/x-ipython", "ipython");
}
pythonConf.name = 'python';
pythonConf.singleOperators = new RegExp("^[\\+\\-\\*/%&|@\\^~<>!\\?]");
if (pythonConf.version === 3) {
pythonConf.identifiers = new RegExp("^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*");
} else if (pythonConf.version === 2) {
pythonConf.identifiers = new RegExp("^[_A-Za-z][_A-Za-z0-9]*");
}
return CodeMirror.getMode(conf, pythonConf);
}, 'python');
});
CodeMirror.defineMIME("text/x-ipython", "ipython");
})

@ -10,9 +10,15 @@
(function(mod) {
if (typeof exports == "object" && typeof module == "object"){ // CommonJS
mod(require("codemirror/lib/codemirror")
,require("codemirror/addon/mode/multiplex")
,require("codemirror/mode/gfm/gfm")
,require("codemirror/mode/stex/stex")
);
} else if (typeof define == "function" && define.amd){ // AMD
define(["codemirror/lib/codemirror"
,"codemirror/addon/mode/multiplex"
,"codemirror/mode/python/python"
,"codemirror/mode/stex/stex"
], mod);
} else {// Plain browser env
mod(CodeMirror);
@ -20,51 +26,37 @@
})( function(CodeMirror){
"use strict";
requirejs(["codemirror/addon/mode/multiplex", "codemirror/mode/gfm/gfm", "codemirror/mode/stex/stex"], function () {
CodeMirror.defineMode("ipythongfm", function(config, parserConfig) {
var gfm_mode = CodeMirror.getMode(config, "gfm");
var tex_mode = CodeMirror.getMode(config, "stex");
return CodeMirror.multiplexingMode(
gfm_mode,
{
open: "$", close: "$",
mode: tex_mode,
delimStyle: "delimit"
},
{
// not sure this works as $$ is interpreted at (opening $, closing $, as defined just above)
open: "$$", close: "$$",
mode: tex_mode,
delimStyle: "delimit"
},
{
open: "\\(", close: "\\)",
mode: tex_mode,
delimStyle: "delimit"
},
{
open: "\\[", close: "\\]",
mode: tex_mode,
delimStyle: "delimit"
}
// .. more multiplexed styles can follow here
);
}, 'gfm');
CodeMirror.defineMIME("text/x-ipythongfm", "ipythongfm");
CodeMirror.defineMode("ipythongfm", function(config, parserConfig) {
var gfm_mode = CodeMirror.getMode(config, "gfm");
var tex_mode = CodeMirror.getMode(config, "stex");
return CodeMirror.multiplexingMode(
gfm_mode,
{
open: "$", close: "$",
mode: tex_mode,
delimStyle: "delimit"
},
{
// not sure this works as $$ is interpreted at (opening $, closing $, as defined just above)
open: "$$", close: "$$",
mode: tex_mode,
delimStyle: "delimit"
},
{
open: "\\(", close: "\\)",
mode: tex_mode,
delimStyle: "delimit"
},
{
open: "\\[", close: "\\]",
mode: tex_mode,
delimStyle: "delimit"
}
// .. more multiplexed styles can follow here
);
}, 'gfm');
// async workaround:
// Cells may be loaded before this mode is defined.
// If that happens, trigger re-load of the mode:
if (Jupyter && Jupyter.notebook) {
Jupyter.notebook.get_cells().map(function (cell) {
if (cell.code_mirror && cell.code_mirror.getOption('mode') === 'ipythongfm') {
cell.code_mirror.setOption('mode', 'ipythongfm');
}
});
}
});
});
CodeMirror.defineMIME("text/x-ipythongfm", "ipythongfm");
})

@ -4,6 +4,8 @@
define(function(require){
"use strict";
var $ = require('jquery');
require('typeahead');
var QH = require("notebook/js/quickhelp");
/**

@ -2,11 +2,12 @@
// 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

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

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

@ -1,6 +1,5 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
__webpack_public_path__ = window['staticURL'] + 'notebook/js/built/';
// adapted from Mozilla Developer Network example at
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind
@ -21,10 +20,10 @@ var bind = function bind(obj) {
Function.prototype.bind = Function.prototype.bind || bind ;
requirejs(['contents'], function(contentsModule) {
require([
'base/js/namespace',
'jquery',
'contents',
'base/js/namespace',
'notebook/js/notebook',
'services/config',
'base/js/utils',
@ -45,8 +44,9 @@ require([
'notebook/js/searchandreplace',
'notebook/js/clipboard'
], function(
IPython,
$,
contents_service,
IPython,
notebook,
configmod,
utils,
@ -75,7 +75,7 @@ require([
try{
requirejs(['custom/custom'], function() {});
} catch(err) {
console.log("Error processing custom.js. Logging and continuing")
console.log("Error processing custom.js. Logging and continuing");
console.warn(err);
}
@ -113,7 +113,7 @@ require([
events: events,
keyboard_manager: keyboard_manager});
acts.extend_env({save_widget:save_widget});
var contents = new contentsModule.Contents({
var contents = new contents_service.Contents({
base_url: common_options.base_url,
common_config: common_config
});
@ -232,4 +232,3 @@ require([
notebook.load_notebook(common_options.notebook_path);
});
});

@ -2,10 +2,11 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'require',
'./toolbar',
'./celltoolbar'
], function(require, toolbar, celltoolbar) {
], function($, require, toolbar, celltoolbar) {
"use strict";
var MainToolBar = function (selector, options) {

@ -2,9 +2,10 @@
// 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 () {

@ -2,13 +2,14 @@
// 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) {

@ -5,31 +5,61 @@
* @module notebook
*/
"use strict";
import IPython from 'base/js/namespace';
import _ from 'underscore';
import utils from 'base/js/utils';
import dialog from 'base/js/dialog';
import cellmod from 'notebook/js/cell';
import textcell from 'notebook/js/textcell';
import codecell from 'notebook/js/codecell';
import moment from 'moment';
import configmod from 'services/config';
import session from 'services/sessions/session';
import celltoolbar from 'notebook/js/celltoolbar';
import marked from 'components/marked/lib/marked';
import CodeMirror from 'codemirror/lib/codemirror';
import runMode from 'codemirror/addon/runmode/runmode';
import mathjaxutils from 'notebook/js/mathjaxutils';
import keyboard from 'base/js/keyboard';
import tooltip from 'notebook/js/tooltip';
import default_celltoolbar from 'notebook/js/celltoolbarpresets/default';
import rawcell_celltoolbar from 'notebook/js/celltoolbarpresets/rawcell';
import slideshow_celltoolbar from 'notebook/js/celltoolbarpresets/slideshow';
import attachments_celltoolbar from 'notebook/js/celltoolbarpresets/attachments';
import scrollmanager from 'notebook/js/scrollmanager';
import commandpalette from 'notebook/js/commandpalette';
import {ShortcutEditor} from 'notebook/js/shortcuteditor';
define([
'jquery',
'base/js/namespace',
'underscore',
'base/js/utils',
'base/js/dialog',
'./cell',
'./textcell',
'./codecell',
'moment',
'services/config',
'services/sessions/session',
'./celltoolbar',
'components/marked/lib/marked',
'codemirror/lib/codemirror',
'codemirror/addon/runmode/runmode',
'./mathjaxutils',
'base/js/keyboard',
'./tooltip',
'./celltoolbarpresets/default',
'./celltoolbarpresets/rawcell',
'./celltoolbarpresets/slideshow',
'./celltoolbarpresets/attachments',
'./scrollmanager',
'./commandpalette',
'./shortcuteditor',
], function (
$,
IPython,
_,
utils,
dialog,
cellmod,
textcell,
codecell,
moment,
configmod,
session,
celltoolbar,
marked,
CodeMirror,
runMode,
mathjaxutils,
keyboard,
tooltip,
default_celltoolbar,
rawcell_celltoolbar,
slideshow_celltoolbar,
attachments_celltoolbar,
scrollmanager,
commandpalette,
shortcuteditor
) {
var ShortcutEditor = shortcuteditor.ShortcutEditor;
var _SOFT_SELECTION_CLASS = 'jupyter-soft-selected';
function soft_selected(cell){
@ -50,7 +80,7 @@ import {ShortcutEditor} from 'notebook/js/shortcuteditor';
* @param {string} options.notebook_path
* @param {string} options.notebook_name
*/
export function Notebook(selector, options) {
function Notebook(selector, options) {
this.config = options.config;
this.class_config = new configmod.ConfigWithDefaults(this.config,
Notebook.options_default, 'Notebook');
@ -3231,3 +3261,6 @@ import {ShortcutEditor} from 'notebook/js/shortcuteditor';
this.events.trigger('checkpoint_deleted.Notebook');
this.load_notebook(this.notebook_path);
};
return {Notebook: Notebook};
})

@ -1,9 +1,10 @@
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;

@ -1,14 +1,15 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
// jshint esnext: true
define([
'jquery',
'base/js/utils',
'base/js/security',
'base/js/keyboard',
'services/config',
'notebook/js/mathjaxutils',
'components/marked/lib/marked',
], function(utils, security, keyboard, configmod, mathjaxutils, marked) {
], function($, utils, security, keyboard, configmod, mathjaxutils, marked) {
"use strict";
/**
@ -243,15 +244,15 @@ define([
};
// Declare mime type as constants
const MIME_JAVASCRIPT = 'application/javascript';
const MIME_HTML = 'text/html';
const MIME_MARKDOWN = 'text/markdown';
const MIME_LATEX = 'text/latex';
const MIME_SVG = 'image/svg+xml';
const MIME_PNG = 'image/png';
const MIME_JPEG = 'image/jpeg';
const MIME_PDF = 'application/pdf';
const MIME_TEXT = 'text/plain';
var MIME_JAVASCRIPT = 'application/javascript';
var MIME_HTML = 'text/html';
var MIME_MARKDOWN = 'text/markdown';
var MIME_LATEX = 'text/latex';
var MIME_SVG = 'image/svg+xml';
var MIME_PNG = 'image/png';
var MIME_JPEG = 'image/jpeg';
var MIME_PDF = 'application/pdf';
var MIME_TEXT = 'text/plain';
OutputArea.output_types = [
@ -263,7 +264,7 @@ define([
MIME_PNG,
MIME_JPEG,
MIME_PDF,
MIME_TEXT
MIME_TEXT,
];
OutputArea.prototype.validate_mimebundle = function (bundle) {
@ -632,14 +633,12 @@ define([
}
};
OutputArea.safe_outputs = {};
OutputArea.safe_outputs[MIME_TEXT] = true;
OutputArea.safe_outputs[MIME_LATEX] = true;
OutputArea.safe_outputs[MIME_PNG] = true;
OutputArea.safe_outputs[MIME_JPEG] = true;
OutputArea.safe_outputs = {
[MIME_TEXT] : true,
[MIME_LATEX] : true,
[MIME_PNG] : true,
[MIME_JPEG] : true
};
OutputArea.prototype.append_mime_type = function (json, element, handle_inserted) {
for (var i=0; i < OutputArea.display_order.length; i++) {
var type = OutputArea.display_order[i];
@ -1052,17 +1051,16 @@ define([
MIME_TEXT
];
OutputArea.append_map = {
[MIME_TEXT] : append_text,
[MIME_HTML] : append_html,
[MIME_MARKDOWN]: append_markdown,
[MIME_SVG] : append_svg,
[MIME_PNG] : append_png,
[MIME_JPEG] : append_jpeg,
[MIME_LATEX] : append_latex,
[MIME_JAVASCRIPT] : append_javascript,
[MIME_PDF] : append_pdf
};
OutputArea.append_map = {};
OutputArea.append_map[MIME_TEXT] = append_text;
OutputArea.append_map[MIME_HTML] = append_html;
OutputArea.append_map[MIME_MARKDOWN] = append_markdown;
OutputArea.append_map[MIME_SVG] = append_svg;
OutputArea.append_map[MIME_PNG] = append_png;
OutputArea.append_map[MIME_JPEG] = append_jpeg;
OutputArea.append_map[MIME_LATEX] = append_latex;
OutputArea.append_map[MIME_JAVASCRIPT] = append_javascript;
OutputArea.append_map[MIME_PDF] = append_pdf;
OutputArea.prototype.mime_types = function () {
return OutputArea.display_order;

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

@ -2,10 +2,11 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/utils',
'base/js/dialog',
'underscore'
], function(utils, dialog, _) {
], function($, utils, dialog, _) {
"use strict";
var platform = utils.platform;
@ -267,7 +268,7 @@ define([
QuickHelp.prototype.build_edit_help = function (cm_shortcuts) {
var edit_shortcuts = this.keyboard_manager.edit_shortcuts.help();
edit_shortcuts = jQuery.merge(jQuery.merge([], cm_shortcuts), edit_shortcuts);
edit_shortcuts = $.merge($.merge([], cm_shortcuts), edit_shortcuts);
return build_div('<h4>Edit Mode (press <kbd>Enter</kbd> to enable)</h4>', edit_shortcuts);
};

@ -2,11 +2,12 @@
// 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) {

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

@ -1,6 +1,7 @@
define(function(require){
"use strict";
var $ = require('jquery');
var dialog = require('base/js/dialog');
/**

@ -1,12 +1,21 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
define([
"jquery",
"notebook/js/quickhelp",
"base/js/dialog",
'components/marked/lib/marked',
], function (
$,
QH,
dialog,
marked
) {
var render = preact.render;
var createClass = preactCompat.createClass;
var createElement = preactCompat.createElement;
import QH from "notebook/js/quickhelp";
import dialog from "base/js/dialog";
import {render} from "preact";
import {createElement, createClass} from "preact-compat";
import marked from 'components/marked/lib/marked';
/**
* Humanize the action name to be consumed by user.
@ -14,7 +23,7 @@ import marked from 'components/marked/lib/marked';
* <namespace>:<description-with-dashes>
* we drop <namespace> and replace dashes for space.
*/
const humanize_action_id = function(str) {
var humanize_action_id = function(str) {
return str.split(':')[1].replace(/-/g, ' ').replace(/_/g, '-');
};
@ -24,7 +33,7 @@ const humanize_action_id = function(str) {
* Wether an action have a keybinding or not.
**/
const KeyBinding = createClass({
var KeyBinding = createClass({
displayName: 'KeyBindings',
getInitialState: function() {
return {shrt:''};
@ -33,13 +42,15 @@ const KeyBinding = createClass({
this.setState({shrt:element.target.value});
},
render: function(){
const that = this;
const available = this.props.available(this.state.shrt);
const empty = (this.state.shrt === '');
var that = this;
var available = this.props.available(this.state.shrt);
var empty = (this.state.shrt === '');
return createElement('div', {className:'jupyter-keybindings'},
createElement('i', {className: "pull-right fa fa-plus", alt: 'add-keyboard-shortcut',
onClick:()=>{
available?that.props.onAddBindings(that.state.shrt, that.props.ckey):null;
onClick: function () {
if (available) {
that.props.onAddBindings(that.state.shrt, that.props.ckey);
}
that.state.shrt='';
}
}),
@ -47,27 +58,28 @@ const KeyBinding = createClass({
type:'text',
placeholder:'add shortcut',
className:'pull-right'+((available||empty)?'':' alert alert-danger'),
value:this.state.shrt,
onChange:this.handleShrtChange
value:that.state.shrt,
onChange:that.handleShrtChange
}),
this.props.shortcuts?this.props.shortcuts.map((item, index) => {
that.props.shortcuts ? that.props.shortcuts.map(function (item, index) {
return createElement('span', {className: 'pull-right'},
createElement('kbd', {}, [
item.h,
createElement('i', {className: "fa fa-times", alt: 'remove '+item.h,
onClick:()=>{
onClick:function () {
that.props.unbind(item.raw);
}
})
])
);
}):null,
createElement('div', {title: '(' +this.props.ckey + ')' , className:'jupyter-keybindings-text'}, this.props.display )
}): null,
createElement('div', {title: '(' + that.props.ckey + ')' ,
className:'jupyter-keybindings-text'}, that.props.display )
);
}
});
const KeyBindingList = createClass({
var KeyBindingList = createClass({
displayName: 'KeyBindingList',
getInitialState: function(){
return {data:[]};
@ -76,15 +88,17 @@ const KeyBindingList = createClass({
this.setState({data:this.props.callback()});
},
render: function() {
const childrens = this.state.data.map((binding)=>{
return createElement(KeyBinding, Object.assign({}, binding, {onAddBindings:(shortcut, action)=>{
this.props.bind(shortcut, action);
this.setState({data:this.props.callback()});
var that = this;
var childrens = this.state.data.map(function (binding) {
return createElement(KeyBinding, Object.assign({}, binding, {
onAddBindings: function (shortcut, action) {
that.props.bind(shortcut, action);
that.setState({data:that.props.callback()});
},
available:this.props.available,
unbind: (shortcut) => {
this.props.unbind(shortcut);
this.setState({data:this.props.callback()});
available: that.props.available,
unbind: function (shortcut) {
that.props.unbind(shortcut);
that.setState({data:that.props.callback()});
}
}));
});
@ -109,18 +123,18 @@ const KeyBindingList = createClass({
}
});
const get_shortcuts_data = function(notebook) {
const actions = Object.keys(notebook.keyboard_manager.actions._actions);
const src = [];
var get_shortcuts_data = function(notebook) {
var actions = Object.keys(notebook.keyboard_manager.actions._actions);
var src = [];
for (let i = 0; i < actions.length; i++) {
const action_id = actions[i];
const action = notebook.keyboard_manager.actions.get(action_id);
for (var i = 0; i < actions.length; i++) {
var action_id = actions[i];
var action = notebook.keyboard_manager.actions.get(action_id);
let shortcuts = notebook.keyboard_manager.command_shortcuts.get_action_shortcuts(action_id);
let hshortcuts;
var shortcuts = notebook.keyboard_manager.command_shortcuts.get_action_shortcuts(action_id);
var hshortcuts = [];
if (shortcuts.length > 0) {
hshortcuts = shortcuts.map((raw)=>{
hshortcuts = shortcuts.map(function (raw) {
return {h:QH._humanize_sequence(raw),raw:raw};}
);
}
@ -135,14 +149,14 @@ const get_shortcuts_data = function(notebook) {
};
export const ShortcutEditor = function(notebook) {
var ShortcutEditor = function(notebook) {
if(!notebook){
throw new Error("CommandPalette takes a notebook non-null mandatory arguement");
throw new Error("CommandPalette takes a notebook non-null mandatory argument");
}
const body = $('<div>');
const mod = dialog.modal({
var body = $('<div>');
var mod = dialog.modal({
notebook: notebook,
keyboard_manager: notebook.keyboard_manager,
title : "Edit Command mode Shortcuts",
@ -152,22 +166,24 @@ export const ShortcutEditor = function(notebook) {
}
});
const src = get_shortcuts_data(notebook);
var src = get_shortcuts_data(notebook);
mod.addClass("modal_stretch");
mod.modal('show');
render(
createElement(KeyBindingList, {
callback:()=>{ return get_shortcuts_data(notebook);},
bind: (shortcut, command) => {
callback: function () { return get_shortcuts_data(notebook);},
bind: function (shortcut, command) {
return notebook.keyboard_manager.command_shortcuts._persist_shortcut(shortcut, command);
},
unbind: (shortcut) => {
unbind: function (shortcut) {
return notebook.keyboard_manager.command_shortcuts._persist_remove_shortcut(shortcut);
},
available: (shrt) => { return notebook.keyboard_manager.command_shortcuts.is_available_shortcut(shrt);}
available: function (shrt) { return notebook.keyboard_manager.command_shortcuts.is_available_shortcut(shrt);}
}),
body.get(0)
);
};
return {ShortcutEditor: ShortcutEditor};
});

@ -2,6 +2,7 @@
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/utils',
'notebook/js/cell',
'base/js/security',
@ -13,6 +14,7 @@ define([
'codemirror/mode/gfm/gfm',
'notebook/js/codemirror-ipythongfm'
], function(
$,
utils,
cell,
security,

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

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

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

@ -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) {

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

@ -2,11 +2,12 @@
// 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";
/**
@ -29,6 +30,7 @@ define([
this.id = null;
this.name = name;
this.ws = null;
this._stopping = false;
this.kernel_service_url = kernel_service_url;
this.kernel_url = null;
@ -506,7 +508,7 @@ define([
this.ws.onerror = ws_error;
// switch from early-close to late-close message after 1s
setTimeout(function() {
if (that.ws !== null) {
if (that.ws !== null && !that._stopping) {
that.ws.onclose = ws_closed_late;
}
}, 1000);
@ -577,11 +579,14 @@ define([
*/
var that = this;
var close = function () {
that._stopping = false;
if (that.ws && that.ws.readyState === WebSocket.CLOSED) {
that.ws = null;
}
};
if (this.ws !== null) {
// flag to avoid races with on_close_late
this._stopping = true;
if (this.ws.readyState === WebSocket.OPEN) {
this.ws.onclose = close;
this.ws.close();
@ -978,7 +983,7 @@ define([
*/
Kernel.prototype.output_callback_overrides_push = function(msg_id, callback_id) {
var output_callbacks = this._msg_callbacks_overrides[msg_id];
if (output_callbacks === void 0) {
if (!output_callbacks) {
this._msg_callbacks_overrides[msg_id] = output_callbacks = [];
}
output_callbacks.push(callback_id);

@ -2,9 +2,10 @@
// 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";
/**

@ -1,15 +1,15 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
__webpack_public_path__ = window['staticURL'] + 'terminal/js/built/';
require('xterm/src/xterm.css');
require([
'jquery',
'base/js/utils',
'base/js/page',
'auth/js/loginwidget',
'services/config',
'terminal/js/terminado',
], function(
$,
utils,
page,
loginwidget,

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

@ -1,6 +1,5 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
__webpack_public_path__ = window['staticURL'] + 'tree/js/built/';
// adapted from Mozilla Developer Network example at
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind
@ -21,8 +20,9 @@ var bind = function bind(obj) {
Function.prototype.bind = Function.prototype.bind || bind ;
requirejs(['contents'], function(contents_service) {
require([
'jquery',
'contents',
'base/js/namespace',
'base/js/dialog',
'base/js/events',
@ -36,6 +36,8 @@ require([
'tree/js/newnotebook',
'auth/js/loginwidget',
], function(
$,
contents_service,
IPython,
dialog,
events,
@ -199,4 +201,3 @@ require([
$("#tabs").find("a[href=" + window.location.hash + "]").click();
}
});
});

@ -2,10 +2,11 @@
// 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) {

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

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

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

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

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

@ -5,57 +5,47 @@
<meta charset="utf-8">
<title>{% block title %}Jupyter Notebook{% endblock %}</title>
{% block favicon %}<link id="favicon" rel="shortcut icon" type="image/x-icon" href="{{static_url("base/images/favicon.ico") }}">{% endblock %}
{% block favicon %}<link rel="shortcut icon" type="image/x-icon" href="{{static_url("base/images/favicon.ico") }}">{% endblock %}
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<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/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.min.js") }}" type="text/javascript" charset="utf-8"></script> <!-- extends window.$ -->
<script src="{{static_url("components/codemirror/lib/codemirror.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{static_url("components/codemirror/mode/meta.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{static_url("components/requirejs/require.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{static_url("components/es6-promise/promise.min.js")}}" type="text/javascript" charset="utf-8"></script>
<script src="{{static_url('components/preact/dist/preact.min.js')}}" type="text/javascript"></script>
<script src="{{static_url('components/proptypes/index.js')}}" type="text/javascript"></script>
<script src="{{static_url('components/preact-compat/dist/preact-compat.min.js')}}" type="text/javascript"></script>
<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: {
'auth/js/main': 'auth/js/built/main.min',
'auth/js/main': 'auth/js/main.min',
custom : '{{ base_url }}custom',
nbextensions : '{{ base_url }}nbextensions',
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',
// 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'
termjs: 'components/xterm.js/dist/xterm',
typeahead: 'components/jquery-typeahead/dist/jquery.typeahead.min',
},
map: { // for backward compatibility
"*": {
"jqueryui": "jquery-ui",
}
"*": {
"jqueryui": "jquery-ui",
}
},
shim: {
typeahead: {
@ -83,75 +73,6 @@
}
},
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({
@ -159,37 +80,20 @@
'*':{
'contents': '{{ contents_js_source }}',
}
},
});
define("bootstrap", function () {
return window.$;
});
define("jquery", function () {
return window.$;
});
define("jqueryui", function () {
return window.$;
});
define("jquery-ui", function () {
return window.$;
});
define("codemirror/lib/codemirror", function () {
return window.CodeMirror;
});
define("codemirror/mode/meta", function () {
return window.CodeMirror;
});
define("CodeMirror", function () {
return window.CodeMirror;
}
});
// error-catching custom.js shim.
define("custom", function (require, exports, module) {
try {
var custom = require('custom/custom');
console.debug('loaded custom.js');
return custom;
} catch (e) {
console.error("error loading custom.js", e);
return {};
}
})
</script>
{% block meta %}
@ -217,7 +121,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">

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

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

@ -1,100 +0,0 @@
/**
* 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');
});
});
});

@ -17,5 +17,29 @@ casper.notebook_test(function () {
var result = this.get_output_cell(0);
this.test.assertEquals(result.text.trim(), jsver, 'IPython.version in JS matches server-side.');
});
// verify that requirejs loads the same CodeCell prototype at runtime as build time
this.thenEvaluate(function () {
require(['notebook/js/codecell'], function (codecell) {
codecell.CodeCell.prototype.test = function () {
return 'ok';
}
window._waitForMe = true;
})
})
this.waitFor(function () {
return this.evaluate(function () {
return window._waitForMe;
});
})
this.then(function () {
var result = this.evaluate(function () {
var cell = Jupyter.notebook.get_cell(0);
return cell.test();
});
this.test.assertEquals(result, 'ok', "runtime-requirejs loads the same modules")
})
});

@ -88,15 +88,15 @@ casper.notebook_test(function () {
// check that the new cell has attachments
this.then(function() {
var cell = this.evaluate(function() {
return IPython.notebook.get_selected_cell();
var cell_attachments = this.evaluate(function() {
return IPython.notebook.get_selected_cell().attachments;
});
var orig_cell = this.evaluate(function() {
return IPython.notebook.get_cell(0);
var orig_cell_attachments = this.evaluate(function() {
return IPython.notebook.get_cell(0).attachments;
});
var clip = this.evaluate(function() { return IPython.notebook.clipboard_attachments; });
// Check that the two cells have the same attachments
this.test.assertEquals(cell.attachments, orig_cell.attachments,
this.test.assertEquals(cell_attachments, orig_cell_attachments,
"both cells have the attachments");
});

@ -8,6 +8,17 @@ casper.get_notebook_server = function () {
return casper.cli.get("url") || ('http://127.0.0.1:' + port);
};
// casper.thenClick doesn't seem to trigger click events properly
casper.thenClick = function (selector) {
return this.thenEvaluate(function(selector) {
var el = $(selector);
if (el.length === 0) {
console.error("Missing element!", selector)
}
el.click();
}, {selector: selector})
}
casper.open_new_notebook = function () {
// Create and open a new notebook.
var baseUrl = this.get_notebook_server();

@ -9,38 +9,16 @@
"url": "https://github.com/jupyter/notebook.git"
},
"scripts": {
"lint": "eslint --quiet notebook/",
"bower": "bower install --allow-root --config.interactive=false",
"build:watch": "concurrent \"npm run build:css:watch\" \"npm run build:js:watch\"",
"build": "npm run build:js && npm run build:css",
"build:css": "concurrent \"npm run build:css:ipython\" \"npm run build:css:style\"",
"build:css:ipython": "lessc --include-path=notebook/static notebook/static/style/ipython.less notebook/static/style/ipython.min.css",
"build:css:style": "lessc --include-path=notebook/static notebook/static/style/style.less notebook/static/style/style.min.css",
"build:css:watch": "./scripts/less-watch ./notebook/static",
"build:js": "webpack",
"build:js:watch": "npm run build:js -- --watch"
"bower": "bower install",
"build": "python setup.py js css"
},
"devDependencies": {
"babel-cli": "^6.7.5",
"babel-core": "^6.7.4",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"bower": "*",
"concurrently": "^1.0.0",
"css-loader": "^0.23.1",
"eslint": "^2.8.0",
"json-loader": "^0.5.4",
"less": "~2",
"requirejs": "^2.1.17",
"style-loader": "^0.13.1",
"underscore": "^1.8.3",
"webpack": "^1.12.13"
"requirejs": "^2.1.17"
},
"dependencies": {
"es6-promise": "^4.0.5",
"moment": "^2.8.4",
"preact": "^4.5.1",
"preact-compat": "^1.7.0",
"xterm": "^2.1.0"
"preact": "^7.1.0",
"preact-compat": "^3.9.4"
}
}

@ -55,7 +55,7 @@ from setupbase import (
check_package_data_first,
CompileCSS,
CompileJS,
JavascriptDependencies,
Bower,
JavascriptVersion,
css_js_prerelease,
)
@ -119,7 +119,7 @@ setup_args['cmdclass'] = {
'sdist' : css_js_prerelease(sdist, strict=True),
'css' : CompileCSS,
'js' : CompileJS,
'jsdeps' : JavascriptDependencies,
'jsdeps' : Bower,
'jsversion' : JavascriptVersion,
}

@ -14,15 +14,16 @@ This includes:
from __future__ import print_function
import os
import pipes
import shutil
import sys
import pipes
from distutils import log
from distutils.cmd import Command
from distutils.version import LooseVersion
from fnmatch import fnmatch
from glob import glob
from subprocess import check_call, check_output
from multiprocessing.pool import ThreadPool
from subprocess import check_call
if sys.platform == 'win32':
from subprocess import list2cmdline
@ -119,14 +120,8 @@ 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.extend([
pjoin('static', app, 'js', 'built', '*main.min.js'),
])
static_data.extend([
pjoin('static', 'built', '*index.js'),
pjoin('static', 'services', 'built', '*contents.js'),
])
static_data.append(pjoin('static', app, 'js', 'main.min.js'))
components = pjoin("static", "components")
# select the components we actually need to install
# (there are lots of resources we bundle for sdist-reasons that we don't actually use)
@ -136,6 +131,7 @@ def find_package_data():
pjoin(components, "bootstrap-tour", "build", "css", "bootstrap-tour.min.css"),
pjoin(components, "bootstrap-tour", "build", "js", "bootstrap-tour.min.js"),
pjoin(components, "font-awesome", "css", "*.css"),
pjoin(components, "es6-promise", "*.js"),
pjoin(components, "font-awesome", "fonts", "*.*"),
pjoin(components, "google-caja", "html-css-sanitizer-minified.js"),
pjoin(components, "jquery", "jquery.min.js"),
@ -145,8 +141,15 @@ def find_package_data():
pjoin(components, "jquery-ui", "themes", "smoothness", "jquery-ui.min.css"),
pjoin(components, "jquery-ui", "themes", "smoothness", "images", "*"),
pjoin(components, "marked", "lib", "marked.js"),
pjoin(components, "preact", "dist", "preact.min.js"),
pjoin(components, "preact-compat", "dist", "preact-compat.min.js"),
pjoin(components, "proptypes", "index.js"),
pjoin(components, "requirejs", "require.js"),
pjoin(components, "underscore", "underscore-min.js"),
pjoin(components, "moment", "moment.js"),
pjoin(components, "moment", "min", "moment.min.js"),
pjoin(components, "xterm.js", "dist", "xterm.js"),
pjoin(components, "xterm.js", "dist", "xterm.css"),
pjoin(components, "text-encoding", "lib", "encoding.js"),
])
@ -322,49 +325,81 @@ def run(cmd, *args, **kwargs):
return check_call(cmd, *args, **kwargs)
def npm_install(cwd):
"""Run npm install in a directory and dedupe if necessary"""
try:
run(['npm', 'install', '--progress=false'], cwd=cwd)
except OSError as e:
print("Failed to run `npm install`: %s" % e, file=sys.stderr)
print("npm is required to build a development version of the notebook.", file=sys.stderr)
raise
shell = (sys.platform == 'win32')
version = check_output(['npm', '--version'], shell=shell).decode('utf-8')
if LooseVersion(version) < LooseVersion('3.0'):
try:
run(['npm', 'dedupe'], cwd=cwd)
except Exception as e:
print("Failed to run `npm dedupe`: %s" % e, file=sys.stderr)
print("Please install npm v3+ to build a development version of the notebook.")
raise
class JavascriptDependencies(Command):
description = "Fetch Javascript dependencies with npm and bower"
class Bower(Command):
description = "fetch static client-side components with bower"
user_options = [
('force', 'f', "force fetching of bower dependencies"),
]
def initialize_options(self):
pass
self.force = False
def finalize_options(self):
pass
self.force = bool(self.force)
bower_dir = pjoin(static, 'components')
node_modules = pjoin(repo_root, 'node_modules')
def run(self):
npm_install(repo_root)
def should_run(self):
if self.force:
return True
if not os.path.exists(self.bower_dir):
return True
# check npm packages
for pkg in ['preact', 'preact-compat', 'proptypes']:
npm_pkg = os.path.join(self.node_modules, pkg)
bower_pkg = os.path.join(self.bower_dir, pkg)
if not os.path.exists(npm_pkg) or not os.path.exists(bower_pkg):
return True
if mtime(bower_pkg) < mtime(npm_pkg):
return True
return mtime(self.bower_dir) < mtime(pjoin(repo_root, 'bower.json'))
def should_run_npm(self):
if not which('npm'):
print("npm unavailable", file=sys.stderr)
return False
if not os.path.exists(self.node_modules):
return True
return mtime(self.node_modules) < mtime(pjoin(repo_root, 'package.json'))
def npm_components(self):
"""Stage npm frontend dependencies into components"""
for pkg in ['preact', 'preact-compat', 'proptypes']:
npm_pkg = os.path.join(self.node_modules, pkg)
bower_pkg = os.path.join(self.bower_dir, pkg)
log.info("Staging %s -> %s" % (npm_pkg, bower_pkg))
if os.path.exists(bower_pkg):
shutil.rmtree(bower_pkg)
shutil.copytree(npm_pkg, bower_pkg)
def run(self):
if not self.should_run():
print("bower dependencies up to date")
return
if self.should_run_npm():
print("installing build dependencies with npm")
run(['npm', 'install'], cwd=repo_root)
os.utime(self.node_modules, None)
env = os.environ.copy()
env['PATH'] = npm_path
try:
run(['npm', 'run', 'bower'], cwd=repo_root)
except Exception as e:
print("Failed to run `npm run bower`: %s" % e, file=sys.stderr)
run(
['bower', 'install', '--allow-root', '--config.interactive=false'],
cwd=repo_root,
env=env
)
except OSError as e:
print("Failed to run bower: %s" % e, file=sys.stderr)
print("You can install js dependencies with `npm install`", file=sys.stderr)
raise
self.npm_components()
os.utime(self.bower_dir, None)
# update package data in case this created new files
update_package_data(self.distribution)
@ -385,17 +420,29 @@ class CompileCSS(Command):
def finalize_options(self):
pass
sources = []
targets = []
for name in ('ipython', 'style'):
sources.append(pjoin(static, 'style', '%s.less' % name))
targets.append(pjoin(static, 'style', '%s.min.css' % name))
def run(self):
try:
run(['npm', 'run', 'build:css'])
except OSError as e:
print("Failed to run npm run build:css : %s" % e, file=sys.stderr)
print("You can install js dependencies with `npm install`", file=sys.stderr)
raise
self.run_command('jsdeps')
env = os.environ.copy()
env['PATH'] = npm_path
for src, dst in zip(self.sources, self.targets):
try:
run(['lessc',
'--source-map',
'--include-path=%s' % pipes.quote(static),
src,
dst,
], cwd=repo_root, env=env)
except OSError as e:
print("Failed to build css: %s" % e, file=sys.stderr)
print("You can install js dependencies with `npm install`", file=sys.stderr)
raise
# update package data in case this created new files
update_package_data(self.distribution)
@ -416,39 +463,56 @@ class CompileJS(Command):
def finalize_options(self):
self.force = bool(self.force)
target = pjoin(static, 'built', 'index.js')
targets = [target]
apps = ['notebook', 'tree', 'edit', 'terminal', 'auth']
targets = [ pjoin(static, app, 'js', 'main.min.js') for app in apps ]
def sources(self):
def sources(self, name):
"""Generator yielding .js sources that an application depends on"""
yield pjoin(repo_root, 'package.json')
yield pjoin(repo_root, 'webpack.config.js')
for parent, dirs, files in os.walk(static):
if os.path.basename(parent) in {'MathJax', 'built'}:
yield pjoin(repo_root, 'tools', 'build-main.js')
yield pjoin(static, name, 'js', 'main.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')
if name == 'notebook':
for f in glob(pjoin(static, 'services', '*', '*.js')):
yield f
for parent, dirs, files in os.walk(pjoin(static, 'components')):
if os.path.basename(parent) == 'MathJax':
# don't look in MathJax, since it takes forever to walk it
# also don't look at build targets as sources
dirs[:] = []
continue
for f in files:
if not f.endswith('.js'):
continue
yield pjoin(parent, f)
def should_run(self):
if self.force or not os.path.exists(self.target):
print("Missing %s" % self.target)
def should_run(self, name, target):
if self.force or not os.path.exists(target):
return True
target_mtime = mtime(self.target)
for source in self.sources():
target_mtime = mtime(target)
for source in self.sources(name):
if mtime(source) > target_mtime:
print('%s > %s' % (source, self.target))
print(source, target)
return True
return False
def build_main(self, name):
"""Build main.min.js"""
target = pjoin(static, name, 'js', '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])
def run(self):
self.run_command('jsdeps')
if self.should_run():
run(['npm', 'run', 'build:js'])
env = os.environ.copy()
env['PATH'] = npm_path
pool = ThreadPool()
pool.map(self.build_main, self.apps)
# update package data in case this created new files
update_package_data(self.distribution)
@ -466,27 +530,17 @@ class JavascriptVersion(Command):
def run(self):
nsfile = pjoin(repo_root, "notebook", "static", "base", "js", "namespace.js")
lines = []
found = False
with open(nsfile) as f:
for line in f.readlines():
if line.strip().startswith("Jupyter.version"):
found = True
new_line = ' Jupyter.version = "{0}";\n'.format(version)
if new_line == line:
# no change, don't rewrite file
return
lines.append(new_line)
else:
lines.append(line)
if not found:
raise RuntimeError("Didn't find Jupyter.version line in %s" % nsfile)
print("Writing version=%s to %s" % (version, nsfile))
lines = f.readlines()
with open(nsfile, 'w') as f:
found = False
for line in lines:
if line.strip().startswith("Jupyter.version"):
line = ' Jupyter.version = "{0}";\n'.format(version)
found = True
f.write(line)
if not found:
raise RuntimeError("Didn't find Jupyter.version line in %s" % nsfile)
def css_js_prerelease(command, strict=False):
@ -497,8 +551,7 @@ def css_js_prerelease(command, strict=False):
jsdeps = self.distribution.get_command_obj('jsdeps')
js = self.distribution.get_command_obj('js')
css = self.distribution.get_command_obj('css')
js.force = strict
jsdeps.force = js.force = strict
targets = [ jsdeps.bower_dir ]
targets.extend(js.targets)
@ -521,11 +574,11 @@ def css_js_prerelease(command, strict=False):
# die if strict or any targets didn't build
prefix = os.path.commonprefix([repo_root + os.sep] + missing)
missing = [ m[len(prefix):] for m in missing ]
log.warning("rebuilding js and css failed. The following required files are missing: %s" % missing)
log.warn("rebuilding js and css failed. The following required files are missing: %s" % missing)
raise e
else:
log.warning("rebuilding js and css failed (not a problem)")
log.warning(str(e))
log.warn("rebuilding js and css failed (not a problem)")
log.warn(str(e))
# check again for missing targets, just in case:
missing = [ t for t in targets if not os.path.exists(t) ]

@ -0,0 +1,68 @@
// 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',
xterm: 'components/xterm.js/dist/xterm',
typeahead: 'components/jquery-typeahead/dist/jquery.typeahead',
contents: 'empty:',
custom: '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);
});

@ -1,93 +0,0 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
// See https://github.com/webpack/css-loader/issues/144
var webpack = require('webpack');
var _ = require('underscore');
var path = require('path');
var sourcemaps = 'inline-source-map';
if(process.argv.indexOf('-w') !== -1 || process.argv.indexOf('-w') !== -1 ){
console.log('watch mode detected, will switch to cheap sourcemaps');
sourcemaps = 'eval-source-map';
}
var commonConfig = {
resolve: {
root: [
'.', /* allows npm packages to be loaded */
'./notebook/static'
].map(function(p) {return path.resolve(p);}),
modulesDirectories: [
"components", /* bower */
"node_modules" /* npm */
]
},
bail: true,
module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules|\/notebook\/static\/component/, loader: "babel-loader"},
{ 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',
'codemirror': 'CodeMirror',
'codemirror/lib/codemirror': 'CodeMirror',
'codemirror/mode/meta': 'CodeMirror',
// Account for relative paths from other CodeMirror files
'../../lib/codemirror': 'CodeMirror',
'../lib/codemirror': 'CodeMirror'
},
};
function buildConfig(appName) {
if (typeof appName !== 'string') return appName;
return _.extend({}, commonConfig, {
entry: ['es6-promise/auto','./notebook/static/' + appName + '/js/main.js'],
output: {
filename: 'main.min.js',
path: path.join(__dirname, 'notebook', 'static', appName, 'js', 'built')
},
devtool: sourcemaps,
});
}
module.exports = [
'auth',
'edit',
'terminal',
'tree',
'notebook',
_.extend({}, commonConfig, {
entry: ['es6-promise/auto', './notebook/static/services/contents.js'],
output: {
filename: 'contents.js',
path: path.join(__dirname, 'notebook', 'static', 'services', 'built'),
libraryTarget: 'amd'
},
devtool: sourcemaps,
}),
_.extend({}, commonConfig, {
entry: ['es6-promise/auto', './notebook/static/index.js'],
output: {
filename: 'index.js',
path: path.join(__dirname, 'notebook', 'static', 'built'),
libraryTarget: 'amd'
},
devtool: sourcemaps,
}),
].map(buildConfig);
Loading…
Cancel
Save