mirror of
https://github.com/jupyter/notebook.git
synced 2025-04-18 14:10:26 +08:00
Revert "Use NPM, node ES5, and browserify."
This commit is contained in:
parent
62101281e0
commit
2d5d548d79
14
.gitignore
vendored
14
.gitignore
vendored
@ -25,17 +25,3 @@ src
|
||||
|
||||
*.swp
|
||||
*.map
|
||||
|
||||
.eggs/
|
||||
|
||||
# Bundled/generated JavaScript
|
||||
notebook/static/auth/js
|
||||
notebook/static/base/js
|
||||
notebook/static/edit/js
|
||||
notebook/static/notebook/js
|
||||
notebook/static/services
|
||||
notebook/static/terminal/js
|
||||
notebook/static/tree/js
|
||||
|
||||
# npm logs
|
||||
npm-debug.log
|
||||
|
@ -1,6 +0,0 @@
|
||||
{
|
||||
"browserify": true,
|
||||
"node": true,
|
||||
"jquery": true,
|
||||
"predef": [ "requirejs", "define", "Promise", "CodeMirror"]
|
||||
}
|
33
README.md
33
README.md
@ -27,36 +27,3 @@ pip install --pre -e .
|
||||
jupyter notebook
|
||||
```
|
||||
|
||||
## Working on the frontend
|
||||
The Notebook frontend depends on a wide set of libraries and package managers.
|
||||
NPM is used to macro manage the frontend build process. You can build the
|
||||
frontend Javascript and LESS by running
|
||||
|
||||
```
|
||||
npm run build
|
||||
```
|
||||
|
||||
If you need to build the Javascript alone
|
||||
|
||||
```
|
||||
npm run build:js
|
||||
```
|
||||
|
||||
Or LESS
|
||||
|
||||
```
|
||||
npm run build:css
|
||||
```
|
||||
|
||||
To build specific sub components, separate using a colon. i.e. to build only
|
||||
the terminal's Javascript
|
||||
|
||||
```
|
||||
npm run build:js:terminal
|
||||
```
|
||||
|
||||
To clean all built output
|
||||
|
||||
```
|
||||
npm run clean
|
||||
```
|
||||
|
17
bower.json
17
bower.json
@ -2,21 +2,20 @@
|
||||
"name": "jupyter-notebook-deps",
|
||||
"version": "0.0.1",
|
||||
"dependencies": {
|
||||
"es6-promise": "~1.0",
|
||||
"font-awesome": "components/font-awesome#~4.2.0",
|
||||
"requirejs": "~2.1",
|
||||
"google-caja": "5669",
|
||||
"MathJax": "components/MathJax#~2.5",
|
||||
"backbone": "components/backbone#~1.2",
|
||||
"bootstrap": "components/bootstrap#~3.3",
|
||||
"bootstrap-tour": "0.9.0",
|
||||
"codemirror": "~5.5",
|
||||
"es6-promise": "~1.0",
|
||||
"font-awesome": "components/font-awesome#~4.2.0",
|
||||
"google-caja": "5669",
|
||||
"jquery": "components/jquery#~2.0",
|
||||
"jquery-ui": "components/jqueryui#~1.10",
|
||||
"codemirror": "~5.5",
|
||||
|
||||
"term.js": "chjj/term.js#~0.0.4",
|
||||
"backbone": "components/backbone#~1.2",
|
||||
"marked": "~0.3",
|
||||
"MathJax": "components/MathJax#~2.5",
|
||||
"moment": "~2.8.4",
|
||||
"requirejs": "~2.1",
|
||||
"term.js": "chjj/term.js#~0.0.4",
|
||||
"text-encoding": "~0.1",
|
||||
"underscore": "components/underscore#~1.5",
|
||||
"jquery-typeahead": "~2.0.0"
|
||||
|
@ -1,35 +0,0 @@
|
||||
var amdWrap = require("amd-wrap-legacy");
|
||||
var glob = require("glob");
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var mkdirp = require("mkdirp");
|
||||
|
||||
var source = "./notebook/static-src";
|
||||
var destination = "./notebook/static";
|
||||
|
||||
glob(path.join(source, "**/*.js"), function(err, files) {
|
||||
if (err) {
|
||||
console.error('Could not glob files.', err);
|
||||
} else {
|
||||
files.forEach(function(file, index) {
|
||||
var toFile = path.join(destination, path.relative(source, file));
|
||||
fs.readFile(file, 'utf8', function (err, data) {
|
||||
if (err) {
|
||||
console.error('Could not read file ' + file, err);
|
||||
} else {
|
||||
mkdirp(path.dirname(toFile), function(err) {
|
||||
if (err) {
|
||||
console.error('Could not mkdirp ', err);
|
||||
} else {
|
||||
fs.writeFile(toFile, amdWrap(data), function(err) {
|
||||
if(err) {
|
||||
return console.error('Could not write file ' + toFile, err);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
@ -172,8 +172,8 @@ class IPythonHandler(AuthenticatedHandler):
|
||||
@property
|
||||
def contents_js_source(self):
|
||||
self.log.debug("Using contents: %s", self.settings.get('contents_js_source',
|
||||
'services/contents.bundle'))
|
||||
return self.settings.get('contents_js_source', 'services/contents.bundle')
|
||||
'services/contents'))
|
||||
return self.settings.get('contents_js_source', 'services/contents')
|
||||
|
||||
#---------------------------------------------------------------
|
||||
# Manager objects
|
||||
|
@ -1,35 +0,0 @@
|
||||
var fs = require('fs');
|
||||
var aliasify = require('aliasify');
|
||||
var browserify = require('browserify');
|
||||
var mkdirp = require("mkdirp");
|
||||
var path = require('path');
|
||||
|
||||
var aliasifyConfig = {
|
||||
aliases: {
|
||||
jqueryui: 'jquery-ui',
|
||||
termjs: 'term.js',
|
||||
caja: 'google-caja/html-css-sanitizer-minified'
|
||||
},
|
||||
verbose: false
|
||||
}
|
||||
|
||||
var b = browserify({
|
||||
paths: [
|
||||
__dirname + '/static-src',
|
||||
__dirname + '/static/components',
|
||||
],
|
||||
debug: true,
|
||||
fullPaths: true
|
||||
});
|
||||
|
||||
b.transform(aliasify, aliasifyConfig);
|
||||
var mkdirp = require("mkdirp");
|
||||
b.add(__dirname + '/static-src/' + process.argv[2]);
|
||||
var toFile = __dirname + '/static/' + process.argv[3];
|
||||
mkdirp(path.dirname(toFile), function(err) {
|
||||
if (err) {
|
||||
console.error('Could not mkdirp ', err);
|
||||
} else {
|
||||
b.bundle().pipe(fs.createWriteStream(toFile));
|
||||
}
|
||||
});
|
@ -1,14 +0,0 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
var IPython = require('base/js/namespace');
|
||||
var page = require('base/js/page');
|
||||
|
||||
module.exports = function loginMain() {
|
||||
var page_instance = new page.Page();
|
||||
$('button#login_submit').addClass("btn btn-default");
|
||||
page_instance.show();
|
||||
$('input#password_input').focus();
|
||||
|
||||
IPython.page = page_instance;
|
||||
};
|
@ -1,5 +0,0 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
exports.login_main = require('./loginmain');
|
||||
exports.logout_main = require('./logoutmain');
|
@ -1,94 +0,0 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* jquery, jquery-ui, and bootstrap all really on weird window level logic.
|
||||
* This module handles the global loading of those tools.
|
||||
*/
|
||||
module.exports = new Promise(function(resolve, reject) {
|
||||
if (window.hasOwnProperty('jquery')) {
|
||||
resolve();
|
||||
}
|
||||
|
||||
requirejs(['jquery'], function($) {
|
||||
var jQueryProperty = {
|
||||
get: function() {
|
||||
return $;
|
||||
},
|
||||
configurable: false
|
||||
};
|
||||
Object.defineProperty(window, '$', jQueryProperty);
|
||||
Object.defineProperty(window, 'jQuery', jQueryProperty);
|
||||
console.log('jQuery loaded and available in global namespace');
|
||||
|
||||
requirejs(['jqueryui', 'bootstrap'], function() {
|
||||
if ($.prototype.modal) {
|
||||
console.log('bootstrap loaded and injected into jQuery\'s namespace');
|
||||
} else {
|
||||
reject(new Error('bootstrap not injected into jQuery prototype'));
|
||||
}
|
||||
|
||||
if ($.prototype.draggable && $.prototype.resizable) {
|
||||
console.log('jQueryUI loaded and injected into jQuery\'s namespace');
|
||||
} else {
|
||||
reject(new Error('jQueryUI not injected into jQuery prototype'));
|
||||
}
|
||||
|
||||
requirejs([
|
||||
'codemirror/lib/codemirror',
|
||||
'codemirror/mode/meta',
|
||||
'codemirror/addon/comment/comment',
|
||||
'codemirror/addon/dialog/dialog',
|
||||
'codemirror/addon/edit/closebrackets',
|
||||
'codemirror/addon/edit/matchbrackets',
|
||||
'codemirror/addon/search/searchcursor',
|
||||
'codemirror/addon/search/search',
|
||||
'codemirror/keymap/emacs',
|
||||
'codemirror/keymap/sublime',
|
||||
'codemirror/keymap/vim',
|
||||
'codemirror/mode/python/python',
|
||||
'codemirror/addon/runmode/runmode',
|
||||
'codemirror/mode/gfm/gfm',
|
||||
'notebook/js/codemirror-ipython',
|
||||
'notebook/js/codemirror-ipythongfm'
|
||||
], function(CodeMirror) {
|
||||
var codeMirrorProperty = {
|
||||
get: function() {
|
||||
return CodeMirror;
|
||||
},
|
||||
configurable: false
|
||||
};
|
||||
Object.defineProperty(window, 'CodeMirror', codeMirrorProperty);
|
||||
console.log('CodeMirror loaded and available in global namespace');
|
||||
|
||||
|
||||
requirejs(['underscore'], function(_) {
|
||||
var underscoreProperty = {
|
||||
get: function() {
|
||||
return _;
|
||||
},
|
||||
configurable: false
|
||||
};
|
||||
Object.defineProperty(window, '_', underscoreProperty);
|
||||
console.log('underscore loaded and available in global namespace');
|
||||
|
||||
resolve();
|
||||
}, function(err) {
|
||||
console.error('could not load underscore');
|
||||
reject(err);
|
||||
});
|
||||
}, function(err) {
|
||||
console.error('could not load CodeMirror and/or it\'s plugins');
|
||||
reject(err);
|
||||
});
|
||||
}, function(err) {
|
||||
console.error('could not load jqueryui and/or bootstrap');
|
||||
reject(err);
|
||||
});
|
||||
}, function(err) {
|
||||
console.error('could not load jquery');
|
||||
reject(err);
|
||||
});
|
||||
});
|
@ -1,70 +0,0 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
"use strict";
|
||||
|
||||
if (!window.Jupyter) {
|
||||
var Jupyter = {};
|
||||
Jupyter.version = "4.1.0.dev";
|
||||
window.Jupyter = Jupyter;
|
||||
}
|
||||
|
||||
var jprop = function(name, loaded, module_path, global_mod) {
|
||||
if (!(window.Jupyter).hasOwnProperty(name)) {
|
||||
Object.defineProperty(window.Jupyter, name, {
|
||||
get: function() {
|
||||
console.warn('accessing `'+name+'` is deprecated. Use `require(\'' + module_path + '\')' + (global_mod ? '[\'' + name + '\']' : '') + '`');
|
||||
return global_mod ? loaded[name] : loaded;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// expose modules
|
||||
jprop('events', require('base/js/events'), 'base/js/events');
|
||||
jprop('utils', require('base/js/utils'), 'base/js/utils');
|
||||
jprop('security', require('base/js/security'), 'base/js/security');
|
||||
jprop('keyboard', require('base/js/keyboard'), 'base/js/keyboard');
|
||||
jprop('dialog', require('base/js/dialog'), 'base/js/dialog');
|
||||
jprop('mathjaxutils', require('notebook/js/mathjaxutils'), 'notebook/js/mathjaxutils');
|
||||
|
||||
//// exposed constructors
|
||||
jprop('CommManager', require('services/kernels/comm'), 'services/kernels/comm', true);
|
||||
jprop('Comm', require('services/kernels/comm'), 'services/kernels/comm', true);
|
||||
|
||||
jprop('NotificationWidget', require('base/js/notificationwidget'), 'base/js/notificationwidget', true);
|
||||
jprop('Kernel', require('services/kernels/kernel'), 'services/kernels/kernel', true);
|
||||
jprop('Session', require('services/sessions/session'), 'services/sessions/session', true);
|
||||
jprop('LoginWidget', require('auth/js/loginwidget'), 'auth/js/loginwidget', true);
|
||||
jprop('Page', require('base/js/page'), 'base/js/page', true);
|
||||
|
||||
// notebook
|
||||
jprop('TextCell', require('notebook/js/textcell'), 'notebook/js/textcell', true);
|
||||
jprop('OutputArea', require('notebook/js/outputarea'), 'notebook/js/outputarea', true);
|
||||
jprop('KeyboardManager', require('notebook/js/keyboardmanager'), 'notebook/js/keyboardmanager', true);
|
||||
jprop('Completer', require('notebook/js/completer'), 'notebook/js/completer', true);
|
||||
jprop('Notebook', require('notebook/js/notebook'), 'notebook/js/notebook', true);
|
||||
jprop('Tooltip', require('notebook/js/tooltip'), 'notebook/js/tooltip', true);
|
||||
jprop('ToolBar', require('notebook/js/toolbar'), 'notebook/js/toolbar', true);
|
||||
jprop('SaveWidget', require('notebook/js/savewidget'), 'notebook/js/savewidget', true);
|
||||
jprop('Pager', require('notebook/js/pager'), 'notebook/js/pager', true);
|
||||
jprop('QuickHelp', require('notebook/js/quickhelp'), 'notebook/js/quickhelp', true);
|
||||
jprop('MarkdownCell', require('notebook/js/textcell'), 'notebook/js/textcell', true);
|
||||
jprop('RawCell', require('notebook/js/textcell'), 'notebook/js/textcell', true);
|
||||
jprop('Cell', require('notebook/js/cell'), 'notebook/js/cell', true);
|
||||
jprop('MainToolBar', require('notebook/js/maintoolbar'), 'notebook/js/maintoolbar', true);
|
||||
jprop('NotebookNotificationArea', require('notebook/js/notificationarea'), 'notebook/js/notificationarea', true);
|
||||
jprop('NotebookTour', require( 'notebook/js/tour'), 'notebook/js/tour', true);
|
||||
jprop('MenuBar', require( 'notebook/js/menubar'), 'notebook/js/menubar', true);
|
||||
|
||||
// tree
|
||||
jprop('SessionList', require('tree/js/sessionlist'), 'tree/js/sessionlist', true);
|
||||
|
||||
window.Jupyter._target = '_blank';
|
||||
|
||||
// deprecated since 4.0, remove in 5+
|
||||
window.IPython = window.Jupyter;
|
||||
|
||||
module.exports = window.Jupyter;
|
14
notebook/static/auth/js/loginmain.js
Normal file
14
notebook/static/auth/js/loginmain.js
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define(['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");
|
||||
page_instance.show();
|
||||
$('input#password_input').focus();
|
||||
|
||||
IPython.page = page_instance;
|
||||
}
|
||||
return login_main;
|
||||
});
|
@ -1,10 +1,12 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'base/js/utils',
|
||||
'jquery',
|
||||
], function(utils, $){
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
|
||||
var LoginWidget = function (selector, options) {
|
||||
options = options || {};
|
||||
this.base_url = options.base_url || utils.get_body_data("baseUrl");
|
||||
@ -32,4 +34,5 @@
|
||||
});
|
||||
};
|
||||
|
||||
exports.LoginWidget = LoginWidget;
|
||||
return {'LoginWidget': LoginWidget};
|
||||
});
|
@ -1,12 +1,12 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
var IPython = require('base/js/namespace');
|
||||
var page = require('base/js/page');
|
||||
|
||||
module.exports = function logoutMain() {
|
||||
define(['base/js/namespace', 'base/js/page'], function(IPython, page) {
|
||||
function logout_main() {
|
||||
var page_instance = new page.Page();
|
||||
page_instance.show();
|
||||
|
||||
IPython.page = page_instance;
|
||||
};
|
||||
}
|
||||
return logout_main;
|
||||
});
|
9
notebook/static/auth/js/main.js
Normal file
9
notebook/static/auth/js/main.js
Normal file
@ -0,0 +1,9 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define(['./loginmain', './logoutmain'], function (login_main, logout_main) {
|
||||
return {
|
||||
login_main: login_main,
|
||||
logout_main: logout_main
|
||||
};
|
||||
});
|
@ -1,7 +1,11 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define(function(require) {
|
||||
"use strict";
|
||||
|
||||
var CodeMirror = require('codemirror/lib/codemirror');
|
||||
var $ = require('jquery');
|
||||
|
||||
/**
|
||||
* A wrapper around bootstrap modal for easier use
|
||||
@ -33,6 +37,7 @@
|
||||
*
|
||||
**/
|
||||
var modal = function (options) {
|
||||
|
||||
var modal = $("<div/>")
|
||||
.addClass("modal")
|
||||
.addClass("fade")
|
||||
@ -193,11 +198,13 @@
|
||||
});
|
||||
|
||||
modal_obj.on('shown.bs.modal', function(){ editor.refresh(); });
|
||||
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
var dialog = {
|
||||
modal : modal,
|
||||
kernel_modal : kernel_modal,
|
||||
edit_metadata : edit_metadata,
|
||||
};
|
||||
|
||||
return dialog;
|
||||
});
|
@ -8,11 +8,17 @@
|
||||
// require(['base/js/events'], function (events) {
|
||||
// events.on("event.Namespace", function () { do_stuff(); });
|
||||
// });
|
||||
"use strict";
|
||||
|
||||
if (!window.jupyterEvents) {
|
||||
define(['base/js/namespace', 'jquery'], function(IPython, $) {
|
||||
"use strict";
|
||||
|
||||
var Events = function () {};
|
||||
window.jupyterEvents = $([new Events()]);
|
||||
}
|
||||
|
||||
module.exports = window.jupyterEvents;
|
||||
|
||||
var events = new Events();
|
||||
|
||||
// Backwards compatability.
|
||||
IPython.Events = Events;
|
||||
IPython.events = events;
|
||||
|
||||
return $([events]);
|
||||
});
|
@ -8,10 +8,13 @@
|
||||
* @class ShortcutManager
|
||||
*/
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
'underscore',
|
||||
], function($, utils, _) {
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
|
||||
|
||||
/**
|
||||
* Setup global keycodes and inverse keycodes.
|
||||
@ -42,20 +45,20 @@
|
||||
'end': 35, 'home': 36, 'left': 37, 'up': 38, 'right': 39, 'down': 40,
|
||||
'insert': 45, 'delete': 46, 'numlock': 144,
|
||||
};
|
||||
|
||||
|
||||
// These apply to Firefox and Opera
|
||||
var _mozilla_keycodes = {
|
||||
'; :': 59, '= +': 61, '- _': 173, 'meta': 224, 'minus':173
|
||||
};
|
||||
|
||||
|
||||
// This apply to Webkit and IE
|
||||
var _ie_keycodes = {
|
||||
'; :': 186, '= +': 187, '- _': 189, 'minus':189
|
||||
};
|
||||
|
||||
|
||||
var browser = utils.browser[0];
|
||||
var platform = utils.platform;
|
||||
|
||||
|
||||
if (browser === 'Firefox' || browser === 'Opera' || browser === 'Netscape') {
|
||||
$.extend(_keycodes, _mozilla_keycodes);
|
||||
} else if (browser === 'Safari' || browser === 'Chrome' || browser === 'MSIE') {
|
||||
@ -452,7 +455,7 @@
|
||||
return (typeof(action_name) !== 'undefined');
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
var keyboard = {
|
||||
keycodes : keycodes,
|
||||
inv_keycodes : inv_keycodes,
|
||||
ShortcutManager : ShortcutManager,
|
||||
@ -461,3 +464,6 @@
|
||||
shortcut_to_event : shortcut_to_event,
|
||||
event_to_shortcut : event_to_shortcut,
|
||||
};
|
||||
|
||||
return keyboard;
|
||||
});
|
82
notebook/static/base/js/namespace.js
Normal file
82
notebook/static/base/js/namespace.js
Normal file
@ -0,0 +1,82 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
|
||||
var Jupyter = Jupyter || {};
|
||||
|
||||
var jprop = function(name, module_path){
|
||||
Object.defineProperty(Jupyter, name, {
|
||||
get: function() {
|
||||
console.warn('accessing `'+name+'` is deprecated. Use `require("'+module_path+'")`');
|
||||
return require(module_path);
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: false
|
||||
});
|
||||
}
|
||||
|
||||
var jglobal = function(name, module_path){
|
||||
Object.defineProperty(Jupyter, name, {
|
||||
get: function() {
|
||||
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
|
||||
|
||||
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
|
||||
jglobal('CommManager','services/kernels/comm')
|
||||
jglobal('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');
|
||||
|
||||
// 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');
|
||||
|
||||
// tree
|
||||
jglobal('SessionList','tree/js/sessionlist');
|
||||
|
||||
Jupyter.version = "4.1.0.dev";
|
||||
Jupyter._target = '_blank';
|
||||
return Jupyter;
|
||||
});
|
||||
|
||||
// deprecated since 4.0, remove in 5+
|
||||
var IPython = Jupyter
|
@ -1,10 +1,12 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/notificationwidget',
|
||||
], function($, notificationwidget) {
|
||||
"use strict";
|
||||
|
||||
var notificationwidget = require('base/js/notificationwidget');
|
||||
|
||||
// store reference to the NotificationWidget class
|
||||
var NotificationWidget = notificationwidget.NotificationWidget;
|
||||
|
||||
@ -77,4 +79,5 @@
|
||||
return this.widget_dict[name];
|
||||
};
|
||||
|
||||
exports.NotificationArea = NotificationArea;
|
||||
return {'NotificationArea': NotificationArea};
|
||||
});
|
@ -1,6 +1,9 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
], function($) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
@ -34,7 +37,7 @@
|
||||
// for this particular combination
|
||||
this.element.addClass('notification_widget btn btn-xs navbar-btn');
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* hide the widget and empty the text
|
||||
**/
|
||||
@ -163,4 +166,5 @@
|
||||
return this.inner.html();
|
||||
};
|
||||
|
||||
exports.NotificationWidget = NotificationWidget;
|
||||
return {'NotificationWidget': NotificationWidget};
|
||||
});
|
@ -1,9 +1,11 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/events',
|
||||
], function($, events){
|
||||
"use strict";
|
||||
|
||||
var events = require('base/js/events');
|
||||
|
||||
var Page = function () {
|
||||
this.bind_events();
|
||||
@ -56,4 +58,5 @@
|
||||
$('div#site').height($(window).height() - $('#header').height());
|
||||
};
|
||||
|
||||
exports.Page = Page;
|
||||
return {'Page': Page};
|
||||
});
|
@ -1,19 +1,21 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'components/google-caja/html-css-sanitizer-minified',
|
||||
], function($, sanitize) {
|
||||
"use strict";
|
||||
|
||||
var caja = require('caja');
|
||||
|
||||
|
||||
var noop = function (x) { return x; };
|
||||
|
||||
|
||||
var caja;
|
||||
if (window && window.html) {
|
||||
caja = window.html;
|
||||
caja.html4 = window.html4;
|
||||
caja.sanitizeStylesheet = window.sanitizeStylesheet;
|
||||
}
|
||||
|
||||
|
||||
var sanitizeAttribs = function (tagName, attribs, opt_naiveUriRewriter, opt_nmTokenPolicy, opt_logger) {
|
||||
/**
|
||||
* add trusting data-attributes to the default sanitizeAttribs from caja
|
||||
@ -31,7 +33,7 @@
|
||||
}
|
||||
return caja.sanitizeAttribs(tagName, attribs, opt_naiveUriRewriter, opt_nmTokenPolicy, opt_logger);
|
||||
};
|
||||
|
||||
|
||||
var sanitize_css = function (css, tagPolicy) {
|
||||
/**
|
||||
* sanitize CSS
|
||||
@ -50,7 +52,7 @@
|
||||
noop
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
var sanitize_stylesheets = function (html, tagPolicy) {
|
||||
/**
|
||||
* sanitize just the css in style tags in a block of html
|
||||
@ -67,7 +69,7 @@
|
||||
});
|
||||
return h.html();
|
||||
};
|
||||
|
||||
|
||||
var sanitize_html = function (html, allow_css) {
|
||||
/**
|
||||
* sanitize HTML
|
||||
@ -114,8 +116,11 @@
|
||||
|
||||
return sanitized;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
var security = {
|
||||
caja: caja,
|
||||
sanitize_html: sanitize_html
|
||||
};
|
||||
|
||||
return security;
|
||||
});
|
@ -1,10 +1,15 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'codemirror/lib/codemirror',
|
||||
'moment',
|
||||
// silently upgrades CodeMirror
|
||||
'codemirror/mode/meta',
|
||||
], function($, CodeMirror, moment){
|
||||
"use strict";
|
||||
|
||||
var moment = require('moment');
|
||||
|
||||
|
||||
/**
|
||||
* Load a single extension.
|
||||
* @param {string} extension - extension path.
|
||||
@ -12,7 +17,7 @@
|
||||
*/
|
||||
var load_extension = function (extension) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
requirejs(["nbextensions/" + extension], function(module) {
|
||||
require(["nbextensions/" + extension], function(module) {
|
||||
console.log("Loaded extension: " + extension);
|
||||
try {
|
||||
module.load_ipython_extension();
|
||||
@ -212,7 +217,7 @@
|
||||
"46":"ansibgcyan",
|
||||
"47":"ansibggray"
|
||||
};
|
||||
|
||||
|
||||
function _process_numbers(attrs, numbers) {
|
||||
// process ansi escapes
|
||||
var n = numbers.shift();
|
||||
@ -369,7 +374,7 @@
|
||||
test.remove();
|
||||
return Math.floor(points*pixel_per_point);
|
||||
};
|
||||
|
||||
|
||||
var always_new = function (constructor) {
|
||||
/**
|
||||
* wrapper around contructor to avoid requiring `var a = new constructor()`
|
||||
@ -402,7 +407,7 @@
|
||||
url = url.replace(/\/\/+/, '/');
|
||||
return url;
|
||||
};
|
||||
|
||||
|
||||
var url_path_split = function (path) {
|
||||
/**
|
||||
* Like os.path.split for URLs.
|
||||
@ -416,7 +421,7 @@
|
||||
return [ path.slice(0, idx), path.slice(idx + 1) ];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var parse_url = function (url) {
|
||||
/**
|
||||
* an `a` element with an href allows attr-access to the parsed segments of a URL
|
||||
@ -432,7 +437,7 @@
|
||||
a.href = url;
|
||||
return a;
|
||||
};
|
||||
|
||||
|
||||
var encode_uri_components = function (uri) {
|
||||
/**
|
||||
* encode just the components of a multi-segment uri,
|
||||
@ -440,7 +445,7 @@
|
||||
*/
|
||||
return uri.split('/').map(encodeURIComponent).join('/');
|
||||
};
|
||||
|
||||
|
||||
var url_join_encode = function () {
|
||||
/**
|
||||
* join a sequence of url components with '/',
|
||||
@ -483,7 +488,7 @@
|
||||
return val;
|
||||
return decodeURIComponent(val);
|
||||
};
|
||||
|
||||
|
||||
var to_absolute_cursor_pos = function (cm, cursor) {
|
||||
/**
|
||||
* get the absolute cursor position from CodeMirror's col, ch
|
||||
@ -497,7 +502,7 @@
|
||||
}
|
||||
return cursor_pos;
|
||||
};
|
||||
|
||||
|
||||
var from_absolute_cursor_pos = function (cm, cursor_pos) {
|
||||
/**
|
||||
* turn absolute cursor position into CodeMirror col, ch cursor
|
||||
@ -521,7 +526,7 @@
|
||||
ch : line.length - 1,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// http://stackoverflow.com/questions/2400935/browser-detection-in-javascript
|
||||
var browser = (function() {
|
||||
if (typeof navigator === 'undefined') {
|
||||
@ -548,7 +553,7 @@
|
||||
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
|
||||
return OSName;
|
||||
})();
|
||||
|
||||
|
||||
var get_url_param = function (name) {
|
||||
// get a URL parameter. I cannot believe we actually need this.
|
||||
// Based on http://stackoverflow.com/a/25359264/938949
|
||||
@ -557,7 +562,7 @@
|
||||
return decodeURIComponent(match[1] || '');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var is_or_has = function (a, b) {
|
||||
/**
|
||||
* Is b a child of a or a itself?
|
||||
@ -581,13 +586,13 @@
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var mergeopt = function(_class, options, overwrite){
|
||||
options = options || {};
|
||||
overwrite = overwrite || {};
|
||||
return $.extend(true, {}, _class.options_default, options, overwrite);
|
||||
};
|
||||
|
||||
|
||||
var ajax_error_msg = function (jqXHR) {
|
||||
/**
|
||||
* Return a JSON error message if there is one,
|
||||
@ -621,7 +626,6 @@
|
||||
var modename = (typeof mode == "string") ? mode :
|
||||
mode.mode || mode.name;
|
||||
|
||||
|
||||
// simplest, cheapest check by mode name: mode may also have config
|
||||
if (CodeMirror.modes.hasOwnProperty(modename)) {
|
||||
// return the full mode object, if it has a name
|
||||
@ -637,7 +641,7 @@
|
||||
CodeMirror.findModeByMIME(modename) ||
|
||||
{mode: modename, mime: modename};
|
||||
|
||||
requirejs([
|
||||
require([
|
||||
// might want to use CodeMirror.modeURL here
|
||||
['codemirror/mode', info.mode, info.mode].join('/'),
|
||||
], function() {
|
||||
@ -647,10 +651,10 @@
|
||||
}, errback
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/** Error type for wrapped XHR errors. */
|
||||
var XHR_ERROR = 'XhrError';
|
||||
|
||||
|
||||
/**
|
||||
* Wraps an AJAX error as an Error object.
|
||||
*/
|
||||
@ -663,7 +667,7 @@
|
||||
wrapped_error.xhr_error = error;
|
||||
return wrapped_error;
|
||||
};
|
||||
|
||||
|
||||
var promising_ajax = function(url, settings) {
|
||||
/**
|
||||
* Like $.ajax, but returning an ES6 promise. success and error settings
|
||||
@ -724,7 +728,7 @@
|
||||
|
||||
// Try loading the view module using require.js
|
||||
if (module_name) {
|
||||
requirejs([module_name], function(module) {
|
||||
require([module_name], function(module) {
|
||||
if (module[class_name] === undefined) {
|
||||
reject(new Error('Class '+class_name+' not found in module '+module_name));
|
||||
} else {
|
||||
@ -801,14 +805,14 @@
|
||||
return MathJax.Hub.Queue(["Typeset", MathJax.Hub, this]);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
var time = {};
|
||||
time.milliseconds = {};
|
||||
time.milliseconds.s = 1000;
|
||||
time.milliseconds.m = 60 * time.milliseconds.s;
|
||||
time.milliseconds.h = 60 * time.milliseconds.m;
|
||||
time.milliseconds.d = 24 * time.milliseconds.h;
|
||||
|
||||
|
||||
time.thresholds = {
|
||||
// moment.js thresholds in milliseconds
|
||||
s: moment.relativeTimeThreshold('s') * time.milliseconds.s,
|
||||
@ -816,7 +820,7 @@
|
||||
h: moment.relativeTimeThreshold('h') * time.milliseconds.h,
|
||||
d: moment.relativeTimeThreshold('d') * time.milliseconds.d,
|
||||
};
|
||||
|
||||
|
||||
time.timeout_from_dt = function (dt) {
|
||||
/** compute a timeout based on dt
|
||||
|
||||
@ -836,8 +840,8 @@
|
||||
return time.milliseconds.h;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
var utils = {
|
||||
load_extension: load_extension,
|
||||
load_extensions: load_extensions,
|
||||
load_extensions_from_config: load_extensions_from_config,
|
||||
@ -877,3 +881,6 @@
|
||||
typeset: typeset,
|
||||
time: time,
|
||||
};
|
||||
|
||||
return utils;
|
||||
});
|
@ -1,9 +1,26 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
'codemirror/lib/codemirror',
|
||||
'codemirror/mode/meta',
|
||||
'codemirror/addon/comment/comment',
|
||||
'codemirror/addon/dialog/dialog',
|
||||
'codemirror/addon/edit/closebrackets',
|
||||
'codemirror/addon/edit/matchbrackets',
|
||||
'codemirror/addon/search/searchcursor',
|
||||
'codemirror/addon/search/search',
|
||||
'codemirror/keymap/emacs',
|
||||
'codemirror/keymap/sublime',
|
||||
'codemirror/keymap/vim',
|
||||
],
|
||||
function($,
|
||||
utils,
|
||||
CodeMirror
|
||||
) {
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
|
||||
var Editor = function(selector, options) {
|
||||
var that = this;
|
||||
@ -42,7 +59,7 @@
|
||||
$('.last_modified').before(this.clean_sel);
|
||||
this.clean_sel.addClass('dirty-indicator-dirty');
|
||||
};
|
||||
|
||||
|
||||
// default CodeMirror options
|
||||
Editor.default_codemirror_options = {
|
||||
extraKeys: {
|
||||
@ -53,7 +70,7 @@
|
||||
lineNumbers: true,
|
||||
lineWrapping: true,
|
||||
};
|
||||
|
||||
|
||||
Editor.prototype.load = function() {
|
||||
/** load the file */
|
||||
var that = this;
|
||||
@ -124,7 +141,7 @@
|
||||
that.events.trigger("mode_changed.Editor", modeinfo);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Editor.prototype.get_filename = function () {
|
||||
return utils.url_path_split(this.file_path)[1];
|
||||
};
|
||||
@ -143,7 +160,7 @@
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Editor.prototype.save = function () {
|
||||
/** save the file */
|
||||
if (!this.save_enabled) {
|
||||
@ -193,7 +210,7 @@
|
||||
});
|
||||
var that = this;
|
||||
};
|
||||
|
||||
|
||||
Editor.prototype.update_codemirror_options = function (options) {
|
||||
/** update codemirror options locally and save changes in config */
|
||||
var that = this;
|
||||
@ -207,4 +224,5 @@
|
||||
);
|
||||
};
|
||||
|
||||
exports.Editor = Editor;
|
||||
return {Editor: Editor};
|
||||
});
|
@ -1,22 +1,33 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
require('base/js/globals').then(function() {
|
||||
|
||||
var IPython = require('base/js/namespace');
|
||||
var utils = require('base/js/utils');
|
||||
var page = require('base/js/page');
|
||||
var events = require('base/js/events');
|
||||
var configmod = require('services/config');
|
||||
var editmod = require('edit/js/editor');
|
||||
var menubar = require('edit/js/menubar');
|
||||
var savewidget = require('edit/js/savewidget');
|
||||
var notificationarea = require('edit/js/notificationarea');
|
||||
|
||||
// Contents must be loaded at runtime.
|
||||
requirejs(['contents', 'custom/custom'], function(contents_service) {
|
||||
|
||||
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,
|
||||
savewidget,
|
||||
notificationarea
|
||||
){
|
||||
"use strict";
|
||||
page = new page.Page();
|
||||
|
||||
var base_url = utils.get_body_data('baseUrl');
|
||||
@ -25,11 +36,11 @@ requirejs(['contents', 'custom/custom'], function(contents_service) {
|
||||
config.load();
|
||||
var common_config = new configmod.ConfigSection('common', {base_url: base_url});
|
||||
common_config.load();
|
||||
var contents = new contents_service.Contents({
|
||||
contents = new contents.Contents({
|
||||
base_url: base_url,
|
||||
common_config: common_config
|
||||
});
|
||||
|
||||
|
||||
var editor = new editmod.Editor('#texteditor-container', {
|
||||
base_url: base_url,
|
||||
events: events,
|
||||
@ -37,22 +48,22 @@ requirejs(['contents', 'custom/custom'], function(contents_service) {
|
||||
file_path: file_path,
|
||||
config: config,
|
||||
});
|
||||
|
||||
|
||||
// Make it available for debugging
|
||||
IPython.editor = editor;
|
||||
|
||||
|
||||
var save_widget = new savewidget.SaveWidget('span#save_widget', {
|
||||
editor: editor,
|
||||
events: events,
|
||||
});
|
||||
|
||||
|
||||
var menus = new menubar.MenuBar('#menubar', {
|
||||
base_url: base_url,
|
||||
editor: editor,
|
||||
events: events,
|
||||
save_widget: save_widget,
|
||||
});
|
||||
|
||||
|
||||
var notification_area = new notificationarea.EditorNotificationArea(
|
||||
'#notification_area', {
|
||||
events: events,
|
||||
@ -84,8 +95,3 @@ requirejs(['contents', 'custom/custom'], function(contents_service) {
|
||||
// On document ready, resize codemirror.
|
||||
$(document).ready(_handle_resize);
|
||||
});
|
||||
|
||||
}).catch(function(err) {
|
||||
console.error('Could not load globals', err);
|
||||
});
|
||||
|
@ -1,11 +1,17 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// 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) {
|
||||
"use strict";
|
||||
|
||||
var IPython = require('base/js/namespace');
|
||||
var utils = require('base/js/utils');
|
||||
var dialog = require('base/js/dialog');
|
||||
|
||||
|
||||
var MenuBar = function (selector, options) {
|
||||
/**
|
||||
* Constructor
|
||||
@ -128,7 +134,7 @@
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
MenuBar.prototype._load_mode_menu = function () {
|
||||
var list = this.element.find("#mode-menu");
|
||||
var editor = this.editor;
|
||||
@ -150,4 +156,5 @@
|
||||
}
|
||||
};
|
||||
|
||||
exports.MenuBar = MenuBar;
|
||||
return {'MenuBar': MenuBar};
|
||||
});
|
@ -1,15 +1,15 @@
|
||||
|
||||
define([
|
||||
'base/js/notificationarea'
|
||||
], function(notificationarea) {
|
||||
"use strict";
|
||||
|
||||
var notificationarea = require('base/js/notificationarea');
|
||||
var NotificationArea = notificationarea.NotificationArea;
|
||||
|
||||
|
||||
var EditorNotificationArea = function(selector, options) {
|
||||
NotificationArea.apply(this, [selector, options]);
|
||||
}
|
||||
|
||||
|
||||
EditorNotificationArea.prototype = Object.create(NotificationArea.prototype);
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the default set of notification widgets.
|
||||
*
|
||||
@ -23,5 +23,7 @@
|
||||
savew.set_message("File saved", 2000);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
exports.EditorNotificationArea = EditorNotificationArea;
|
||||
return {EditorNotificationArea: EditorNotificationArea};
|
||||
});
|
@ -1,11 +1,14 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
var dialog = require('base/js/dialog');
|
||||
var keyboard = require('base/js/keyboard');
|
||||
var moment = require('moment');
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
'base/js/dialog',
|
||||
'base/js/keyboard',
|
||||
'moment',
|
||||
], function($, utils, dialog, keyboard, moment) {
|
||||
"use strict";
|
||||
|
||||
var SaveWidget = function (selector, options) {
|
||||
this.editor = undefined;
|
||||
@ -131,7 +134,7 @@
|
||||
}
|
||||
this._render_last_modified();
|
||||
};
|
||||
|
||||
|
||||
SaveWidget.prototype._render_last_modified = function () {
|
||||
/** actually set the text in the element, from our _last_modified value
|
||||
|
||||
@ -157,7 +160,7 @@
|
||||
}
|
||||
el.text(human_date).attr('title', long_date);
|
||||
};
|
||||
|
||||
|
||||
SaveWidget.prototype._schedule_render_last_modified = function () {
|
||||
/** schedule the next update to relative date
|
||||
|
||||
@ -176,4 +179,6 @@
|
||||
);
|
||||
};
|
||||
|
||||
exports.SaveWidget = SaveWidget;
|
||||
return {'SaveWidget': SaveWidget};
|
||||
|
||||
});
|
@ -1,10 +1,12 @@
|
||||
// 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) {
|
||||
'use strict';
|
||||
|
||||
var dialog = require('base/js/dialog');
|
||||
var IPython = require('base/js/namespace');
|
||||
|
||||
$('#notebook_about').click(function () {
|
||||
// use underscore template to auto html escape
|
||||
var text = 'You are using Jupyter notebook.<br/><br/>';
|
||||
@ -33,3 +35,4 @@
|
||||
kinfo.html($('<p/>').text('unable to contact kernel'));
|
||||
}
|
||||
});
|
||||
});
|
@ -1,5 +1,7 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define(function(require){
|
||||
"use strict";
|
||||
|
||||
|
||||
@ -573,4 +575,6 @@
|
||||
return (typeof(this._actions[name]) !== 'undefined');
|
||||
};
|
||||
|
||||
exports.init = ActionHandler;
|
||||
return {init:ActionHandler};
|
||||
|
||||
});
|
@ -8,12 +8,20 @@
|
||||
* @namespace cell
|
||||
* @class Cell
|
||||
*/
|
||||
|
||||
|
||||
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) {
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
|
||||
|
||||
var overlayHack = CodeMirror.scrollbarModel.native.prototype.overlayHack;
|
||||
|
||||
|
||||
CodeMirror.scrollbarModel.native.prototype.overlayHack = function () {
|
||||
overlayHack.apply(this, arguments);
|
||||
// Reverse `min-height: 18px` scrollbar hack on OS X
|
||||
@ -26,7 +34,7 @@
|
||||
this.horiz.style.minHeight = "";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var Cell = function (options) {
|
||||
/* Constructor
|
||||
*
|
||||
@ -114,7 +122,7 @@
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// FIXME: Workaround CM Bug #332 (Safari segfault on drag)
|
||||
// by disabling drag/drop altogether on Safari
|
||||
// https://github.com/codemirror/CodeMirror/issues/332
|
||||
@ -193,7 +201,7 @@
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This method gets called in CodeMirror's onKeyDown/onKeyPress
|
||||
* handlers and is used to provide custom key handling.
|
||||
@ -389,7 +397,7 @@
|
||||
this.focus_cell();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Focus the cell in the DOM sense
|
||||
* @method focus_cell
|
||||
@ -545,7 +553,7 @@
|
||||
this.user_highlight = mode;
|
||||
this.auto_highlight();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Trigger autodetection of highlight scheme for current cell
|
||||
* @method auto_highlight
|
||||
@ -553,7 +561,7 @@
|
||||
Cell.prototype.auto_highlight = function () {
|
||||
this._auto_highlight(this.class_config.get_sync('highlight_modes'));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Try to autodetect cell highlight mode, or use selected mode
|
||||
* @methods _auto_highlight
|
||||
@ -651,17 +659,17 @@
|
||||
};
|
||||
|
||||
UnrecognizedCell.prototype = Object.create(Cell.prototype);
|
||||
|
||||
|
||||
|
||||
|
||||
// cannot merge or split unrecognized cells
|
||||
UnrecognizedCell.prototype.is_mergeable = function () {
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
UnrecognizedCell.prototype.is_splittable = function () {
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
UnrecognizedCell.prototype.toJSON = function () {
|
||||
/**
|
||||
* deepcopy the metadata so copied cells don't share the same object
|
||||
@ -678,7 +686,7 @@
|
||||
}
|
||||
this.element.find('.inner_cell').find("a").text("Unrecognized cell type: " + data.cell_type);
|
||||
};
|
||||
|
||||
|
||||
UnrecognizedCell.prototype.create_element = function () {
|
||||
Cell.prototype.create_element.apply(this, arguments);
|
||||
var cell = this.element = $("<div>").addClass('cell unrecognized_cell');
|
||||
@ -695,7 +703,7 @@
|
||||
cell.append(inner_cell);
|
||||
this.element = cell;
|
||||
};
|
||||
|
||||
|
||||
UnrecognizedCell.prototype.bind_events = function () {
|
||||
Cell.prototype.bind_events.apply(this, arguments);
|
||||
var cell = this;
|
||||
@ -705,7 +713,8 @@
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
return {
|
||||
Cell: Cell,
|
||||
UnrecognizedCell: UnrecognizedCell
|
||||
};
|
||||
});
|
@ -1,9 +1,12 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
var IPython = require('base/js/namespace');
|
||||
var events = require('base/js/events');
|
||||
define([
|
||||
'base/js/namespace',
|
||||
'jquery',
|
||||
'base/js/events'
|
||||
], function(IPython, $, events) {
|
||||
"use strict";
|
||||
|
||||
var CellToolbar = function (options) {
|
||||
/**
|
||||
@ -461,4 +464,5 @@
|
||||
// Backwards compatability.
|
||||
IPython.CellToolbar = CellToolbar;
|
||||
|
||||
exports.CellToolbar = CellToolbar;
|
||||
return {'CellToolbar': CellToolbar};
|
||||
});
|
@ -1,9 +1,12 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
var celltoolbar = require('notebook/js/celltoolbar');
|
||||
var dialog = require('base/js/dialog');
|
||||
define([
|
||||
'jquery',
|
||||
'notebook/js/celltoolbar',
|
||||
'base/js/dialog',
|
||||
], function($, celltoolbar, dialog) {
|
||||
"use strict";
|
||||
|
||||
var CellToolbar = celltoolbar.CellToolbar;
|
||||
|
||||
@ -44,4 +47,5 @@
|
||||
CellToolbar.register_preset('Edit Metadata', example_preset, notebook);
|
||||
console.log('Default extension for cell metadata editing loaded.');
|
||||
};
|
||||
exports.register = register;
|
||||
return {'register': register};
|
||||
});
|
@ -8,8 +8,12 @@
|
||||
// ```
|
||||
// $.getScript('/static/js/celltoolbarpresets/example.js');
|
||||
// ```
|
||||
define([
|
||||
'jquery',
|
||||
'notebook/js/celltoolbar',
|
||||
], function($, celltoolbar) {
|
||||
"use strict";
|
||||
var celltoolbar = require('notebook/js/celltoolbar');
|
||||
|
||||
var CellToolbar = celltoolbar.CellToolbar;
|
||||
|
||||
var example_preset = [];
|
||||
@ -142,4 +146,5 @@
|
||||
CellToolbar.register_preset('Example',example_preset, notebook);
|
||||
console.log('Example extension for metadata editing loaded.');
|
||||
};
|
||||
exports.register = register;
|
||||
return {'register': register};
|
||||
});
|
@ -1,15 +1,18 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'notebook/js/celltoolbar',
|
||||
'base/js/dialog',
|
||||
'base/js/keyboard',
|
||||
], function($, celltoolbar, dialog, keyboard) {
|
||||
"use strict";
|
||||
|
||||
var celltoolbar = require('notebook/js/celltoolbar');
|
||||
var dialog = require('base/js/dialog');
|
||||
var keyboard = require('base/js/keyboard');
|
||||
var CellToolbar = celltoolbar.CellToolbar;
|
||||
var raw_cell_preset = [];
|
||||
|
||||
var CellToolbar = celltoolbar.CellToolbar;
|
||||
var raw_cell_preset = [];
|
||||
|
||||
var select_type = CellToolbar.utils.select_ui_generator([
|
||||
var select_type = CellToolbar.utils.select_ui_generator([
|
||||
["None", "-"],
|
||||
["LaTeX", "text/latex"],
|
||||
["reST", "text/restructuredtext"],
|
||||
@ -69,13 +72,15 @@
|
||||
},
|
||||
// name
|
||||
"Raw NBConvert Format"
|
||||
);
|
||||
);
|
||||
|
||||
var register = function (notebook) {
|
||||
var register = function (notebook) {
|
||||
CellToolbar.register_callback('raw_cell.select', select_type, ['raw']);
|
||||
raw_cell_preset.push('raw_cell.select');
|
||||
|
||||
CellToolbar.register_preset('Raw Cell Format', raw_cell_preset, notebook);
|
||||
console.log('Raw Cell Format toolbar preset loaded.');
|
||||
};
|
||||
exports.register = register;
|
||||
};
|
||||
return {'register': register};
|
||||
|
||||
});
|
@ -1,8 +1,12 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'notebook/js/celltoolbar',
|
||||
], function($, celltoolbar) {
|
||||
"use strict";
|
||||
|
||||
var celltoolbar = require('notebook/js/celltoolbar');
|
||||
|
||||
var CellToolbar = celltoolbar.CellToolbar;
|
||||
var slideshow_preset = [];
|
||||
@ -38,4 +42,5 @@
|
||||
CellToolbar.register_preset('Slideshow',slideshow_preset, notebook);
|
||||
console.log('Slideshow extension for metadata editing loaded.');
|
||||
};
|
||||
exports.register = register;
|
||||
return {'register': register};
|
||||
});
|
@ -7,17 +7,36 @@
|
||||
* @namespace codecell
|
||||
* @class CodeCell
|
||||
*/
|
||||
|
||||
|
||||
define([
|
||||
'base/js/namespace',
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
'base/js/keyboard',
|
||||
'services/config',
|
||||
'notebook/js/cell',
|
||||
'notebook/js/outputarea',
|
||||
'notebook/js/completer',
|
||||
'notebook/js/celltoolbar',
|
||||
'codemirror/lib/codemirror',
|
||||
'codemirror/mode/python/python',
|
||||
'notebook/js/codemirror-ipython'
|
||||
], function(IPython,
|
||||
$,
|
||||
utils,
|
||||
keyboard,
|
||||
configmod,
|
||||
cell,
|
||||
outputarea,
|
||||
completer,
|
||||
celltoolbar,
|
||||
CodeMirror,
|
||||
cmpython,
|
||||
cmip
|
||||
) {
|
||||
"use strict";
|
||||
|
||||
var IPython = require('base/js/namespace');
|
||||
var utils = require('base/js/utils');
|
||||
var keyboard = require('base/js/keyboard');
|
||||
var configmod = require('services/config');
|
||||
var cell = require('notebook/js/cell');
|
||||
var outputarea = require('notebook/js/outputarea');
|
||||
var completer = require('notebook/js/completer');
|
||||
var celltoolbar = require('notebook/js/celltoolbar');
|
||||
|
||||
|
||||
var Cell = cell.Cell;
|
||||
|
||||
/* local util for codemirror */
|
||||
@ -125,7 +144,7 @@
|
||||
CodeCell.msg_cells = {};
|
||||
|
||||
CodeCell.prototype = Object.create(Cell.prototype);
|
||||
|
||||
|
||||
/** @method create_element */
|
||||
CodeCell.prototype.create_element = function () {
|
||||
Cell.prototype.create_element.apply(this, arguments);
|
||||
@ -312,7 +331,7 @@
|
||||
this.render();
|
||||
this.events.trigger('execute.CodeCell', {cell: this});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Construct the default callbacks for
|
||||
* @method get_callbacks
|
||||
@ -338,7 +357,7 @@
|
||||
input : $.proxy(this._handle_input_request, this)
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
CodeCell.prototype._open_with_pager = function (payload) {
|
||||
this.events.trigger('open_with_text.Pager', payload);
|
||||
};
|
||||
@ -387,7 +406,7 @@
|
||||
// Always execute, even if we are already in the rendered state
|
||||
return cont;
|
||||
};
|
||||
|
||||
|
||||
CodeCell.prototype.select_all = function () {
|
||||
var start = {line: 0, ch: 0};
|
||||
var nlines = this.code_mirror.lineCount();
|
||||
@ -536,4 +555,5 @@
|
||||
// Backwards compatability.
|
||||
IPython.CodeCell = CodeCell;
|
||||
|
||||
exports.CodeCell = CodeCell;
|
||||
return {'CodeCell': CodeCell};
|
||||
});
|
@ -1,10 +1,12 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define(function(require){
|
||||
"use strict";
|
||||
|
||||
var QH = require("notebook/js/quickhelp");
|
||||
|
||||
var $ = require("jquery");
|
||||
|
||||
/**
|
||||
* Humanize the action name to be consumed by user.
|
||||
* internaly the actions anem are of the form
|
||||
@ -172,4 +174,5 @@
|
||||
|
||||
mod.modal('show');
|
||||
};
|
||||
module.exports = {'CommandPalette': CommandPalette};
|
||||
return {'CommandPalette': CommandPalette};
|
||||
});
|
@ -1,10 +1,14 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
var keyboard = require('base/js/keyboard');
|
||||
require('notebook/js/contexthint');
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
'base/js/keyboard',
|
||||
'notebook/js/contexthint',
|
||||
'codemirror/lib/codemirror',
|
||||
], function($, utils, keyboard, CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
// easier key mapping
|
||||
var keycodes = keyboard.keycodes;
|
||||
@ -404,4 +408,5 @@
|
||||
}, 50);
|
||||
};
|
||||
|
||||
exports.Completer = Completer;
|
||||
return {'Completer': Completer};
|
||||
});
|
@ -2,6 +2,7 @@
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
// highly adapted for codemiror jshint
|
||||
define(['codemirror/lib/codemirror'], function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var forEach = function(arr, f) {
|
||||
@ -93,4 +94,5 @@
|
||||
return filterd;
|
||||
};
|
||||
|
||||
exports.contextHint = CodeMirror.contextHint;
|
||||
return {'contextHint': CodeMirror.contextHint};
|
||||
});
|
@ -1,9 +1,14 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/namespace',
|
||||
'base/js/dialog',
|
||||
'base/js/utils',
|
||||
], function($, IPython, dialog, utils) {
|
||||
"use strict";
|
||||
var IPython = require('base/js/namespace');
|
||||
var dialog = require('base/js/dialog');
|
||||
var utils = require('base/js/utils');
|
||||
|
||||
var KernelSelector = function(selector, notebook) {
|
||||
var that = this;
|
||||
this.selector = selector;
|
||||
@ -27,14 +32,14 @@
|
||||
|
||||
Object.seal(this);
|
||||
};
|
||||
|
||||
|
||||
KernelSelector.prototype.request_kernelspecs = function() {
|
||||
// Preliminary documentation for kernelspecs api is at
|
||||
// https://github.com/ipython/ipython/wiki/IPEP-25%3A-Registry-of-installed-kernels#rest-api
|
||||
var url = utils.url_join_encode(this.notebook.base_url, 'api/kernelspecs');
|
||||
utils.promising_ajax(url).then($.proxy(this._got_kernelspecs, this));
|
||||
};
|
||||
|
||||
|
||||
var _sorted_names = function(kernelspecs) {
|
||||
// sort kernel names
|
||||
return Object.keys(kernelspecs).sort(function (a, b) {
|
||||
@ -50,7 +55,7 @@
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
KernelSelector.prototype._got_kernelspecs = function(data) {
|
||||
var that = this;
|
||||
this.kernelspecs = data.kernelspecs;
|
||||
@ -88,7 +93,7 @@
|
||||
this._loaded = true;
|
||||
this._finish_load();
|
||||
};
|
||||
|
||||
|
||||
KernelSelector.prototype._spec_changed = function (event, ks) {
|
||||
/** event handler for spec_changed */
|
||||
var that = this;
|
||||
@ -142,7 +147,7 @@
|
||||
|
||||
// load kernel js
|
||||
if (ks.resources['kernel.js']) {
|
||||
requirejs([ks.resources['kernel.js']],
|
||||
require([ks.resources['kernel.js']],
|
||||
function (kernel_mod) {
|
||||
if (kernel_mod && kernel_mod.onload) {
|
||||
kernel_mod.onload();
|
||||
@ -233,7 +238,7 @@
|
||||
this.current_selection = ks.name;
|
||||
this.events.trigger('spec_changed.Kernel', ks);
|
||||
};
|
||||
|
||||
|
||||
KernelSelector.prototype._spec_not_found = function (event, data) {
|
||||
var that = this;
|
||||
var select = $("<select>").addClass('form-control');
|
||||
@ -328,4 +333,5 @@
|
||||
});
|
||||
};
|
||||
|
||||
exports.KernelSelector = KernelSelector;
|
||||
return {'KernelSelector': KernelSelector};
|
||||
});
|
@ -7,10 +7,14 @@
|
||||
* @namespace keyboardmanager
|
||||
* @class KeyboardManager
|
||||
*/
|
||||
"use strict";
|
||||
var utils = require('base/js/utils');
|
||||
var keyboard = require('base/js/keyboard');
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
'base/js/keyboard',
|
||||
], function($, utils, keyboard) {
|
||||
"use strict";
|
||||
|
||||
// Main keyboard manager for the notebook
|
||||
var keycodes = keyboard.keycodes;
|
||||
|
||||
@ -135,7 +139,7 @@
|
||||
this.notebook = notebook;
|
||||
this.actions.extend_env({notebook:notebook});
|
||||
};
|
||||
|
||||
|
||||
KeyboardManager.prototype.set_quickhelp = function (notebook) {
|
||||
this.actions.extend_env({quick_help:notebook});
|
||||
};
|
||||
@ -222,4 +226,5 @@
|
||||
});
|
||||
};
|
||||
|
||||
exports.KeyboardManager = KeyboardManager;
|
||||
return {'KeyboardManager': KeyboardManager};
|
||||
});
|
@ -1,30 +1,67 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
// Contents must be loaded at runtime.
|
||||
require('base/js/globals').then(function() {
|
||||
var IPython = require('base/js/namespace');
|
||||
var notebook = require('notebook/js/notebook');
|
||||
var configmod = require('services/config');
|
||||
var utils = require('base/js/utils');
|
||||
var page = require('base/js/page');
|
||||
var events = require('base/js/events');
|
||||
var loginwidget = require('auth/js/loginwidget');
|
||||
var maintoolbar = require('notebook/js/maintoolbar');
|
||||
var pager = require('notebook/js/pager');
|
||||
var quickhelp = require('notebook/js/quickhelp');
|
||||
var menubar = require('notebook/js/menubar');
|
||||
var notificationarea = require('notebook/js/notificationarea');
|
||||
var savewidget = require('notebook/js/savewidget');
|
||||
var actions = require('notebook/js/actions');
|
||||
var keyboardmanager = require('notebook/js/keyboardmanager');
|
||||
var kernelselector = require('notebook/js/kernelselector');
|
||||
var about = require('notebook/js/about');
|
||||
var typeahead = require('typeahead');
|
||||
var searchandreplace = require('notebook/js/searchandreplace');
|
||||
require([
|
||||
'base/js/namespace',
|
||||
'jquery',
|
||||
'notebook/js/notebook',
|
||||
'contents',
|
||||
'services/config',
|
||||
'base/js/utils',
|
||||
'base/js/page',
|
||||
'base/js/events',
|
||||
'auth/js/loginwidget',
|
||||
'notebook/js/maintoolbar',
|
||||
'notebook/js/pager',
|
||||
'notebook/js/quickhelp',
|
||||
'notebook/js/menubar',
|
||||
'notebook/js/notificationarea',
|
||||
'notebook/js/savewidget',
|
||||
'notebook/js/actions',
|
||||
'notebook/js/keyboardmanager',
|
||||
'notebook/js/kernelselector',
|
||||
'codemirror/lib/codemirror',
|
||||
'notebook/js/about',
|
||||
'typeahead',
|
||||
'notebook/js/searchandreplace',
|
||||
// only loaded, not used, please keep sure this is loaded last
|
||||
requirejs(['contents', 'custom/custom'], function(contents_service) {
|
||||
'custom/custom'
|
||||
], function(
|
||||
IPython,
|
||||
$,
|
||||
notebook,
|
||||
contents,
|
||||
configmod,
|
||||
utils,
|
||||
page,
|
||||
events,
|
||||
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
|
||||
) {
|
||||
"use strict";
|
||||
|
||||
// BEGIN HARDCODED WIDGETS HACK
|
||||
utils.load_extension('widgets/notebook/js/extension').catch(function () {
|
||||
console.warn('ipywidgets package not installed. Widgets are not available.');
|
||||
});
|
||||
// END HARDCODED WIDGETS HACK
|
||||
|
||||
// compat with old IPython, remove for IPython > 3.0
|
||||
window.CodeMirror = CodeMirror;
|
||||
|
||||
var common_options = {
|
||||
ws_url : utils.get_body_data("wsUrl"),
|
||||
@ -37,8 +74,8 @@ require('base/js/globals').then(function() {
|
||||
config_section.load();
|
||||
var common_config = new configmod.ConfigSection('common', common_options);
|
||||
common_config.load();
|
||||
page = new page.Page();
|
||||
pager = new pager.Pager('div#pager', {
|
||||
var page = new page.Page();
|
||||
var pager = new pager.Pager('div#pager', {
|
||||
events: events});
|
||||
var acts = new actions.init();
|
||||
var keyboard_manager = new keyboardmanager.KeyboardManager({
|
||||
@ -48,11 +85,11 @@ require('base/js/globals').then(function() {
|
||||
var save_widget = new savewidget.SaveWidget('span#save_widget', {
|
||||
events: events,
|
||||
keyboard_manager: keyboard_manager});
|
||||
var contents = new contents_service.Contents({
|
||||
var contents = new contents.Contents({
|
||||
base_url: common_options.base_url,
|
||||
common_config: common_config
|
||||
});
|
||||
notebook = new notebook.Notebook('div#notebook', $.extend({
|
||||
var notebook = new notebook.Notebook('div#notebook', $.extend({
|
||||
events: events,
|
||||
keyboard_manager: keyboard_manager,
|
||||
save_widget: save_widget,
|
||||
@ -70,7 +107,7 @@ require('base/js/globals').then(function() {
|
||||
notebook: notebook});
|
||||
keyboard_manager.set_notebook(notebook);
|
||||
keyboard_manager.set_quickhelp(quick_help);
|
||||
menubar = new menubar.MenuBar('#menubar', $.extend({
|
||||
var menubar = new menubar.MenuBar('#menubar', $.extend({
|
||||
notebook: notebook,
|
||||
contents: contents,
|
||||
events: events,
|
||||
@ -112,7 +149,7 @@ require('base/js/globals').then(function() {
|
||||
events.off('notebook_loaded.Notebook', first_load);
|
||||
};
|
||||
events.on('notebook_loaded.Notebook', first_load);
|
||||
|
||||
|
||||
IPython.page = page;
|
||||
IPython.notebook = notebook;
|
||||
IPython.contents = contents;
|
||||
@ -126,17 +163,9 @@ require('base/js/globals').then(function() {
|
||||
IPython.save_widget = save_widget;
|
||||
IPython.tooltip = notebook.tooltip;
|
||||
|
||||
// BEGIN HARDCODED WIDGETS HACK
|
||||
utils.load_extension('widgets/notebook/js/extension').catch(function (err) {
|
||||
console.warn('ipywidgets package not loaded. Widgets are not available. (Maybe they aren\'t installed)', err);
|
||||
});
|
||||
// END HARDCODED WIDGETS HACK
|
||||
|
||||
events.trigger('app_initialized.NotebookApp');
|
||||
utils.load_extensions_from_config(config_section);
|
||||
utils.load_extensions_from_config(common_config);
|
||||
notebook.load_notebook(common_options.notebook_path);
|
||||
});
|
||||
}).catch(function(err) {
|
||||
console.error('Could not load globals', err);
|
||||
|
||||
});
|
@ -1,9 +1,14 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'require',
|
||||
'jquery',
|
||||
'./toolbar',
|
||||
'./celltoolbar'
|
||||
], function(require, $, toolbar, celltoolbar) {
|
||||
"use strict";
|
||||
|
||||
var toolbar = require('./toolbar');
|
||||
var celltoolbar = require('./celltoolbar');
|
||||
var MainToolBar = function (selector, options) {
|
||||
/**
|
||||
* Constructor
|
||||
@ -55,7 +60,7 @@
|
||||
];
|
||||
this.construct(grps);
|
||||
};
|
||||
|
||||
|
||||
// add a cell type drop down to the maintoolbar.
|
||||
// triggered when the pseudo action `<add_celltype_list>` is
|
||||
// encountered when building a toolbar.
|
||||
@ -153,4 +158,5 @@
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
exports.MainToolBar = MainToolBar;
|
||||
return {'MainToolBar': MainToolBar};
|
||||
});
|
@ -1,9 +1,12 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
var dialog = require('base/js/dialog');
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
'base/js/dialog',
|
||||
], function($, utils, dialog) {
|
||||
"use strict";
|
||||
|
||||
var init = function () {
|
||||
if (window.MathJax) {
|
||||
@ -199,8 +202,11 @@
|
||||
return text;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
var mathjaxutils = {
|
||||
init : init,
|
||||
remove_math : remove_math,
|
||||
replace_math : replace_math
|
||||
};
|
||||
|
||||
return mathjaxutils;
|
||||
});
|
@ -1,13 +1,17 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/namespace',
|
||||
'base/js/dialog',
|
||||
'base/js/utils',
|
||||
'notebook/js/tour',
|
||||
'bootstrap',
|
||||
'moment',
|
||||
], function($, IPython, dialog, utils, tour, bootstrap, moment) {
|
||||
"use strict";
|
||||
|
||||
var IPython = require('base/js/namespace');
|
||||
var dialog = require('base/js/dialog');
|
||||
var utils = require('base/js/utils');
|
||||
var tour = require('notebook/js/tour');
|
||||
var moment = require('moment');
|
||||
|
||||
|
||||
var MenuBar = function (selector, options) {
|
||||
/**
|
||||
* Constructor
|
||||
@ -37,7 +41,7 @@
|
||||
this.quick_help = options.quick_help;
|
||||
|
||||
try {
|
||||
this.tour = new tour.NotebookTour(this.notebook, this.events);
|
||||
this.tour = new tour.Tour(this.notebook, this.events);
|
||||
} catch (e) {
|
||||
this.tour = undefined;
|
||||
console.log("Failed to instantiate Notebook Tour", e);
|
||||
@ -361,7 +365,7 @@
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
MenuBar.prototype.update_nbconvert_script = function(langinfo) {
|
||||
/**
|
||||
* Set the 'Download as foo' menu option for the relevant language.
|
||||
@ -414,4 +418,5 @@
|
||||
|
||||
};
|
||||
|
||||
exports.MenuBar = MenuBar;
|
||||
return {'MenuBar': MenuBar};
|
||||
});
|
@ -4,9 +4,10 @@
|
||||
/**
|
||||
* @module notebook
|
||||
*/
|
||||
define(function (require) {
|
||||
"use strict";
|
||||
|
||||
var IPython = require('base/js/namespace');
|
||||
var $ = require('jquery');
|
||||
var utils = require('base/js/utils');
|
||||
var dialog = require('base/js/dialog');
|
||||
var cellmod = require('notebook/js/cell');
|
||||
@ -16,7 +17,9 @@
|
||||
var configmod = require('services/config');
|
||||
var session = require('services/sessions/session');
|
||||
var celltoolbar = require('notebook/js/celltoolbar');
|
||||
var marked = require('marked');
|
||||
var marked = require('components/marked/lib/marked');
|
||||
var CodeMirror = require('codemirror/lib/codemirror');
|
||||
var runMode = require('codemirror/addon/runmode/runmode');
|
||||
var mathjaxutils = require('notebook/js/mathjaxutils');
|
||||
var keyboard = require('base/js/keyboard');
|
||||
var tooltip = require('notebook/js/tooltip');
|
||||
@ -316,6 +319,7 @@
|
||||
return;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Notebook.prototype.show_command_palette = function() {
|
||||
var x = new commandpalette.CommandPalette(this);
|
||||
@ -527,7 +531,7 @@
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the numeric index of a given cell.
|
||||
*
|
||||
@ -808,7 +812,7 @@
|
||||
cell.focus_editor();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Ensure either cell, or codemirror is focused. Is none
|
||||
* is focused, focus the cell.
|
||||
@ -1262,7 +1266,7 @@
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Warn about heading cell support removal.
|
||||
*/
|
||||
@ -1282,7 +1286,7 @@
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Turn a cell into a heading containing markdown cell.
|
||||
*
|
||||
@ -1696,7 +1700,7 @@
|
||||
var _mode_equal = function(mode1, mode2){
|
||||
return ((mode1||{}).name||mode1)===((mode2||{}).name||mode2);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the codemirror mode for all code cells, including the default for
|
||||
* new code cells.
|
||||
@ -1776,7 +1780,7 @@
|
||||
this._session_starting = false;
|
||||
utils.log_ajax_error(jqxhr, status, error);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Prompt the user to restart the Jupyter kernel.
|
||||
*/
|
||||
@ -1807,7 +1811,7 @@
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Execute or render cell outputs and go into command mode.
|
||||
*/
|
||||
@ -2058,7 +2062,7 @@
|
||||
this.events.trigger("autosave_disabled.Notebook");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Save this notebook on the server. This becomes a notebook instance's
|
||||
* .save_notebook method *after* the entire notebook has been loaded.
|
||||
@ -2141,7 +2145,7 @@
|
||||
return _save();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Success callback for saving a notebook.
|
||||
*
|
||||
@ -2182,7 +2186,7 @@
|
||||
this._checkpoint_after_save = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Update the autosave interval based on the duration of the last save.
|
||||
*
|
||||
@ -2270,7 +2274,7 @@
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Ensure a filename has the right extension
|
||||
* Returns the filename with the appropriate extension, appending if necessary.
|
||||
@ -2512,7 +2516,7 @@
|
||||
};
|
||||
|
||||
/********************* checkpoint-related ********************/
|
||||
|
||||
|
||||
/**
|
||||
* Save the notebook then immediately create a checkpoint.
|
||||
*/
|
||||
@ -2520,7 +2524,7 @@
|
||||
this._checkpoint_after_save = true;
|
||||
this.save_notebook();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Add a checkpoint for this notebook.
|
||||
*/
|
||||
@ -2539,7 +2543,7 @@
|
||||
}
|
||||
this.last_checkpoint = this.checkpoints[this.checkpoints.length - 1];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* List checkpoints for this notebook.
|
||||
*/
|
||||
@ -2636,7 +2640,7 @@
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Restore the notebook to a checkpoint state.
|
||||
*
|
||||
@ -2652,7 +2656,7 @@
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Success callback for restoring a notebook to a checkpoint.
|
||||
*/
|
||||
@ -2676,7 +2680,7 @@
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Success callback for deleting a notebook checkpoint.
|
||||
*/
|
||||
@ -2685,4 +2689,5 @@
|
||||
this.load_notebook(this.notebook_path);
|
||||
};
|
||||
|
||||
exports.Notebook = Notebook;
|
||||
return {'Notebook': Notebook};
|
||||
});
|
@ -1,23 +1,22 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
'base/js/dialog',
|
||||
'base/js/notificationarea',
|
||||
'moment'
|
||||
], function($, utils, dialog, notificationarea, moment) {
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
var dialog = require('base/js/dialog');
|
||||
var notificationarea = require('base/js/notificationarea');
|
||||
var moment = require('moment');
|
||||
|
||||
var NotificationArea = notificationarea.NotificationArea;
|
||||
|
||||
|
||||
var NotebookNotificationArea = function(selector, options) {
|
||||
NotificationArea.apply(this, [selector, options]);
|
||||
this.save_widget = options.save_widget;
|
||||
this.notebook = options.notebook;
|
||||
this.keyboard_manager = options.keyboard_manager;
|
||||
};
|
||||
|
||||
|
||||
NotebookNotificationArea.prototype = Object.create(NotificationArea.prototype);
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the default set of notification widgets.
|
||||
*
|
||||
@ -340,4 +339,5 @@
|
||||
});
|
||||
};
|
||||
|
||||
exports.NotebookNotificationArea = NotebookNotificationArea;
|
||||
return {'NotebookNotificationArea': NotebookNotificationArea};
|
||||
});
|
@ -1,12 +1,15 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
var security = require('base/js/security');
|
||||
var keyboard = require('base/js/keyboard');
|
||||
var mathjaxutils = require('notebook/js/mathjaxutils');
|
||||
var marked = require('marked');
|
||||
define([
|
||||
'jqueryui',
|
||||
'base/js/utils',
|
||||
'base/js/security',
|
||||
'base/js/keyboard',
|
||||
'notebook/js/mathjaxutils',
|
||||
'components/marked/lib/marked',
|
||||
], function($, utils, security, keyboard, mathjaxutils, marked) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* @class OutputArea
|
||||
@ -229,8 +232,8 @@
|
||||
}
|
||||
this.append_output(json);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
OutputArea.output_types = [
|
||||
'application/javascript',
|
||||
'text/html',
|
||||
@ -265,7 +268,7 @@
|
||||
});
|
||||
return bundle;
|
||||
};
|
||||
|
||||
|
||||
OutputArea.prototype.append_output = function (json) {
|
||||
this.expand();
|
||||
|
||||
@ -398,7 +401,7 @@
|
||||
.append($('<div/>').text(err.toString()).addClass('js-error'))
|
||||
.append($('<div/>').text('See your browser Javascript console for more details.').addClass('js-error'));
|
||||
};
|
||||
|
||||
|
||||
OutputArea.prototype._safe_append = function (toinsert) {
|
||||
/**
|
||||
* safely append an item to the document
|
||||
@ -545,7 +548,7 @@
|
||||
'image/png' : true,
|
||||
'image/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];
|
||||
@ -682,7 +685,7 @@
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
var set_width_height = function (img, md, mime) {
|
||||
/**
|
||||
* set width and height of an img element from metadata
|
||||
@ -695,7 +698,7 @@
|
||||
img.addClass('unconfined');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var append_png = function (png, md, element, handle_inserted) {
|
||||
var type = 'image/png';
|
||||
var toinsert = this.create_output_subarea(md, "output_png", type);
|
||||
@ -958,4 +961,5 @@
|
||||
"application/pdf" : append_pdf
|
||||
};
|
||||
|
||||
exports.OutputArea = OutputArea;
|
||||
return {'OutputArea': OutputArea};
|
||||
});
|
@ -1,8 +1,11 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
define([
|
||||
'jqueryui',
|
||||
'base/js/utils',
|
||||
], function($, utils) {
|
||||
"use strict";
|
||||
|
||||
var Pager = function (pager_selector, options) {
|
||||
/**
|
||||
@ -163,4 +166,5 @@
|
||||
$('.end_space').css('height', Math.max(this.pager_element.height(), this._default_end_space));
|
||||
};
|
||||
|
||||
exports.Pager = Pager;
|
||||
return {'Pager': Pager};
|
||||
});
|
@ -1,10 +1,12 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
'base/js/dialog',
|
||||
], function($, utils, dialog) {
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
var dialog = require('base/js/dialog');
|
||||
|
||||
var platform = utils.platform;
|
||||
|
||||
var QuickHelp = function (options) {
|
||||
@ -62,7 +64,7 @@
|
||||
{ shortcut: cmd_ctrl + "Shift-z", help:"redo" },
|
||||
{ shortcut: cmd_ctrl + "y", help:"redo" },
|
||||
].concat( platform_specific );
|
||||
|
||||
|
||||
var mac_humanize_map = {
|
||||
// all these are unicode, will probably display badly on anything except macs.
|
||||
// these are the standard symbol that are used in MacOS native menus
|
||||
@ -112,7 +114,7 @@
|
||||
'space':'Space',
|
||||
'backspace':'Backspace',
|
||||
};
|
||||
|
||||
|
||||
var humanize_map;
|
||||
|
||||
if (platform === 'MacOS'){
|
||||
@ -284,7 +286,8 @@
|
||||
return div;
|
||||
};
|
||||
|
||||
module.exports = {'QuickHelp': QuickHelp,
|
||||
return {'QuickHelp': QuickHelp,
|
||||
humanize_shortcut: humanize_shortcut,
|
||||
humanize_sequence: humanize_sequence
|
||||
};
|
||||
});
|
@ -1,11 +1,14 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
var dialog = require('base/js/dialog');
|
||||
var keyboard = require('base/js/keyboard');
|
||||
var moment = require('moment');
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
'base/js/dialog',
|
||||
'base/js/keyboard',
|
||||
'moment',
|
||||
], function($, utils, dialog, keyboard, moment) {
|
||||
"use strict";
|
||||
|
||||
var SaveWidget = function (selector, options) {
|
||||
/**
|
||||
@ -159,7 +162,7 @@
|
||||
}
|
||||
this._render_checkpoint();
|
||||
};
|
||||
|
||||
|
||||
SaveWidget.prototype._render_checkpoint = function () {
|
||||
/** actually set the text in the element, from our _checkpoint value
|
||||
|
||||
@ -186,7 +189,7 @@
|
||||
el.text('Last Checkpoint: ' + human_date).attr('title', long_date);
|
||||
};
|
||||
|
||||
|
||||
|
||||
SaveWidget.prototype._schedule_render_checkpoint = function () {
|
||||
/** schedule the next update to relative date
|
||||
|
||||
@ -213,4 +216,6 @@
|
||||
}
|
||||
};
|
||||
|
||||
exports.SaveWidget = SaveWidget;
|
||||
return {'SaveWidget': SaveWidget};
|
||||
|
||||
});
|
@ -1,5 +1,6 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
define(['jquery'], function($){
|
||||
"use strict";
|
||||
|
||||
var ScrollManager = function(notebook, options) {
|
||||
@ -204,9 +205,10 @@
|
||||
};
|
||||
|
||||
// Return naemspace for require.js loads
|
||||
module.exports = {
|
||||
return {
|
||||
'ScrollManager': ScrollManager,
|
||||
'SlideScrollManager': SlideScrollManager,
|
||||
'HeadingScrollManager': HeadingScrollManager,
|
||||
'TargetScrollManager': TargetScrollManager
|
||||
};
|
||||
});
|
@ -1,3 +1,4 @@
|
||||
define(function(require){
|
||||
"use strict";
|
||||
|
||||
var dialog = require('base/js/dialog');
|
||||
@ -381,4 +382,5 @@
|
||||
};
|
||||
|
||||
|
||||
exports.load = load;
|
||||
return {load:load};
|
||||
});
|
@ -1,15 +1,32 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'base/js/utils',
|
||||
'jquery',
|
||||
'notebook/js/cell',
|
||||
'base/js/security',
|
||||
'services/config',
|
||||
'notebook/js/mathjaxutils',
|
||||
'notebook/js/celltoolbar',
|
||||
'components/marked/lib/marked',
|
||||
'codemirror/lib/codemirror',
|
||||
'codemirror/mode/gfm/gfm',
|
||||
'notebook/js/codemirror-ipythongfm'
|
||||
], function(
|
||||
utils,
|
||||
$,
|
||||
cell,
|
||||
security,
|
||||
configmod,
|
||||
mathjaxutils,
|
||||
celltoolbar,
|
||||
marked,
|
||||
CodeMirror,
|
||||
gfm,
|
||||
ipgfm
|
||||
) {
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
var cell = require('notebook/js/cell');
|
||||
var security = require('base/js/security');
|
||||
var configmod = require('services/config');
|
||||
var mathjaxutils = require('notebook/js/mathjaxutils');
|
||||
var celltoolbar = require('notebook/js/celltoolbar');
|
||||
var marked = require('marked');
|
||||
|
||||
var Cell = cell.Cell;
|
||||
|
||||
var TextCell = function (options) {
|
||||
@ -99,7 +116,7 @@
|
||||
|
||||
|
||||
// Cell level actions
|
||||
|
||||
|
||||
TextCell.prototype.select = function () {
|
||||
var cont = Cell.prototype.select.apply(this);
|
||||
if (cont) {
|
||||
@ -308,7 +325,7 @@
|
||||
"It will not be rendered in the notebook. " +
|
||||
"When passing through nbconvert, a Raw Cell's content is added to the output unmodified."
|
||||
};
|
||||
|
||||
|
||||
RawCell.config_defaults = {
|
||||
highlight_modes : {
|
||||
'diff' :{'reg':[/^diff/]}
|
||||
@ -342,8 +359,10 @@
|
||||
return cont;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
var textcell = {
|
||||
TextCell: TextCell,
|
||||
MarkdownCell: MarkdownCell,
|
||||
RawCell: RawCell
|
||||
};
|
||||
return textcell;
|
||||
});
|
@ -1,6 +1,9 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery'
|
||||
], function($) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
@ -129,4 +132,5 @@
|
||||
this.element.toggle();
|
||||
};
|
||||
|
||||
exports.ToolBar = ToolBar;
|
||||
return {'ToolBar': ToolBar};
|
||||
});
|
@ -1,8 +1,11 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
], function($, utils) {
|
||||
"use strict";
|
||||
|
||||
// tooltip constructor
|
||||
var Tooltip = function (events) {
|
||||
@ -315,4 +318,5 @@
|
||||
this.text.scrollTop(0);
|
||||
};
|
||||
|
||||
exports.Tooltip = Tooltip;
|
||||
return {'Tooltip': Tooltip};
|
||||
});
|
@ -1,5 +1,10 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'bootstraptour',
|
||||
], function($, Tour) {
|
||||
"use strict";
|
||||
|
||||
var tour_style = "<div class='popover tour'>\n" +
|
||||
@ -111,24 +116,23 @@
|
||||
}
|
||||
];
|
||||
|
||||
requirejs(['bootstraptour'], function assignTour(Tour) {
|
||||
that.tour = new Tour({
|
||||
storage: false, // start tour from beginning every time
|
||||
debug: true,
|
||||
reflex: true, // click on element to continue tour
|
||||
animation: false,
|
||||
duration: that.step_duration,
|
||||
onStart: function() { console.log('tour started'); },
|
||||
// TODO: remove the onPause/onResume logic once pi's patch has been
|
||||
// merged upstream to make this work via data-resume-class and
|
||||
// data-resume-text attributes.
|
||||
onPause: that.toggle_pause_play,
|
||||
onResume: that.toggle_pause_play,
|
||||
steps: that.tour_steps,
|
||||
template: tour_style,
|
||||
orphan: true
|
||||
});
|
||||
this.tour = new Tour({
|
||||
storage: false, // start tour from beginning every time
|
||||
debug: true,
|
||||
reflex: true, // click on element to continue tour
|
||||
animation: false,
|
||||
duration: this.step_duration,
|
||||
onStart: function() { console.log('tour started'); },
|
||||
// TODO: remove the onPause/onResume logic once pi's patch has been
|
||||
// merged upstream to make this work via data-resume-class and
|
||||
// data-resume-text attributes.
|
||||
onPause: this.toggle_pause_play,
|
||||
onResume: this.toggle_pause_play,
|
||||
steps: this.tour_steps,
|
||||
template: tour_style,
|
||||
orphan: true
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
NotebookTour.prototype.start = function () {
|
||||
@ -144,15 +148,17 @@
|
||||
NotebookTour.prototype.command_icon_hack = function() {
|
||||
$('#modal_indicator').css('min-height', 20);
|
||||
};
|
||||
|
||||
|
||||
NotebookTour.prototype.toggle_pause_play = function () {
|
||||
$('#tour-pause').toggleClass('fa-pause fa-play');
|
||||
};
|
||||
|
||||
|
||||
NotebookTour.prototype.edit_mode = function() {
|
||||
this.notebook.focus_cell();
|
||||
this.notebook.edit_mode();
|
||||
};
|
||||
|
||||
exports.NotebookTour = NotebookTour;
|
||||
|
||||
return {'Tour': NotebookTour};
|
||||
|
||||
});
|
||||
|
@ -1,9 +1,12 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
],
|
||||
function($, utils) {
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
|
||||
var ConfigSection = function(section_name, options) {
|
||||
this.section_name = section_name;
|
||||
this.base_url = options.base_url;
|
||||
@ -24,14 +27,14 @@
|
||||
ConfigSection.prototype.api_url = function() {
|
||||
return utils.url_join_encode(this.base_url, 'api/config', this.section_name);
|
||||
};
|
||||
|
||||
|
||||
ConfigSection.prototype._load_done = function() {
|
||||
if (!this._one_load_finished) {
|
||||
this._one_load_finished = true;
|
||||
this._finish_firstload();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ConfigSection.prototype.load = function() {
|
||||
var that = this;
|
||||
return utils.promising_ajax(this.api_url(), {
|
||||
@ -44,7 +47,7 @@
|
||||
return data;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Modify the config values stored. Update the local data immediately,
|
||||
* send the change to the server, and use the updated data from the server
|
||||
@ -66,14 +69,14 @@
|
||||
return data;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
var ConfigWithDefaults = function(section, defaults, classname) {
|
||||
this.section = section;
|
||||
this.defaults = defaults;
|
||||
this.classname = classname;
|
||||
};
|
||||
|
||||
|
||||
ConfigWithDefaults.prototype._class_data = function() {
|
||||
if (this.classname) {
|
||||
return this.section.data[this.classname] || {};
|
||||
@ -81,7 +84,7 @@
|
||||
return this.section.data
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Wait for config to have loaded, then get a value or the default.
|
||||
* Returns a promise.
|
||||
@ -92,7 +95,7 @@
|
||||
return this._class_data()[key] || this.defaults[key]
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Return a config value. If config is not yet loaded, return the default
|
||||
* instead of waiting for it to load.
|
||||
@ -100,7 +103,7 @@
|
||||
ConfigWithDefaults.prototype.get_sync = function(key) {
|
||||
return this._class_data()[key] || this.defaults[key];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set a config value. Send the update to the server, and change our
|
||||
* local copy of the data immediately.
|
||||
@ -118,8 +121,9 @@
|
||||
return this.section.update(d);
|
||||
}
|
||||
};
|
||||
|
||||
return {ConfigSection: ConfigSection,
|
||||
ConfigWithDefaults: ConfigWithDefaults,
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
ConfigSection: ConfigSection,
|
||||
ConfigWithDefaults: ConfigWithDefaults,
|
||||
};
|
||||
});
|
@ -1,7 +1,10 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define(function(require) {
|
||||
"use strict";
|
||||
|
||||
var $ = require('jquery');
|
||||
var utils = require('base/js/utils');
|
||||
|
||||
var Contents = function(options) {
|
||||
@ -33,7 +36,7 @@
|
||||
// directory.
|
||||
this.message = 'A directory must be empty before being deleted.';
|
||||
};
|
||||
|
||||
|
||||
Contents.DirectoryNotEmptyError.prototype = Object.create(Error.prototype);
|
||||
Contents.DirectoryNotEmptyError.prototype.name =
|
||||
Contents.DIRECTORY_NOT_EMPTY_ERROR;
|
||||
@ -170,7 +173,7 @@
|
||||
var url = this.api_url(path);
|
||||
return utils.promising_ajax(url, settings);
|
||||
};
|
||||
|
||||
|
||||
Contents.prototype.copy = function(from_file, to_dir) {
|
||||
/**
|
||||
* Copy a file into a given directory via POST
|
||||
@ -249,6 +252,5 @@
|
||||
return this.get(path, {type: 'directory'});
|
||||
};
|
||||
|
||||
exports.Contents = Contents;
|
||||
define([], function() { return {Contents: Contents}; });
|
||||
|
||||
return {'Contents': Contents};
|
||||
});
|
@ -1,14 +1,16 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
], function($, utils) {
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// CommManager class
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
var CommManager = function (kernel) {
|
||||
this.comms = {};
|
||||
this.targets = {};
|
||||
@ -16,7 +18,7 @@
|
||||
this.init_kernel(kernel);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
CommManager.prototype.init_kernel = function (kernel) {
|
||||
/**
|
||||
* connect the kernel, and register message handlers
|
||||
@ -28,7 +30,7 @@
|
||||
kernel.register_iopub_handler(msg_type, $.proxy(this[msg_type], this));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
CommManager.prototype.new_comm = function (target_name, data, callbacks, metadata, comm_id) {
|
||||
/**
|
||||
* Create a new Comm, register it, and open its Kernel-side counterpart
|
||||
@ -41,21 +43,21 @@
|
||||
comm.open(data, callbacks, metadata);
|
||||
return comm;
|
||||
};
|
||||
|
||||
|
||||
CommManager.prototype.register_target = function (target_name, f) {
|
||||
/**
|
||||
* Register a target function for a given target name
|
||||
*/
|
||||
this.targets[target_name] = f;
|
||||
};
|
||||
|
||||
|
||||
CommManager.prototype.unregister_target = function (target_name, f) {
|
||||
/**
|
||||
* Unregister a target function for a given target name
|
||||
*/
|
||||
delete this.targets[target_name];
|
||||
};
|
||||
|
||||
|
||||
CommManager.prototype.register_comm = function (comm) {
|
||||
/**
|
||||
* Register a comm in the mapping
|
||||
@ -64,16 +66,16 @@
|
||||
comm.kernel = this.kernel;
|
||||
return comm.comm_id;
|
||||
};
|
||||
|
||||
|
||||
CommManager.prototype.unregister_comm = function (comm) {
|
||||
/**
|
||||
* Remove a comm from the mapping
|
||||
*/
|
||||
delete this.comms[comm.comm_id];
|
||||
};
|
||||
|
||||
|
||||
// comm message handlers
|
||||
|
||||
|
||||
CommManager.prototype.comm_open = function (msg) {
|
||||
var content = msg.content;
|
||||
var that = this;
|
||||
@ -98,7 +100,7 @@
|
||||
}, utils.reject('Could not open comm', true));
|
||||
return this.comms[comm_id];
|
||||
};
|
||||
|
||||
|
||||
CommManager.prototype.comm_close = function(msg) {
|
||||
var content = msg.content;
|
||||
if (this.comms[content.comm_id] === undefined) {
|
||||
@ -118,7 +120,7 @@
|
||||
});
|
||||
return this.comms[content.comm_id];
|
||||
};
|
||||
|
||||
|
||||
CommManager.prototype.comm_msg = function(msg) {
|
||||
var content = msg.content;
|
||||
if (this.comms[content.comm_id] === undefined) {
|
||||
@ -136,17 +138,17 @@
|
||||
});
|
||||
return this.comms[content.comm_id];
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Comm base class
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
var Comm = function (target_name, comm_id) {
|
||||
this.target_name = target_name;
|
||||
this.comm_id = comm_id || utils.uuid();
|
||||
this._msg_callback = this._close_callback = null;
|
||||
};
|
||||
|
||||
|
||||
// methods for sending messages
|
||||
Comm.prototype.open = function (data, callbacks, metadata) {
|
||||
var content = {
|
||||
@ -156,7 +158,7 @@
|
||||
};
|
||||
return this.kernel.send_shell_message("comm_open", content, callbacks, metadata);
|
||||
};
|
||||
|
||||
|
||||
Comm.prototype.send = function (data, callbacks, metadata, buffers) {
|
||||
var content = {
|
||||
comm_id : this.comm_id,
|
||||
@ -164,7 +166,7 @@
|
||||
};
|
||||
return this.kernel.send_shell_message("comm_msg", content, callbacks, metadata, buffers);
|
||||
};
|
||||
|
||||
|
||||
Comm.prototype.close = function (data, callbacks, metadata) {
|
||||
var content = {
|
||||
comm_id : this.comm_id,
|
||||
@ -172,22 +174,22 @@
|
||||
};
|
||||
return this.kernel.send_shell_message("comm_close", content, callbacks, metadata);
|
||||
};
|
||||
|
||||
|
||||
// methods for registering callbacks for incoming messages
|
||||
Comm.prototype._register_callback = function (key, callback) {
|
||||
this['_' + key + '_callback'] = callback;
|
||||
};
|
||||
|
||||
|
||||
Comm.prototype.on_msg = function (callback) {
|
||||
this._register_callback('msg', callback);
|
||||
};
|
||||
|
||||
|
||||
Comm.prototype.on_close = function (callback) {
|
||||
this._register_callback('close', callback);
|
||||
};
|
||||
|
||||
|
||||
// methods for handling incoming messages
|
||||
|
||||
|
||||
Comm.prototype._callback = function (key, msg) {
|
||||
var callback = this['_' + key + '_callback'];
|
||||
if (callback) {
|
||||
@ -198,16 +200,17 @@
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Comm.prototype.handle_msg = function (msg) {
|
||||
this._callback('msg', msg);
|
||||
};
|
||||
|
||||
|
||||
Comm.prototype.handle_close = function (msg) {
|
||||
this._callback('close', msg);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
return {
|
||||
'CommManager': CommManager,
|
||||
'Comm': Comm
|
||||
};
|
||||
});
|
@ -1,11 +1,14 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
var comm = require('./comm');
|
||||
var serialize = require('./serialize');
|
||||
var events = require('base/js/events');
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
'./comm',
|
||||
'./serialize',
|
||||
'base/js/events'
|
||||
], function($, utils, comm, serialize, events) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* A Kernel class to communicate with the Python kernel. This
|
||||
@ -524,7 +527,7 @@
|
||||
}
|
||||
this._schedule_reconnect();
|
||||
};
|
||||
|
||||
|
||||
Kernel.prototype._schedule_reconnect = function () {
|
||||
/**
|
||||
* function to call when kernel connection is lost
|
||||
@ -542,7 +545,7 @@
|
||||
console.log("Failed to reconnect, giving up.");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Kernel.prototype.stop_channels = function () {
|
||||
/**
|
||||
* Close the websocket. After successful close, the value
|
||||
@ -596,7 +599,7 @@
|
||||
*/
|
||||
return (this.ws === null);
|
||||
};
|
||||
|
||||
|
||||
Kernel.prototype.send_shell_message = function (msg_type, content, callbacks, metadata, buffers) {
|
||||
/**
|
||||
* Send a message on the Kernel's shell channel
|
||||
@ -803,7 +806,7 @@
|
||||
delete this._msg_callbacks[msg_id];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @function _finish_shell
|
||||
*/
|
||||
@ -829,7 +832,7 @@
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set callbacks for a particular message.
|
||||
* Callbacks should be a struct of the following form:
|
||||
@ -853,7 +856,7 @@
|
||||
this.last_msg_callbacks = {};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Kernel.prototype._handle_ws_message = function (e) {
|
||||
var that = this;
|
||||
this._msg_queue = this._msg_queue.then(function() {
|
||||
@ -877,7 +880,7 @@
|
||||
console.error("unrecognized message channel", msg.channel, msg);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Kernel.prototype._handle_shell_reply = function (reply) {
|
||||
this.events.trigger('shell_reply.Kernel', {kernel: this, reply:reply});
|
||||
var that = this;
|
||||
@ -974,7 +977,7 @@
|
||||
this._kernel_dead();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Handle clear_output message
|
||||
*
|
||||
@ -1057,4 +1060,5 @@
|
||||
}
|
||||
};
|
||||
|
||||
exports.Kernel = Kernel;
|
||||
return {'Kernel': Kernel};
|
||||
});
|
@ -1,7 +1,11 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
define([
|
||||
'underscore',
|
||||
], function (_) {
|
||||
"use strict";
|
||||
|
||||
var _deserialize_array_buffer = function (buf) {
|
||||
var data = new DataView(buf);
|
||||
// read the header: 1 + nbufs 32b integers
|
||||
@ -25,7 +29,7 @@
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
var _deserialize_binary = function(data) {
|
||||
/**
|
||||
* deserialize the binary message format
|
||||
@ -62,7 +66,7 @@
|
||||
return Promise.resolve(_deserialize_binary(data));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var _serialize_binary = function (msg) {
|
||||
/**
|
||||
* implement the binary serialization protocol
|
||||
@ -105,7 +109,7 @@
|
||||
// return raw ArrayBuffer
|
||||
return msg_buf.buffer;
|
||||
};
|
||||
|
||||
|
||||
var serialize = function (msg) {
|
||||
if (msg.buffers && msg.buffers.length) {
|
||||
return _serialize_binary(msg);
|
||||
@ -113,8 +117,10 @@
|
||||
return JSON.stringify(msg);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
var exports = {
|
||||
deserialize : deserialize,
|
||||
serialize: serialize
|
||||
};
|
||||
return exports;
|
||||
});
|
@ -1,9 +1,12 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
var kernel = require('services/kernels/kernel');
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
'services/kernels/kernel',
|
||||
], function($, utils, kernel) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Session object for accessing the session REST api. The session
|
||||
@ -308,10 +311,11 @@
|
||||
this.name = "SessionAlreadyStarting";
|
||||
this.message = (message || "");
|
||||
};
|
||||
|
||||
|
||||
SessionAlreadyStarting.prototype = Error.prototype;
|
||||
|
||||
module.exports = {
|
||||
|
||||
return {
|
||||
Session: Session,
|
||||
SessionAlreadyStarting: SessionAlreadyStarting
|
||||
};
|
||||
});
|
@ -1,14 +1,23 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
require('base/js/globals').then(function() {
|
||||
var utils = require('base/js/utils');
|
||||
var page = require('base/js/page');
|
||||
var configmod = require('services/config');
|
||||
var terminado = require('terminal/js/terminado');
|
||||
requirejs(['custom/custom'], function() {
|
||||
|
||||
require([
|
||||
'jquery',
|
||||
'termjs',
|
||||
'base/js/utils',
|
||||
'base/js/page',
|
||||
'services/config',
|
||||
'terminal/js/terminado',
|
||||
'custom/custom',
|
||||
], function(
|
||||
$,
|
||||
termjs,
|
||||
utils,
|
||||
page,
|
||||
configmod,
|
||||
terminado
|
||||
){
|
||||
"use strict";
|
||||
page = new page.Page();
|
||||
|
||||
var common_config = new configmod.ConfigSection('common',
|
||||
@ -24,7 +33,7 @@ require('base/js/globals').then(function() {
|
||||
var ws_path = utils.get_body_data('wsPath');
|
||||
var ws_url = location.protocol.replace('http', 'ws') + "//" + location.host
|
||||
+ base_url + ws_path;
|
||||
|
||||
|
||||
var header = $("#header")[0]
|
||||
function calculate_size() {
|
||||
var height = $(window).height() - header.offsetHeight;
|
||||
@ -34,16 +43,16 @@ require('base/js/globals').then(function() {
|
||||
console.log("resize to :", rows , 'rows by ', cols, 'columns');
|
||||
return {rows: rows, cols: cols};
|
||||
}
|
||||
|
||||
|
||||
page.show_header();
|
||||
|
||||
|
||||
var size = calculate_size();
|
||||
var terminal = terminado.make_terminal($("#terminado-container")[0], size, ws_url);
|
||||
|
||||
|
||||
page.show_site();
|
||||
|
||||
|
||||
utils.load_extensions_from_config(common_config);
|
||||
|
||||
|
||||
window.onresize = function() {
|
||||
var geom = calculate_size();
|
||||
terminal.term.resize(geom.cols, geom.rows);
|
||||
@ -53,8 +62,5 @@ require('base/js/globals').then(function() {
|
||||
|
||||
// Expose terminal for fiddling with in the browser
|
||||
window.terminal = terminal;
|
||||
});
|
||||
|
||||
}).catch(function(err) {
|
||||
console.error('Could not load globals', err);
|
||||
});
|
@ -1,12 +1,9 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
define ([], function() {
|
||||
"use strict";
|
||||
var termjs = require('termjs');
|
||||
|
||||
exports.make_terminal = function(element, size, ws_url) {
|
||||
function make_terminal(element, size, ws_url) {
|
||||
var ws = new WebSocket(ws_url);
|
||||
termjs.Terminal.brokenBold = true;
|
||||
var term = new termjs.Terminal({
|
||||
Terminal.brokenBold = true;
|
||||
var term = new Terminal({
|
||||
cols: size.cols,
|
||||
rows: size.rows,
|
||||
screenKeys: false,
|
||||
@ -39,3 +36,6 @@
|
||||
};
|
||||
return {socket: ws, term: term};
|
||||
}
|
||||
|
||||
return {make_terminal: make_terminal};
|
||||
});
|
@ -1,9 +1,12 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
var IPython = require('base/js/namespace');
|
||||
var notebooklist = require('tree/js/notebooklist');
|
||||
define([
|
||||
'base/js/namespace',
|
||||
'jquery',
|
||||
'tree/js/notebooklist',
|
||||
], function(IPython, $, notebooklist) {
|
||||
"use strict";
|
||||
|
||||
var KernelList = function (selector, options) {
|
||||
/**
|
||||
@ -29,7 +32,7 @@
|
||||
* do nothing
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
KernelList.prototype.sessions_loaded = function (d) {
|
||||
this.sessions = d;
|
||||
this.clear_list();
|
||||
@ -65,8 +68,9 @@
|
||||
})
|
||||
.appendTo(running_indicator);
|
||||
};
|
||||
|
||||
|
||||
// Backwards compatability.
|
||||
IPython.KernelList = KernelList;
|
||||
|
||||
exports.KernelList = KernelList;
|
||||
return {'KernelList': KernelList};
|
||||
});
|
@ -1,27 +1,46 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
// Contents must be loaded at runtime.
|
||||
require('base/js/globals').then(function() {
|
||||
var IPython = require('base/js/namespace');
|
||||
var dialog = require('base/js/dialog');
|
||||
var events = require('base/js/events');
|
||||
var page = require('base/js/page');
|
||||
var utils = require('base/js/utils');
|
||||
var config = require('services/config');
|
||||
var notebooklist = require('tree/js/notebooklist');
|
||||
var sesssionlist = require('tree/js/sessionlist');
|
||||
var kernellist = require('tree/js/kernellist');
|
||||
var terminallist = require('tree/js/terminallist');
|
||||
var newnotebook = require('tree/js/newnotebook');
|
||||
var loginwidget = require('auth/js/loginwidget');
|
||||
requirejs(['contents', 'custom/custom'], 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:
|
||||
'jqueryui',
|
||||
'bootstrap',
|
||||
'custom/custom',
|
||||
], function(
|
||||
$,
|
||||
IPython,
|
||||
dialog,
|
||||
events,
|
||||
page,
|
||||
utils,
|
||||
config,
|
||||
contents_service,
|
||||
notebooklist,
|
||||
sesssionlist,
|
||||
kernellist,
|
||||
terminallist,
|
||||
newnotebook,
|
||||
loginwidget){
|
||||
"use strict";
|
||||
|
||||
IPython.NotebookList = notebooklist.NotebookList;
|
||||
|
||||
page = new page.Page();
|
||||
|
||||
|
||||
var common_options = {
|
||||
base_url: utils.get_body_data("baseUrl"),
|
||||
notebook_path: utils.get_body_data("notebookPath"),
|
||||
@ -46,7 +65,7 @@ require('base/js/globals').then(function() {
|
||||
var kernel_list = new kernellist.KernelList('#running_list', $.extend({
|
||||
session_list: session_list},
|
||||
common_options));
|
||||
|
||||
|
||||
var terminal_list;
|
||||
if (utils.get_body_data("terminalsAvailable") === "True") {
|
||||
terminal_list = new terminallist.TerminalList('#terminal_list', common_options);
|
||||
@ -129,12 +148,12 @@ require('base/js/globals').then(function() {
|
||||
events.trigger('app_initialized.DashboardApp');
|
||||
utils.load_extensions_from_config(cfg);
|
||||
utils.load_extensions_from_config(common_config);
|
||||
|
||||
|
||||
// bound the upload method to the on change of the file select list
|
||||
$("#alternate_upload").change(function (event){
|
||||
notebook_list.handleFilesUpload(event,'form');
|
||||
});
|
||||
|
||||
|
||||
// set hash on tab click
|
||||
$("#tabs").find("a").click(function(e) {
|
||||
// Prevent the document from jumping when the active tab is changed to a
|
||||
@ -150,12 +169,9 @@ require('base/js/globals').then(function() {
|
||||
window.location.hash = hash;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// load tab if url hash
|
||||
if (window.location.hash) {
|
||||
$("#tabs").find("a[href=" + window.location.hash + "]").click();
|
||||
}
|
||||
});
|
||||
}).catch(function(err) {
|
||||
console.error('Could not load globals', err);
|
||||
});
|
@ -1,11 +1,14 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/namespace',
|
||||
'base/js/utils',
|
||||
'base/js/dialog',
|
||||
], function ($, IPython, utils, dialog) {
|
||||
"use strict";
|
||||
|
||||
var IPython = require('base/js/namespace');
|
||||
var utils = require('base/js/utils');
|
||||
var dialog = require('base/js/dialog');
|
||||
|
||||
|
||||
var NewNotebookWidget = function (selector, options) {
|
||||
this.selector = selector;
|
||||
this.base_url = options.base_url;
|
||||
@ -19,20 +22,20 @@
|
||||
}
|
||||
this.bind_events();
|
||||
};
|
||||
|
||||
|
||||
NewNotebookWidget.prototype.bind_events = function () {
|
||||
var that = this;
|
||||
this.element.find('#new_notebook').click(function () {
|
||||
that.new_notebook();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
NewNotebookWidget.prototype.request_kernelspecs = function () {
|
||||
/** request and then load kernel specs */
|
||||
var url = utils.url_join_encode(this.base_url, 'api/kernelspecs');
|
||||
utils.promising_ajax(url).then($.proxy(this._load_kernelspecs, this));
|
||||
};
|
||||
|
||||
|
||||
NewNotebookWidget.prototype._load_kernelspecs = function (data) {
|
||||
/** load kernelspec list */
|
||||
var that = this;
|
||||
@ -67,7 +70,7 @@
|
||||
menu.after(li);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
NewNotebookWidget.prototype.new_notebook = function (kernel_name) {
|
||||
/** create and open a new notebook */
|
||||
var that = this;
|
||||
@ -97,5 +100,6 @@
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
exports.NewNotebookWidget = NewNotebookWidget;
|
||||
|
||||
return {'NewNotebookWidget': NewNotebookWidget};
|
||||
});
|
@ -1,13 +1,16 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'base/js/namespace',
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
'base/js/dialog',
|
||||
'base/js/events',
|
||||
'base/js/keyboard',
|
||||
], function(IPython, $, utils, dialog, events, keyboard) {
|
||||
"use strict";
|
||||
|
||||
var IPython = require('base/js/namespace');
|
||||
var utils = require('base/js/utils');
|
||||
var dialog = require('base/js/dialog');
|
||||
var events = require('base/js/events');
|
||||
var keyboard = require('base/js/keyboard');
|
||||
|
||||
|
||||
var NotebookList = function (selector, options) {
|
||||
/**
|
||||
* Constructor
|
||||
@ -880,4 +883,5 @@
|
||||
.append(cancel_button);
|
||||
};
|
||||
|
||||
exports.NotebookList = NotebookList;
|
||||
return {'NotebookList': NotebookList};
|
||||
});
|
@ -1,8 +1,11 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
], function($, utils) {
|
||||
"use strict";
|
||||
|
||||
var SesssionList = function (options) {
|
||||
/**
|
||||
@ -48,7 +51,7 @@
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
SesssionList.prototype.load_sessions = function(){
|
||||
var that = this;
|
||||
var settings = {
|
||||
@ -74,4 +77,5 @@
|
||||
this.events.trigger('sessions_loaded.Dashboard', this.sessions);
|
||||
};
|
||||
|
||||
exports.SesssionList = SesssionList;
|
||||
return {'SesssionList': SesssionList};
|
||||
});
|
@ -1,10 +1,13 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
var IPython = require('base/js/namespace');
|
||||
var utils = require('base/js/utils');
|
||||
var notebooklist = require('tree/js/notebooklist');
|
||||
define([
|
||||
'base/js/namespace',
|
||||
'base/js/utils',
|
||||
'jquery',
|
||||
'tree/js/notebooklist',
|
||||
], function(IPython, utils, $, notebooklist) {
|
||||
"use strict";
|
||||
|
||||
var TerminalList = function (selector, options) {
|
||||
/**
|
||||
@ -59,7 +62,7 @@
|
||||
);
|
||||
$.ajax(url, settings);
|
||||
};
|
||||
|
||||
|
||||
TerminalList.prototype.load_terminals = function() {
|
||||
var url = utils.url_join_encode(this.base_url, 'api/terminals');
|
||||
$.ajax(url, {
|
||||
@ -83,7 +86,7 @@
|
||||
}
|
||||
$('#terminal_list_header').toggle(data.length === 0);
|
||||
};
|
||||
|
||||
|
||||
TerminalList.prototype.add_link = function(name, item) {
|
||||
item.data('term-name', name);
|
||||
item.find(".item_name").text("terminals/" + name);
|
||||
@ -93,7 +96,7 @@
|
||||
link.attr('target', IPython._target||'_blank');
|
||||
this.add_shutdown_button(name, item);
|
||||
};
|
||||
|
||||
|
||||
TerminalList.prototype.add_shutdown_button = function(name, item) {
|
||||
var that = this;
|
||||
var shutdown_button = $("<button/>").text("Shutdown").addClass("btn btn-xs btn-warning").
|
||||
@ -114,4 +117,5 @@
|
||||
item.find(".item_buttons").text("").append(shutdown_button);
|
||||
};
|
||||
|
||||
exports.TerminalList = TerminalList;
|
||||
return {TerminalList: TerminalList};
|
||||
});
|
@ -95,5 +95,5 @@ data-file-path="{{file_path}}"
|
||||
|
||||
{{super()}}
|
||||
|
||||
<script src="{{ static_url("edit/js/main.bundle.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 %}
|
||||
|
@ -328,6 +328,10 @@ data-notebook-path="{{notebook_path}}"
|
||||
|
||||
<script src="{{ static_url("components/text-encoding/lib/encoding.js") }}" charset="utf-8"></script>
|
||||
|
||||
<script src="{{ static_url("notebook/js/main.bundle.js") }}" charset="utf-8"></script>
|
||||
{% if ignore_minified_js %}
|
||||
<script src="{{ static_url("notebook/js/main.js") }}" charset="utf-8"></script>
|
||||
{% else %}
|
||||
<script src="{{ static_url("notebook/js/main.min.js") }}" charset="utf-8"></script>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
@ -38,10 +38,13 @@
|
||||
moment: 'components/moment/moment',
|
||||
codemirror: 'components/codemirror',
|
||||
termjs: 'components/term.js/src/term',
|
||||
marked: 'components/marked/marked.min',
|
||||
caja: 'components/google-caja/html-css-sanitizer-minified'
|
||||
typeahead: 'components/jquery-typeahead/dist/jquery.typeahead'
|
||||
},
|
||||
shim: {
|
||||
typeahead: {
|
||||
deps: ["jquery"],
|
||||
exports: "typeahead"
|
||||
},
|
||||
underscore: {
|
||||
exports: '_'
|
||||
},
|
||||
|
@ -60,5 +60,5 @@ data-ws-path="{{ws_path}}"
|
||||
|
||||
{{super()}}
|
||||
|
||||
<script src="{{ static_url("terminal/js/main.bundle.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 %}
|
||||
|
@ -167,5 +167,5 @@ data-terminals-available="{{terminals_available}}"
|
||||
{% block script %}
|
||||
{{super()}}
|
||||
|
||||
<script src="{{ static_url("tree/js/main.bundle.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 %}
|
||||
|
@ -22,8 +22,8 @@ casper.notebook_test(function () {
|
||||
this.test.assertEquals(result, output, "IPython.utils.fixConsole() handles [0m correctly");
|
||||
|
||||
this.thenEvaluate(function() {
|
||||
define('nbextensions/a', [], function() { return {load_ipython_extension: function() {window.a = true;}}; });
|
||||
define('nbextensions/c', [], function() { return {load_ipython_extension: function() {window.c = true;}}; });
|
||||
define('nbextensions/a', [], function() { window.a = true; });
|
||||
define('nbextensions/c', [], function() { window.c = true; });
|
||||
require(['base/js/utils'], function(utils) {
|
||||
utils.load_extensions('a', 'b', 'c');
|
||||
});
|
||||
@ -33,12 +33,7 @@ casper.notebook_test(function () {
|
||||
});
|
||||
|
||||
this.waitFor(function() {
|
||||
return this.evaluate(function() { return window.c; });
|
||||
});
|
||||
|
||||
this.then(function() {
|
||||
this.test.assertEquals(this.evaluate(function() { return window.a; }), true, "module a loaded");
|
||||
this.test.assertEquals(this.evaluate(function() { return window.c; }), true, "module c loaded");
|
||||
return this.evaluate(function() { return window.a; });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -58,7 +58,7 @@ casper.open_new_notebook = function () {
|
||||
// track the IPython busy/idle state
|
||||
this.thenEvaluate(function () {
|
||||
require(['base/js/namespace', 'base/js/events'], function (IPython, events) {
|
||||
IPython._status = 'idle';
|
||||
|
||||
events.on('kernel_idle.Kernel',function () {
|
||||
IPython._status = 'idle';
|
||||
});
|
||||
@ -149,7 +149,7 @@ casper.wait_for_idle = function () {
|
||||
// Waits for the notebook to idle.
|
||||
this.waitFor(function () {
|
||||
return this.evaluate(function () {
|
||||
return IPython._status == 'idle' || IPython._status === undefined;
|
||||
return IPython._status == 'idle';
|
||||
});
|
||||
});
|
||||
};
|
||||
|
33
package.json
33
package.json
@ -9,39 +9,12 @@
|
||||
"url": "https://github.com/jupyter/notebook.git"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "npm run clean:js && npm run clean:css",
|
||||
"clean:css": "rimraf notebook/static/style/ipython.min.css && rimraf notebook/static/style/style.min.css",
|
||||
"clean:js": "rimraf notebook/static/auth/js && rimraf notebook/static/base/js && rimraf notebook/static/edit/js && rimraf notebook/static/notebook/js && rimraf notebook/static/terminal/js && rimraf notebook/static/tree/js && rimraf notebook/static/services",
|
||||
"uninstall": "npm run clean && rimraf notebook/static/components && rimraf node_modules",
|
||||
"postinstall": "npm run bower && npm run build",
|
||||
"bower": "bower install --allow-root --config.interactive=false",
|
||||
"build": "concurrent \"npm run build:css\" \"npm run build:js\"",
|
||||
"build:css": "concurrent \"npm run build:css:ipython\" \"npm run build:css:style\"",
|
||||
"build:css:ipython": "lessc --source-map --include-path=./notebook/static/ ./notebook/static/style/ipython.less ./notebook/static/style/ipython.min.css",
|
||||
"build:css:style": "lessc --source-map --include-path=./notebook/static/ ./notebook/static/style/style.less ./notebook/static/style/style.min.css",
|
||||
"build:js": "concurrent \"npm run build:js:amd\" \"npm run build:js:tree\" \"npm run build:js:terminal\" \"npm run build:js:notebook\" \"npm run build:js:edit\" \"npm run build:js:auth\" \"npm run build:js:contents\"",
|
||||
"build:js:amd": "node ./notebook/amd.js",
|
||||
"build:js:notebook": "node ./notebook/build.js notebook/js/main.js notebook/js/main.bundle.js",
|
||||
"build:js:contents": "node ./notebook/build.js services/contents.js services/contents.bundle.js",
|
||||
"build:js:edit": "node ./notebook/build.js edit/js/main.js edit/js/main.bundle.js",
|
||||
"build:js:tree": "node ./notebook/build.js tree/js/main.js tree/js/main.bundle.js",
|
||||
"build:js:auth": "node ./notebook/build.js auth/js/main.js auth/js/main.bundle.js",
|
||||
"build:js:terminal": "node ./notebook/build.js terminal/js/main.js terminal/js/main.bundle.js"
|
||||
"bower": "bower install",
|
||||
"build": "python setup.py js css"
|
||||
},
|
||||
"devDependencies": {
|
||||
"aliasify": "^1.7.2",
|
||||
"amd-wrap-legacy": "^0.2.0",
|
||||
"bower": "*",
|
||||
"browserify": "^11.0.1",
|
||||
"concurrently": "^0.1.1",
|
||||
"glob": "^5.0.14",
|
||||
"less": "~2",
|
||||
"marked": "~0.3",
|
||||
"mkdirp": "^0.5.1",
|
||||
"moment": "~2.8.4",
|
||||
"rimraf": "^2.4.2",
|
||||
"term.js": "~0.0.4",
|
||||
"text-encoding": "~0.1",
|
||||
"typeahead": "^0.2.0"
|
||||
"requirejs": "^2.1.17"
|
||||
}
|
||||
}
|
||||
|
4
setup.py
4
setup.py
@ -55,7 +55,7 @@ from setupbase import (
|
||||
check_package_data_first,
|
||||
CompileCSS,
|
||||
CompileJS,
|
||||
JSDeps,
|
||||
Bower,
|
||||
JavascriptVersion,
|
||||
css_js_prerelease,
|
||||
)
|
||||
@ -111,7 +111,7 @@ setup_args['cmdclass'] = {
|
||||
'sdist' : css_js_prerelease(sdist, strict=True),
|
||||
'css' : CompileCSS,
|
||||
'js' : CompileJS,
|
||||
'jsdeps' : JSDeps,
|
||||
'jsdeps' : Bower,
|
||||
'jsversion' : JavascriptVersion,
|
||||
}
|
||||
|
||||
|
200
setupbase.py
200
setupbase.py
@ -113,13 +113,13 @@ 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.bundle.js'))
|
||||
static_data.append(pjoin('static', 'services', 'contents.bundle.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)
|
||||
static_data.extend([
|
||||
pjoin(components, "backbone", "backbone-min.js"),
|
||||
pjoin(components, "bootstrap", "js", "bootstrap.min.js"),
|
||||
pjoin(components, "bootstrap-tour", "build", "css", "bootstrap-tour.min.css"),
|
||||
pjoin(components, "bootstrap-tour", "build", "js", "bootstrap-tour.min.js"),
|
||||
@ -130,10 +130,13 @@ def find_package_data():
|
||||
pjoin(components, "jquery-ui", "ui", "minified", "jquery-ui.min.js"),
|
||||
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, "requirejs", "require.js"),
|
||||
pjoin(components, "underscore", "underscore-min.js"),
|
||||
pjoin(components, "moment", "moment.js"),
|
||||
pjoin(components, "marked", "marked.min.js"),
|
||||
pjoin(components, "moment", "min", "moment.min.js"),
|
||||
pjoin(components, "term.js", "src", "term.js"),
|
||||
pjoin(components, "text-encoding", "lib", "encoding.js"),
|
||||
])
|
||||
|
||||
# Ship all of Codemirror's CSS and JS
|
||||
@ -297,28 +300,61 @@ def run(cmd, *args, **kwargs):
|
||||
return check_call(cmd, *args, **kwargs)
|
||||
|
||||
|
||||
class JSDeps(Command):
|
||||
class Bower(Command):
|
||||
description = "fetch static client-side components with bower"
|
||||
user_options = []
|
||||
|
||||
|
||||
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 should_run(self):
|
||||
if self.force:
|
||||
return True
|
||||
if not os.path.exists(self.bower_dir):
|
||||
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 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', 'install'],
|
||||
['bower', 'install', '--allow-root', '--config.interactive=false'],
|
||||
cwd=repo_root,
|
||||
env=env
|
||||
)
|
||||
except OSError as e:
|
||||
print("Failed to run `npm install`: %s" % e, file=sys.stderr)
|
||||
print("Failed to run bower: %s" % e, file=sys.stderr)
|
||||
print("You can install js dependencies with `npm install`", file=sys.stderr)
|
||||
raise
|
||||
os.utime(self.bower_dir, None)
|
||||
# update package data in case this created new files
|
||||
update_package_data(self.distribution)
|
||||
|
||||
@ -338,51 +374,103 @@ 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):
|
||||
self.run_command('jsdeps')
|
||||
env = os.environ.copy()
|
||||
env['PATH'] = npm_path
|
||||
try:
|
||||
run(
|
||||
['npm', 'run', 'build:css'],
|
||||
cwd=repo_root,
|
||||
env=env
|
||||
)
|
||||
except OSError as e:
|
||||
print("Failed to run `npm run build:css`: %s" % e, file=sys.stderr)
|
||||
raise
|
||||
|
||||
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)
|
||||
|
||||
|
||||
class CompileJS(Command):
|
||||
"""Rebuild Notebook Javascript main.min.js files
|
||||
|
||||
Calls require via build-main.js
|
||||
"""
|
||||
description = "Rebuild Notebook Javascript main.min.js files"
|
||||
user_options = []
|
||||
|
||||
user_options = [
|
||||
('force', 'f', "force rebuilding js targets"),
|
||||
]
|
||||
|
||||
def initialize_options(self):
|
||||
pass
|
||||
self.force = False
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
self.force = bool(self.force)
|
||||
|
||||
apps = ['notebook', 'tree', 'edit', 'terminal', 'auth']
|
||||
targets = [ pjoin(static, app, 'js', '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')
|
||||
|
||||
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
|
||||
dirs[:] = []
|
||||
continue
|
||||
for f in files:
|
||||
yield pjoin(parent, f)
|
||||
|
||||
def should_run(self, name, target):
|
||||
if self.force or not os.path.exists(target):
|
||||
return True
|
||||
target_mtime = mtime(target)
|
||||
for source in self.sources(name):
|
||||
if mtime(source) > target_mtime:
|
||||
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')
|
||||
env = os.environ.copy()
|
||||
env['PATH'] = npm_path
|
||||
try:
|
||||
run(
|
||||
['npm', 'run', 'build:js'],
|
||||
cwd=repo_root,
|
||||
env=env
|
||||
)
|
||||
except OSError as e:
|
||||
print("Failed to run `npm run build:js`: %s" % e, file=sys.stderr)
|
||||
raise
|
||||
pool = ThreadPool()
|
||||
pool.map(self.build_main, self.apps)
|
||||
# update package data in case this created new files
|
||||
update_package_data(self.distribution)
|
||||
|
||||
|
||||
class JavascriptVersion(Command):
|
||||
"""write the javascript version to notebook javascript"""
|
||||
description = "Write Jupyter version to javascript"
|
||||
@ -395,7 +483,7 @@ class JavascriptVersion(Command):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
nsfile = pjoin(repo_root, "notebook", "static-src", "base", "js", "namespace.js")
|
||||
nsfile = pjoin(repo_root, "notebook", "static", "base", "js", "namespace.js")
|
||||
with open(nsfile) as f:
|
||||
lines = f.readlines()
|
||||
with open(nsfile, 'w') as f:
|
||||
@ -414,11 +502,45 @@ def css_js_prerelease(command, strict=False):
|
||||
class DecoratedCommand(command):
|
||||
def run(self):
|
||||
self.distribution.run_command('jsversion')
|
||||
jsdeps = self.distribution.get_command_obj('jsdeps')
|
||||
js = self.distribution.get_command_obj('js')
|
||||
css = self.distribution.get_command_obj('css')
|
||||
jsdeps.force = js.force = strict
|
||||
|
||||
targets = [ jsdeps.bower_dir ]
|
||||
targets.extend(js.targets)
|
||||
targets.extend(css.targets)
|
||||
missing = [ t for t in targets if not os.path.exists(t) ]
|
||||
|
||||
if not is_repo and not missing:
|
||||
# If we're an sdist, we aren't a repo and everything should be present.
|
||||
# Don't rebuild js/css in that case.
|
||||
command.run(self)
|
||||
return
|
||||
|
||||
try:
|
||||
self.distribution.run_command('jsdeps')
|
||||
self.distribution.run_command('css')
|
||||
self.distribution.run_command('js')
|
||||
except Exception as e:
|
||||
log.warn("rebuilding js and css failed.")
|
||||
raise e
|
||||
|
||||
# refresh missing
|
||||
missing = [ t for t in targets if not os.path.exists(t) ]
|
||||
if strict or missing:
|
||||
# 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.warn("rebuilding js and css failed. The following required files are missing: %s" % missing)
|
||||
raise e
|
||||
else:
|
||||
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) ]
|
||||
if missing:
|
||||
# command succeeded, but targets still missing (?!)
|
||||
prefix = os.path.commonprefix([repo_root + os.sep] + missing)
|
||||
missing = [ m[len(prefix):] for m in missing ]
|
||||
raise ValueError("The following required files are missing: %s" % missing)
|
||||
|
||||
command.run(self)
|
||||
return DecoratedCommand
|
||||
|
Loading…
x
Reference in New Issue
Block a user