mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-27 04:20:22 +08:00
Merge pull request #268 from jdfreder/npm
Use NPM, node ES5, and browserify.
This commit is contained in:
commit
62101281e0
14
.gitignore
vendored
14
.gitignore
vendored
@ -25,3 +25,17 @@ 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
|
||||
|
6
.jshintrc
Normal file
6
.jshintrc
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"browserify": true,
|
||||
"node": true,
|
||||
"jquery": true,
|
||||
"predef": [ "requirejs", "define", "Promise", "CodeMirror"]
|
||||
}
|
33
README.md
33
README.md
@ -27,3 +27,36 @@ 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,20 +2,21 @@
|
||||
"name": "jupyter-notebook-deps",
|
||||
"version": "0.0.1",
|
||||
"dependencies": {
|
||||
"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",
|
||||
"requirejs": "~2.1",
|
||||
"google-caja": "5669",
|
||||
"MathJax": "components/MathJax#~2.5",
|
||||
"bootstrap": "components/bootstrap#~3.3",
|
||||
"bootstrap-tour": "0.9.0",
|
||||
"jquery": "components/jquery#~2.0",
|
||||
"jquery-ui": "components/jqueryui#~1.10",
|
||||
"marked": "~0.3",
|
||||
"MathJax": "components/MathJax#~2.5",
|
||||
"moment": "~2.8.4",
|
||||
"requirejs": "~2.1",
|
||||
"codemirror": "~5.5",
|
||||
|
||||
"term.js": "chjj/term.js#~0.0.4",
|
||||
"backbone": "components/backbone#~1.2",
|
||||
"marked": "~0.3",
|
||||
"moment": "~2.8.4",
|
||||
"text-encoding": "~0.1",
|
||||
"underscore": "components/underscore#~1.5",
|
||||
"jquery-typeahead": "~2.0.0"
|
||||
|
35
notebook/amd.js
Normal file
35
notebook/amd.js
Normal file
@ -0,0 +1,35 @@
|
||||
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'))
|
||||
return self.settings.get('contents_js_source', 'services/contents')
|
||||
'services/contents.bundle'))
|
||||
return self.settings.get('contents_js_source', 'services/contents.bundle')
|
||||
|
||||
#---------------------------------------------------------------
|
||||
# Manager objects
|
||||
|
35
notebook/build.js
Normal file
35
notebook/build.js
Normal file
@ -0,0 +1,35 @@
|
||||
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));
|
||||
}
|
||||
});
|
14
notebook/static-src/auth/js/loginmain.js
Normal file
14
notebook/static-src/auth/js/loginmain.js
Normal file
@ -0,0 +1,14 @@
|
||||
// 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,12 +1,10 @@
|
||||
// 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");
|
||||
@ -34,5 +32,4 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
return {'LoginWidget': LoginWidget};
|
||||
});
|
||||
exports.LoginWidget = LoginWidget;
|
@ -1,12 +1,12 @@
|
||||
// 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 logout_main() {
|
||||
var IPython = require('base/js/namespace');
|
||||
var page = require('base/js/page');
|
||||
|
||||
module.exports = function logoutMain() {
|
||||
var page_instance = new page.Page();
|
||||
page_instance.show();
|
||||
|
||||
IPython.page = page_instance;
|
||||
}
|
||||
return logout_main;
|
||||
});
|
||||
};
|
5
notebook/static-src/auth/js/main.js
Normal file
5
notebook/static-src/auth/js/main.js
Normal file
@ -0,0 +1,5 @@
|
||||
// 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,11 +1,7 @@
|
||||
// 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
|
||||
@ -37,7 +33,6 @@ define(function(require) {
|
||||
*
|
||||
**/
|
||||
var modal = function (options) {
|
||||
|
||||
var modal = $("<div/>")
|
||||
.addClass("modal")
|
||||
.addClass("fade")
|
||||
@ -198,13 +193,11 @@ define(function(require) {
|
||||
});
|
||||
|
||||
modal_obj.on('shown.bs.modal', function(){ editor.refresh(); });
|
||||
|
||||
};
|
||||
|
||||
var dialog = {
|
||||
|
||||
module.exports = {
|
||||
modal : modal,
|
||||
kernel_modal : kernel_modal,
|
||||
edit_metadata : edit_metadata,
|
||||
};
|
||||
|
||||
return dialog;
|
||||
});
|
@ -8,17 +8,11 @@
|
||||
// require(['base/js/events'], function (events) {
|
||||
// events.on("event.Namespace", function () { do_stuff(); });
|
||||
// });
|
||||
"use strict";
|
||||
|
||||
define(['base/js/namespace', 'jquery'], function(IPython, $) {
|
||||
"use strict";
|
||||
|
||||
if (!window.jupyterEvents) {
|
||||
var Events = function () {};
|
||||
|
||||
var events = new Events();
|
||||
|
||||
// Backwards compatability.
|
||||
IPython.Events = Events;
|
||||
IPython.events = events;
|
||||
|
||||
return $([events]);
|
||||
});
|
||||
window.jupyterEvents = $([new Events()]);
|
||||
}
|
||||
|
||||
module.exports = window.jupyterEvents;
|
94
notebook/static-src/base/js/globals.js
Normal file
94
notebook/static-src/base/js/globals.js
Normal file
@ -0,0 +1,94 @@
|
||||
// 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);
|
||||
});
|
||||
});
|
@ -8,13 +8,10 @@
|
||||
* @class ShortcutManager
|
||||
*/
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
'underscore',
|
||||
], function($, utils, _) {
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
|
||||
|
||||
/**
|
||||
* Setup global keycodes and inverse keycodes.
|
||||
@ -45,20 +42,20 @@ define([
|
||||
'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') {
|
||||
@ -455,7 +452,7 @@ define([
|
||||
return (typeof(action_name) !== 'undefined');
|
||||
};
|
||||
|
||||
var keyboard = {
|
||||
module.exports = {
|
||||
keycodes : keycodes,
|
||||
inv_keycodes : inv_keycodes,
|
||||
ShortcutManager : ShortcutManager,
|
||||
@ -464,6 +461,3 @@ define([
|
||||
shortcut_to_event : shortcut_to_event,
|
||||
event_to_shortcut : event_to_shortcut,
|
||||
};
|
||||
|
||||
return keyboard;
|
||||
});
|
70
notebook/static-src/base/js/namespace.js
Normal file
70
notebook/static-src/base/js/namespace.js
Normal file
@ -0,0 +1,70 @@
|
||||
// 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;
|
@ -1,12 +1,10 @@
|
||||
// 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;
|
||||
|
||||
@ -79,5 +77,4 @@ define([
|
||||
return this.widget_dict[name];
|
||||
};
|
||||
|
||||
return {'NotificationArea': NotificationArea};
|
||||
});
|
||||
exports.NotificationArea = NotificationArea;
|
@ -1,9 +1,6 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
], function($) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
@ -37,7 +34,7 @@ define([
|
||||
// for this particular combination
|
||||
this.element.addClass('notification_widget btn btn-xs navbar-btn');
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* hide the widget and empty the text
|
||||
**/
|
||||
@ -166,5 +163,4 @@ define([
|
||||
return this.inner.html();
|
||||
};
|
||||
|
||||
return {'NotificationWidget': NotificationWidget};
|
||||
});
|
||||
exports.NotificationWidget = NotificationWidget;
|
@ -1,11 +1,9 @@
|
||||
// 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();
|
||||
@ -58,5 +56,4 @@ define([
|
||||
$('div#site').height($(window).height() - $('#header').height());
|
||||
};
|
||||
|
||||
return {'Page': Page};
|
||||
});
|
||||
exports.Page = Page;
|
@ -1,21 +1,19 @@
|
||||
// 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
|
||||
@ -33,7 +31,7 @@ define([
|
||||
}
|
||||
return caja.sanitizeAttribs(tagName, attribs, opt_naiveUriRewriter, opt_nmTokenPolicy, opt_logger);
|
||||
};
|
||||
|
||||
|
||||
var sanitize_css = function (css, tagPolicy) {
|
||||
/**
|
||||
* sanitize CSS
|
||||
@ -52,7 +50,7 @@ define([
|
||||
noop
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
var sanitize_stylesheets = function (html, tagPolicy) {
|
||||
/**
|
||||
* sanitize just the css in style tags in a block of html
|
||||
@ -69,7 +67,7 @@ define([
|
||||
});
|
||||
return h.html();
|
||||
};
|
||||
|
||||
|
||||
var sanitize_html = function (html, allow_css) {
|
||||
/**
|
||||
* sanitize HTML
|
||||
@ -116,11 +114,8 @@ define([
|
||||
|
||||
return sanitized;
|
||||
};
|
||||
|
||||
var security = {
|
||||
|
||||
module.exports = {
|
||||
caja: caja,
|
||||
sanitize_html: sanitize_html
|
||||
};
|
||||
|
||||
return security;
|
||||
});
|
@ -1,15 +1,10 @@
|
||||
// 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.
|
||||
@ -17,7 +12,7 @@ define([
|
||||
*/
|
||||
var load_extension = function (extension) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
require(["nbextensions/" + extension], function(module) {
|
||||
requirejs(["nbextensions/" + extension], function(module) {
|
||||
console.log("Loaded extension: " + extension);
|
||||
try {
|
||||
module.load_ipython_extension();
|
||||
@ -217,7 +212,7 @@ define([
|
||||
"46":"ansibgcyan",
|
||||
"47":"ansibggray"
|
||||
};
|
||||
|
||||
|
||||
function _process_numbers(attrs, numbers) {
|
||||
// process ansi escapes
|
||||
var n = numbers.shift();
|
||||
@ -374,7 +369,7 @@ define([
|
||||
test.remove();
|
||||
return Math.floor(points*pixel_per_point);
|
||||
};
|
||||
|
||||
|
||||
var always_new = function (constructor) {
|
||||
/**
|
||||
* wrapper around contructor to avoid requiring `var a = new constructor()`
|
||||
@ -407,7 +402,7 @@ define([
|
||||
url = url.replace(/\/\/+/, '/');
|
||||
return url;
|
||||
};
|
||||
|
||||
|
||||
var url_path_split = function (path) {
|
||||
/**
|
||||
* Like os.path.split for URLs.
|
||||
@ -421,7 +416,7 @@ define([
|
||||
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
|
||||
@ -437,7 +432,7 @@ define([
|
||||
a.href = url;
|
||||
return a;
|
||||
};
|
||||
|
||||
|
||||
var encode_uri_components = function (uri) {
|
||||
/**
|
||||
* encode just the components of a multi-segment uri,
|
||||
@ -445,7 +440,7 @@ define([
|
||||
*/
|
||||
return uri.split('/').map(encodeURIComponent).join('/');
|
||||
};
|
||||
|
||||
|
||||
var url_join_encode = function () {
|
||||
/**
|
||||
* join a sequence of url components with '/',
|
||||
@ -488,7 +483,7 @@ define([
|
||||
return val;
|
||||
return decodeURIComponent(val);
|
||||
};
|
||||
|
||||
|
||||
var to_absolute_cursor_pos = function (cm, cursor) {
|
||||
/**
|
||||
* get the absolute cursor position from CodeMirror's col, ch
|
||||
@ -502,7 +497,7 @@ define([
|
||||
}
|
||||
return cursor_pos;
|
||||
};
|
||||
|
||||
|
||||
var from_absolute_cursor_pos = function (cm, cursor_pos) {
|
||||
/**
|
||||
* turn absolute cursor position into CodeMirror col, ch cursor
|
||||
@ -526,7 +521,7 @@ define([
|
||||
ch : line.length - 1,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// http://stackoverflow.com/questions/2400935/browser-detection-in-javascript
|
||||
var browser = (function() {
|
||||
if (typeof navigator === 'undefined') {
|
||||
@ -553,7 +548,7 @@ define([
|
||||
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
|
||||
@ -562,7 +557,7 @@ define([
|
||||
return decodeURIComponent(match[1] || '');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var is_or_has = function (a, b) {
|
||||
/**
|
||||
* Is b a child of a or a itself?
|
||||
@ -586,13 +581,13 @@ define([
|
||||
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,
|
||||
@ -626,6 +621,7 @@ define([
|
||||
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
|
||||
@ -641,7 +637,7 @@ define([
|
||||
CodeMirror.findModeByMIME(modename) ||
|
||||
{mode: modename, mime: modename};
|
||||
|
||||
require([
|
||||
requirejs([
|
||||
// might want to use CodeMirror.modeURL here
|
||||
['codemirror/mode', info.mode, info.mode].join('/'),
|
||||
], function() {
|
||||
@ -651,10 +647,10 @@ define([
|
||||
}, errback
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/** Error type for wrapped XHR errors. */
|
||||
var XHR_ERROR = 'XhrError';
|
||||
|
||||
|
||||
/**
|
||||
* Wraps an AJAX error as an Error object.
|
||||
*/
|
||||
@ -667,7 +663,7 @@ define([
|
||||
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
|
||||
@ -728,7 +724,7 @@ define([
|
||||
|
||||
// Try loading the view module using require.js
|
||||
if (module_name) {
|
||||
require([module_name], function(module) {
|
||||
requirejs([module_name], function(module) {
|
||||
if (module[class_name] === undefined) {
|
||||
reject(new Error('Class '+class_name+' not found in module '+module_name));
|
||||
} else {
|
||||
@ -805,14 +801,14 @@ define([
|
||||
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,
|
||||
@ -820,7 +816,7 @@ define([
|
||||
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
|
||||
|
||||
@ -840,8 +836,8 @@ define([
|
||||
return time.milliseconds.h;
|
||||
}
|
||||
};
|
||||
|
||||
var utils = {
|
||||
|
||||
module.exports = {
|
||||
load_extension: load_extension,
|
||||
load_extensions: load_extensions,
|
||||
load_extensions_from_config: load_extensions_from_config,
|
||||
@ -881,6 +877,3 @@ define([
|
||||
typeset: typeset,
|
||||
time: time,
|
||||
};
|
||||
|
||||
return utils;
|
||||
});
|
@ -1,26 +1,9 @@
|
||||
// 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;
|
||||
@ -59,7 +42,7 @@ function($,
|
||||
$('.last_modified').before(this.clean_sel);
|
||||
this.clean_sel.addClass('dirty-indicator-dirty');
|
||||
};
|
||||
|
||||
|
||||
// default CodeMirror options
|
||||
Editor.default_codemirror_options = {
|
||||
extraKeys: {
|
||||
@ -70,7 +53,7 @@ function($,
|
||||
lineNumbers: true,
|
||||
lineWrapping: true,
|
||||
};
|
||||
|
||||
|
||||
Editor.prototype.load = function() {
|
||||
/** load the file */
|
||||
var that = this;
|
||||
@ -141,7 +124,7 @@ function($,
|
||||
that.events.trigger("mode_changed.Editor", modeinfo);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Editor.prototype.get_filename = function () {
|
||||
return utils.url_path_split(this.file_path)[1];
|
||||
};
|
||||
@ -160,7 +143,7 @@ function($,
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Editor.prototype.save = function () {
|
||||
/** save the file */
|
||||
if (!this.save_enabled) {
|
||||
@ -210,7 +193,7 @@ function($,
|
||||
});
|
||||
var that = this;
|
||||
};
|
||||
|
||||
|
||||
Editor.prototype.update_codemirror_options = function (options) {
|
||||
/** update codemirror options locally and save changes in config */
|
||||
var that = this;
|
||||
@ -224,5 +207,4 @@ function($,
|
||||
);
|
||||
};
|
||||
|
||||
return {Editor: Editor};
|
||||
});
|
||||
exports.Editor = Editor;
|
@ -1,33 +1,22 @@
|
||||
// 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');
|
||||
@ -36,11 +25,11 @@ require([
|
||||
config.load();
|
||||
var common_config = new configmod.ConfigSection('common', {base_url: base_url});
|
||||
common_config.load();
|
||||
contents = new contents.Contents({
|
||||
var contents = new contents_service.Contents({
|
||||
base_url: base_url,
|
||||
common_config: common_config
|
||||
});
|
||||
|
||||
|
||||
var editor = new editmod.Editor('#texteditor-container', {
|
||||
base_url: base_url,
|
||||
events: events,
|
||||
@ -48,22 +37,22 @@ require([
|
||||
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,
|
||||
@ -95,3 +84,8 @@ require([
|
||||
// On document ready, resize codemirror.
|
||||
$(document).ready(_handle_resize);
|
||||
});
|
||||
|
||||
}).catch(function(err) {
|
||||
console.error('Could not load globals', err);
|
||||
});
|
||||
|
@ -1,17 +1,11 @@
|
||||
// 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
|
||||
@ -134,7 +128,7 @@ define([
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
MenuBar.prototype._load_mode_menu = function () {
|
||||
var list = this.element.find("#mode-menu");
|
||||
var editor = this.editor;
|
||||
@ -156,5 +150,4 @@ define([
|
||||
}
|
||||
};
|
||||
|
||||
return {'MenuBar': MenuBar};
|
||||
});
|
||||
exports.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,7 +23,5 @@ define([
|
||||
savew.set_message("File saved", 2000);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
return {EditorNotificationArea: EditorNotificationArea};
|
||||
});
|
||||
exports.EditorNotificationArea = EditorNotificationArea;
|
@ -1,15 +1,12 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
'base/js/dialog',
|
||||
'base/js/keyboard',
|
||||
'moment',
|
||||
], function($, utils, dialog, keyboard, moment) {
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
var dialog = require('base/js/dialog');
|
||||
var keyboard = require('base/js/keyboard');
|
||||
var moment = require('moment');
|
||||
|
||||
var SaveWidget = function (selector, options) {
|
||||
this.editor = undefined;
|
||||
this.selector = selector;
|
||||
@ -134,7 +131,7 @@ define([
|
||||
}
|
||||
this._render_last_modified();
|
||||
};
|
||||
|
||||
|
||||
SaveWidget.prototype._render_last_modified = function () {
|
||||
/** actually set the text in the element, from our _last_modified value
|
||||
|
||||
@ -160,7 +157,7 @@ define([
|
||||
}
|
||||
el.text(human_date).attr('title', long_date);
|
||||
};
|
||||
|
||||
|
||||
SaveWidget.prototype._schedule_render_last_modified = function () {
|
||||
/** schedule the next update to relative date
|
||||
|
||||
@ -179,6 +176,4 @@ define([
|
||||
);
|
||||
};
|
||||
|
||||
return {'SaveWidget': SaveWidget};
|
||||
|
||||
});
|
||||
exports.SaveWidget = SaveWidget;
|
@ -1,12 +1,10 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
require([
|
||||
'jquery',
|
||||
'base/js/dialog',
|
||||
'underscore',
|
||||
'base/js/namespace'
|
||||
], function ($, dialog, _, IPython) {
|
||||
'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/>';
|
||||
@ -35,4 +33,3 @@ require([
|
||||
kinfo.html($('<p/>').text('unable to contact kernel'));
|
||||
}
|
||||
});
|
||||
});
|
@ -1,7 +1,5 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define(function(require){
|
||||
"use strict";
|
||||
|
||||
|
||||
@ -575,6 +573,4 @@ define(function(require){
|
||||
return (typeof(this._actions[name]) !== 'undefined');
|
||||
};
|
||||
|
||||
return {init:ActionHandler};
|
||||
|
||||
});
|
||||
exports.init = ActionHandler;
|
@ -8,20 +8,12 @@
|
||||
* @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
|
||||
@ -34,7 +26,7 @@ define([
|
||||
this.horiz.style.minHeight = "";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var Cell = function (options) {
|
||||
/* Constructor
|
||||
*
|
||||
@ -122,7 +114,7 @@ define([
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// FIXME: Workaround CM Bug #332 (Safari segfault on drag)
|
||||
// by disabling drag/drop altogether on Safari
|
||||
// https://github.com/codemirror/CodeMirror/issues/332
|
||||
@ -201,7 +193,7 @@ define([
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This method gets called in CodeMirror's onKeyDown/onKeyPress
|
||||
* handlers and is used to provide custom key handling.
|
||||
@ -397,7 +389,7 @@ define([
|
||||
this.focus_cell();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Focus the cell in the DOM sense
|
||||
* @method focus_cell
|
||||
@ -553,7 +545,7 @@ define([
|
||||
this.user_highlight = mode;
|
||||
this.auto_highlight();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Trigger autodetection of highlight scheme for current cell
|
||||
* @method auto_highlight
|
||||
@ -561,7 +553,7 @@ define([
|
||||
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
|
||||
@ -659,17 +651,17 @@ define([
|
||||
};
|
||||
|
||||
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
|
||||
@ -686,7 +678,7 @@ define([
|
||||
}
|
||||
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');
|
||||
@ -703,7 +695,7 @@ define([
|
||||
cell.append(inner_cell);
|
||||
this.element = cell;
|
||||
};
|
||||
|
||||
|
||||
UnrecognizedCell.prototype.bind_events = function () {
|
||||
Cell.prototype.bind_events.apply(this, arguments);
|
||||
var cell = this;
|
||||
@ -713,8 +705,7 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
module.exports = {
|
||||
Cell: Cell,
|
||||
UnrecognizedCell: UnrecognizedCell
|
||||
};
|
||||
});
|
@ -1,13 +1,10 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'base/js/namespace',
|
||||
'jquery',
|
||||
'base/js/events'
|
||||
], function(IPython, $, events) {
|
||||
"use strict";
|
||||
|
||||
var IPython = require('base/js/namespace');
|
||||
var events = require('base/js/events');
|
||||
|
||||
var CellToolbar = function (options) {
|
||||
/**
|
||||
* Constructor
|
||||
@ -464,5 +461,4 @@ define([
|
||||
// Backwards compatability.
|
||||
IPython.CellToolbar = CellToolbar;
|
||||
|
||||
return {'CellToolbar': CellToolbar};
|
||||
});
|
||||
exports.CellToolbar = CellToolbar;
|
@ -1,13 +1,10 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'notebook/js/celltoolbar',
|
||||
'base/js/dialog',
|
||||
], function($, celltoolbar, dialog) {
|
||||
"use strict";
|
||||
|
||||
var celltoolbar = require('notebook/js/celltoolbar');
|
||||
var dialog = require('base/js/dialog');
|
||||
|
||||
var CellToolbar = celltoolbar.CellToolbar;
|
||||
|
||||
var raw_edit = function (cell) {
|
||||
@ -47,5 +44,4 @@ define([
|
||||
CellToolbar.register_preset('Edit Metadata', example_preset, notebook);
|
||||
console.log('Default extension for cell metadata editing loaded.');
|
||||
};
|
||||
return {'register': register};
|
||||
});
|
||||
exports.register = register;
|
@ -8,12 +8,8 @@
|
||||
// ```
|
||||
// $.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 = [];
|
||||
@ -146,5 +142,4 @@ define([
|
||||
CellToolbar.register_preset('Example',example_preset, notebook);
|
||||
console.log('Example extension for metadata editing loaded.');
|
||||
};
|
||||
return {'register': register};
|
||||
});
|
||||
exports.register = register;
|
@ -1,18 +1,15 @@
|
||||
// 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 = celltoolbar.CellToolbar;
|
||||
var raw_cell_preset = [];
|
||||
var celltoolbar = require('notebook/js/celltoolbar');
|
||||
var dialog = require('base/js/dialog');
|
||||
var keyboard = require('base/js/keyboard');
|
||||
|
||||
var select_type = CellToolbar.utils.select_ui_generator([
|
||||
var CellToolbar = celltoolbar.CellToolbar;
|
||||
var raw_cell_preset = [];
|
||||
|
||||
var select_type = CellToolbar.utils.select_ui_generator([
|
||||
["None", "-"],
|
||||
["LaTeX", "text/latex"],
|
||||
["reST", "text/restructuredtext"],
|
||||
@ -72,15 +69,13 @@ define([
|
||||
},
|
||||
// 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.');
|
||||
};
|
||||
return {'register': register};
|
||||
|
||||
});
|
||||
};
|
||||
exports.register = register;
|
@ -1,12 +1,8 @@
|
||||
// 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 = [];
|
||||
@ -42,5 +38,4 @@ define([
|
||||
CellToolbar.register_preset('Slideshow',slideshow_preset, notebook);
|
||||
console.log('Slideshow extension for metadata editing loaded.');
|
||||
};
|
||||
return {'register': register};
|
||||
});
|
||||
exports.register = register;
|
@ -7,36 +7,17 @@
|
||||
* @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 */
|
||||
@ -144,7 +125,7 @@ define([
|
||||
CodeCell.msg_cells = {};
|
||||
|
||||
CodeCell.prototype = Object.create(Cell.prototype);
|
||||
|
||||
|
||||
/** @method create_element */
|
||||
CodeCell.prototype.create_element = function () {
|
||||
Cell.prototype.create_element.apply(this, arguments);
|
||||
@ -331,7 +312,7 @@ define([
|
||||
this.render();
|
||||
this.events.trigger('execute.CodeCell', {cell: this});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Construct the default callbacks for
|
||||
* @method get_callbacks
|
||||
@ -357,7 +338,7 @@ define([
|
||||
input : $.proxy(this._handle_input_request, this)
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
CodeCell.prototype._open_with_pager = function (payload) {
|
||||
this.events.trigger('open_with_text.Pager', payload);
|
||||
};
|
||||
@ -406,7 +387,7 @@ define([
|
||||
// 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();
|
||||
@ -555,5 +536,4 @@ define([
|
||||
// Backwards compatability.
|
||||
IPython.CodeCell = CodeCell;
|
||||
|
||||
return {'CodeCell': CodeCell};
|
||||
});
|
||||
exports.CodeCell = CodeCell;
|
@ -1,12 +1,10 @@
|
||||
// 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
|
||||
@ -174,5 +172,4 @@ define(function(require){
|
||||
|
||||
mod.modal('show');
|
||||
};
|
||||
return {'CommandPalette': CommandPalette};
|
||||
});
|
||||
module.exports = {'CommandPalette': CommandPalette};
|
@ -1,15 +1,11 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
'base/js/keyboard',
|
||||
'notebook/js/contexthint',
|
||||
'codemirror/lib/codemirror',
|
||||
], function($, utils, keyboard, CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
var keyboard = require('base/js/keyboard');
|
||||
require('notebook/js/contexthint');
|
||||
|
||||
// easier key mapping
|
||||
var keycodes = keyboard.keycodes;
|
||||
|
||||
@ -408,5 +404,4 @@ define([
|
||||
}, 50);
|
||||
};
|
||||
|
||||
return {'Completer': Completer};
|
||||
});
|
||||
exports.Completer = Completer;
|
@ -2,7 +2,6 @@
|
||||
// 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) {
|
||||
@ -94,5 +93,4 @@ define(['codemirror/lib/codemirror'], function(CodeMirror) {
|
||||
return filterd;
|
||||
};
|
||||
|
||||
return {'contextHint': CodeMirror.contextHint};
|
||||
});
|
||||
exports.contextHint = CodeMirror.contextHint;
|
@ -1,14 +1,9 @@
|
||||
// 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;
|
||||
@ -32,14 +27,14 @@ define([
|
||||
|
||||
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) {
|
||||
@ -55,7 +50,7 @@ define([
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
KernelSelector.prototype._got_kernelspecs = function(data) {
|
||||
var that = this;
|
||||
this.kernelspecs = data.kernelspecs;
|
||||
@ -93,7 +88,7 @@ define([
|
||||
this._loaded = true;
|
||||
this._finish_load();
|
||||
};
|
||||
|
||||
|
||||
KernelSelector.prototype._spec_changed = function (event, ks) {
|
||||
/** event handler for spec_changed */
|
||||
var that = this;
|
||||
@ -147,7 +142,7 @@ define([
|
||||
|
||||
// load kernel js
|
||||
if (ks.resources['kernel.js']) {
|
||||
require([ks.resources['kernel.js']],
|
||||
requirejs([ks.resources['kernel.js']],
|
||||
function (kernel_mod) {
|
||||
if (kernel_mod && kernel_mod.onload) {
|
||||
kernel_mod.onload();
|
||||
@ -238,7 +233,7 @@ define([
|
||||
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');
|
||||
@ -333,5 +328,4 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
return {'KernelSelector': KernelSelector};
|
||||
});
|
||||
exports.KernelSelector = KernelSelector;
|
@ -7,14 +7,10 @@
|
||||
* @namespace keyboardmanager
|
||||
* @class KeyboardManager
|
||||
*/
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
'base/js/keyboard',
|
||||
], function($, utils, keyboard) {
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
var keyboard = require('base/js/keyboard');
|
||||
|
||||
// Main keyboard manager for the notebook
|
||||
var keycodes = keyboard.keycodes;
|
||||
|
||||
@ -139,7 +135,7 @@ define([
|
||||
this.notebook = notebook;
|
||||
this.actions.extend_env({notebook:notebook});
|
||||
};
|
||||
|
||||
|
||||
KeyboardManager.prototype.set_quickhelp = function (notebook) {
|
||||
this.actions.extend_env({quick_help:notebook});
|
||||
};
|
||||
@ -226,5 +222,4 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
return {'KeyboardManager': KeyboardManager};
|
||||
});
|
||||
exports.KeyboardManager = KeyboardManager;
|
@ -1,67 +1,30 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
require([
|
||||
'base/js/namespace',
|
||||
'jquery',
|
||||
'notebook/js/notebook',
|
||||
'contents',
|
||||
'services/config',
|
||||
'base/js/utils',
|
||||
'base/js/page',
|
||||
'base/js/events',
|
||||
'auth/js/loginwidget',
|
||||
'notebook/js/maintoolbar',
|
||||
'notebook/js/pager',
|
||||
'notebook/js/quickhelp',
|
||||
'notebook/js/menubar',
|
||||
'notebook/js/notificationarea',
|
||||
'notebook/js/savewidget',
|
||||
'notebook/js/actions',
|
||||
'notebook/js/keyboardmanager',
|
||||
'notebook/js/kernelselector',
|
||||
'codemirror/lib/codemirror',
|
||||
'notebook/js/about',
|
||||
'typeahead',
|
||||
'notebook/js/searchandreplace',
|
||||
// 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');
|
||||
// only loaded, not used, please keep sure this is loaded last
|
||||
'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;
|
||||
requirejs(['contents', 'custom/custom'], function(contents_service) {
|
||||
|
||||
var common_options = {
|
||||
ws_url : utils.get_body_data("wsUrl"),
|
||||
@ -74,8 +37,8 @@ require([
|
||||
config_section.load();
|
||||
var common_config = new configmod.ConfigSection('common', common_options);
|
||||
common_config.load();
|
||||
var page = new page.Page();
|
||||
var pager = new pager.Pager('div#pager', {
|
||||
page = new page.Page();
|
||||
pager = new pager.Pager('div#pager', {
|
||||
events: events});
|
||||
var acts = new actions.init();
|
||||
var keyboard_manager = new keyboardmanager.KeyboardManager({
|
||||
@ -85,11 +48,11 @@ require([
|
||||
var save_widget = new savewidget.SaveWidget('span#save_widget', {
|
||||
events: events,
|
||||
keyboard_manager: keyboard_manager});
|
||||
var contents = new contents.Contents({
|
||||
var contents = new contents_service.Contents({
|
||||
base_url: common_options.base_url,
|
||||
common_config: common_config
|
||||
});
|
||||
var notebook = new notebook.Notebook('div#notebook', $.extend({
|
||||
notebook = new notebook.Notebook('div#notebook', $.extend({
|
||||
events: events,
|
||||
keyboard_manager: keyboard_manager,
|
||||
save_widget: save_widget,
|
||||
@ -107,7 +70,7 @@ require([
|
||||
notebook: notebook});
|
||||
keyboard_manager.set_notebook(notebook);
|
||||
keyboard_manager.set_quickhelp(quick_help);
|
||||
var menubar = new menubar.MenuBar('#menubar', $.extend({
|
||||
menubar = new menubar.MenuBar('#menubar', $.extend({
|
||||
notebook: notebook,
|
||||
contents: contents,
|
||||
events: events,
|
||||
@ -149,7 +112,7 @@ require([
|
||||
events.off('notebook_loaded.Notebook', first_load);
|
||||
};
|
||||
events.on('notebook_loaded.Notebook', first_load);
|
||||
|
||||
|
||||
IPython.page = page;
|
||||
IPython.notebook = notebook;
|
||||
IPython.contents = contents;
|
||||
@ -163,9 +126,17 @@ require([
|
||||
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,14 +1,9 @@
|
||||
// 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
|
||||
@ -60,7 +55,7 @@ define([
|
||||
];
|
||||
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.
|
||||
@ -158,5 +153,4 @@ define([
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
return {'MainToolBar': MainToolBar};
|
||||
});
|
||||
exports.MainToolBar = MainToolBar;
|
@ -1,13 +1,10 @@
|
||||
// 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 init = function () {
|
||||
if (window.MathJax) {
|
||||
// MathJax loaded
|
||||
@ -202,11 +199,8 @@ define([
|
||||
return text;
|
||||
};
|
||||
|
||||
var mathjaxutils = {
|
||||
module.exports = {
|
||||
init : init,
|
||||
remove_math : remove_math,
|
||||
replace_math : replace_math
|
||||
};
|
||||
|
||||
return mathjaxutils;
|
||||
});
|
@ -1,17 +1,13 @@
|
||||
// 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
|
||||
@ -41,7 +37,7 @@ define([
|
||||
this.quick_help = options.quick_help;
|
||||
|
||||
try {
|
||||
this.tour = new tour.Tour(this.notebook, this.events);
|
||||
this.tour = new tour.NotebookTour(this.notebook, this.events);
|
||||
} catch (e) {
|
||||
this.tour = undefined;
|
||||
console.log("Failed to instantiate Notebook Tour", e);
|
||||
@ -365,7 +361,7 @@ define([
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
MenuBar.prototype.update_nbconvert_script = function(langinfo) {
|
||||
/**
|
||||
* Set the 'Download as foo' menu option for the relevant language.
|
||||
@ -418,5 +414,4 @@ define([
|
||||
|
||||
};
|
||||
|
||||
return {'MenuBar': MenuBar};
|
||||
});
|
||||
exports.MenuBar = MenuBar;
|
@ -4,10 +4,9 @@
|
||||
/**
|
||||
* @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');
|
||||
@ -17,9 +16,7 @@ define(function (require) {
|
||||
var configmod = require('services/config');
|
||||
var session = require('services/sessions/session');
|
||||
var celltoolbar = require('notebook/js/celltoolbar');
|
||||
var marked = require('components/marked/lib/marked');
|
||||
var CodeMirror = require('codemirror/lib/codemirror');
|
||||
var runMode = require('codemirror/addon/runmode/runmode');
|
||||
var marked = require('marked');
|
||||
var mathjaxutils = require('notebook/js/mathjaxutils');
|
||||
var keyboard = require('base/js/keyboard');
|
||||
var tooltip = require('notebook/js/tooltip');
|
||||
@ -319,7 +316,6 @@ define(function (require) {
|
||||
return;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Notebook.prototype.show_command_palette = function() {
|
||||
var x = new commandpalette.CommandPalette(this);
|
||||
@ -531,7 +527,7 @@ define(function (require) {
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the numeric index of a given cell.
|
||||
*
|
||||
@ -812,7 +808,7 @@ define(function (require) {
|
||||
cell.focus_editor();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Ensure either cell, or codemirror is focused. Is none
|
||||
* is focused, focus the cell.
|
||||
@ -1266,7 +1262,7 @@ define(function (require) {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Warn about heading cell support removal.
|
||||
*/
|
||||
@ -1286,7 +1282,7 @@ define(function (require) {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Turn a cell into a heading containing markdown cell.
|
||||
*
|
||||
@ -1700,7 +1696,7 @@ define(function (require) {
|
||||
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.
|
||||
@ -1780,7 +1776,7 @@ define(function (require) {
|
||||
this._session_starting = false;
|
||||
utils.log_ajax_error(jqxhr, status, error);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Prompt the user to restart the Jupyter kernel.
|
||||
*/
|
||||
@ -1811,7 +1807,7 @@ define(function (require) {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Execute or render cell outputs and go into command mode.
|
||||
*/
|
||||
@ -2062,7 +2058,7 @@ define(function (require) {
|
||||
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.
|
||||
@ -2145,7 +2141,7 @@ define(function (require) {
|
||||
return _save();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Success callback for saving a notebook.
|
||||
*
|
||||
@ -2186,7 +2182,7 @@ define(function (require) {
|
||||
this._checkpoint_after_save = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Update the autosave interval based on the duration of the last save.
|
||||
*
|
||||
@ -2274,7 +2270,7 @@ define(function (require) {
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Ensure a filename has the right extension
|
||||
* Returns the filename with the appropriate extension, appending if necessary.
|
||||
@ -2516,7 +2512,7 @@ define(function (require) {
|
||||
};
|
||||
|
||||
/********************* checkpoint-related ********************/
|
||||
|
||||
|
||||
/**
|
||||
* Save the notebook then immediately create a checkpoint.
|
||||
*/
|
||||
@ -2524,7 +2520,7 @@ define(function (require) {
|
||||
this._checkpoint_after_save = true;
|
||||
this.save_notebook();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Add a checkpoint for this notebook.
|
||||
*/
|
||||
@ -2543,7 +2539,7 @@ define(function (require) {
|
||||
}
|
||||
this.last_checkpoint = this.checkpoints[this.checkpoints.length - 1];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* List checkpoints for this notebook.
|
||||
*/
|
||||
@ -2640,7 +2636,7 @@ define(function (require) {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Restore the notebook to a checkpoint state.
|
||||
*
|
||||
@ -2656,7 +2652,7 @@ define(function (require) {
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Success callback for restoring a notebook to a checkpoint.
|
||||
*/
|
||||
@ -2680,7 +2676,7 @@ define(function (require) {
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Success callback for deleting a notebook checkpoint.
|
||||
*/
|
||||
@ -2689,5 +2685,4 @@ define(function (require) {
|
||||
this.load_notebook(this.notebook_path);
|
||||
};
|
||||
|
||||
return {'Notebook': Notebook};
|
||||
});
|
||||
exports.Notebook = Notebook;
|
@ -1,22 +1,23 @@
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
'base/js/dialog',
|
||||
'base/js/notificationarea',
|
||||
'moment'
|
||||
], function($, utils, dialog, notificationarea, moment) {
|
||||
// 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 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.
|
||||
*
|
||||
@ -339,5 +340,4 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
return {'NotebookNotificationArea': NotebookNotificationArea};
|
||||
});
|
||||
exports.NotebookNotificationArea = NotebookNotificationArea;
|
@ -1,16 +1,13 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
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";
|
||||
|
||||
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');
|
||||
|
||||
/**
|
||||
* @class OutputArea
|
||||
*
|
||||
@ -232,8 +229,8 @@ define([
|
||||
}
|
||||
this.append_output(json);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
OutputArea.output_types = [
|
||||
'application/javascript',
|
||||
'text/html',
|
||||
@ -268,7 +265,7 @@ define([
|
||||
});
|
||||
return bundle;
|
||||
};
|
||||
|
||||
|
||||
OutputArea.prototype.append_output = function (json) {
|
||||
this.expand();
|
||||
|
||||
@ -401,7 +398,7 @@ define([
|
||||
.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
|
||||
@ -548,7 +545,7 @@ define([
|
||||
'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];
|
||||
@ -685,7 +682,7 @@ define([
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
var set_width_height = function (img, md, mime) {
|
||||
/**
|
||||
* set width and height of an img element from metadata
|
||||
@ -698,7 +695,7 @@ define([
|
||||
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);
|
||||
@ -961,5 +958,4 @@ define([
|
||||
"application/pdf" : append_pdf
|
||||
};
|
||||
|
||||
return {'OutputArea': OutputArea};
|
||||
});
|
||||
exports.OutputArea = OutputArea;
|
@ -1,12 +1,9 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jqueryui',
|
||||
'base/js/utils',
|
||||
], function($, utils) {
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
|
||||
var Pager = function (pager_selector, options) {
|
||||
/**
|
||||
* Constructor
|
||||
@ -166,5 +163,4 @@ define([
|
||||
$('.end_space').css('height', Math.max(this.pager_element.height(), this._default_end_space));
|
||||
};
|
||||
|
||||
return {'Pager': Pager};
|
||||
});
|
||||
exports.Pager = Pager;
|
@ -1,12 +1,10 @@
|
||||
// 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) {
|
||||
@ -64,7 +62,7 @@ define([
|
||||
{ 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
|
||||
@ -114,7 +112,7 @@ define([
|
||||
'space':'Space',
|
||||
'backspace':'Backspace',
|
||||
};
|
||||
|
||||
|
||||
var humanize_map;
|
||||
|
||||
if (platform === 'MacOS'){
|
||||
@ -286,8 +284,7 @@ define([
|
||||
return div;
|
||||
};
|
||||
|
||||
return {'QuickHelp': QuickHelp,
|
||||
module.exports = {'QuickHelp': QuickHelp,
|
||||
humanize_shortcut: humanize_shortcut,
|
||||
humanize_sequence: humanize_sequence
|
||||
};
|
||||
});
|
@ -1,15 +1,12 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
'base/js/dialog',
|
||||
'base/js/keyboard',
|
||||
'moment',
|
||||
], function($, utils, dialog, keyboard, moment) {
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
var dialog = require('base/js/dialog');
|
||||
var keyboard = require('base/js/keyboard');
|
||||
var moment = require('moment');
|
||||
|
||||
var SaveWidget = function (selector, options) {
|
||||
/**
|
||||
* TODO: Remove circular ref.
|
||||
@ -162,7 +159,7 @@ define([
|
||||
}
|
||||
this._render_checkpoint();
|
||||
};
|
||||
|
||||
|
||||
SaveWidget.prototype._render_checkpoint = function () {
|
||||
/** actually set the text in the element, from our _checkpoint value
|
||||
|
||||
@ -189,7 +186,7 @@ define([
|
||||
el.text('Last Checkpoint: ' + human_date).attr('title', long_date);
|
||||
};
|
||||
|
||||
|
||||
|
||||
SaveWidget.prototype._schedule_render_checkpoint = function () {
|
||||
/** schedule the next update to relative date
|
||||
|
||||
@ -216,6 +213,4 @@ define([
|
||||
}
|
||||
};
|
||||
|
||||
return {'SaveWidget': SaveWidget};
|
||||
|
||||
});
|
||||
exports.SaveWidget = SaveWidget;
|
@ -1,6 +1,5 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
define(['jquery'], function($){
|
||||
"use strict";
|
||||
|
||||
var ScrollManager = function(notebook, options) {
|
||||
@ -205,10 +204,9 @@ define(['jquery'], function($){
|
||||
};
|
||||
|
||||
// Return naemspace for require.js loads
|
||||
return {
|
||||
module.exports = {
|
||||
'ScrollManager': ScrollManager,
|
||||
'SlideScrollManager': SlideScrollManager,
|
||||
'HeadingScrollManager': HeadingScrollManager,
|
||||
'TargetScrollManager': TargetScrollManager
|
||||
};
|
||||
});
|
@ -1,4 +1,3 @@
|
||||
define(function(require){
|
||||
"use strict";
|
||||
|
||||
var dialog = require('base/js/dialog');
|
||||
@ -382,5 +381,4 @@ define(function(require){
|
||||
};
|
||||
|
||||
|
||||
return {load:load};
|
||||
});
|
||||
exports.load = load;
|
@ -1,32 +1,15 @@
|
||||
// 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) {
|
||||
@ -116,7 +99,7 @@ define([
|
||||
|
||||
|
||||
// Cell level actions
|
||||
|
||||
|
||||
TextCell.prototype.select = function () {
|
||||
var cont = Cell.prototype.select.apply(this);
|
||||
if (cont) {
|
||||
@ -325,7 +308,7 @@ define([
|
||||
"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/]}
|
||||
@ -359,10 +342,8 @@ define([
|
||||
return cont;
|
||||
};
|
||||
|
||||
var textcell = {
|
||||
module.exports = {
|
||||
TextCell: TextCell,
|
||||
MarkdownCell: MarkdownCell,
|
||||
RawCell: RawCell
|
||||
};
|
||||
return textcell;
|
||||
});
|
@ -1,9 +1,6 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery'
|
||||
], function($) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
@ -132,5 +129,4 @@ define([
|
||||
this.element.toggle();
|
||||
};
|
||||
|
||||
return {'ToolBar': ToolBar};
|
||||
});
|
||||
exports.ToolBar = ToolBar;
|
@ -1,12 +1,9 @@
|
||||
// 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');
|
||||
|
||||
// tooltip constructor
|
||||
var Tooltip = function (events) {
|
||||
var that = this;
|
||||
@ -318,5 +315,4 @@ define([
|
||||
this.text.scrollTop(0);
|
||||
};
|
||||
|
||||
return {'Tooltip': Tooltip};
|
||||
});
|
||||
exports.Tooltip = Tooltip;
|
@ -1,10 +1,5 @@
|
||||
// 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" +
|
||||
@ -116,23 +111,24 @@ define([
|
||||
}
|
||||
];
|
||||
|
||||
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
|
||||
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
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
NotebookTour.prototype.start = function () {
|
||||
@ -148,17 +144,15 @@ define([
|
||||
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();
|
||||
};
|
||||
|
||||
return {'Tour': NotebookTour};
|
||||
|
||||
});
|
||||
|
||||
exports.NotebookTour = NotebookTour;
|
||||
|
@ -1,12 +1,9 @@
|
||||
// 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;
|
||||
@ -27,14 +24,14 @@ function($, utils) {
|
||||
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(), {
|
||||
@ -47,7 +44,7 @@ function($, utils) {
|
||||
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
|
||||
@ -69,14 +66,14 @@ function($, utils) {
|
||||
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] || {};
|
||||
@ -84,7 +81,7 @@ function($, utils) {
|
||||
return this.section.data
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Wait for config to have loaded, then get a value or the default.
|
||||
* Returns a promise.
|
||||
@ -95,7 +92,7 @@ function($, utils) {
|
||||
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.
|
||||
@ -103,7 +100,7 @@ function($, utils) {
|
||||
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.
|
||||
@ -121,9 +118,8 @@ function($, utils) {
|
||||
return this.section.update(d);
|
||||
}
|
||||
};
|
||||
|
||||
return {ConfigSection: ConfigSection,
|
||||
ConfigWithDefaults: ConfigWithDefaults,
|
||||
};
|
||||
|
||||
});
|
||||
module.exports = {
|
||||
ConfigSection: ConfigSection,
|
||||
ConfigWithDefaults: ConfigWithDefaults,
|
||||
};
|
@ -1,10 +1,7 @@
|
||||
// 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) {
|
||||
@ -36,7 +33,7 @@ define(function(require) {
|
||||
// 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;
|
||||
@ -173,7 +170,7 @@ define(function(require) {
|
||||
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
|
||||
@ -252,5 +249,6 @@ define(function(require) {
|
||||
return this.get(path, {type: 'directory'});
|
||||
};
|
||||
|
||||
return {'Contents': Contents};
|
||||
});
|
||||
exports.Contents = Contents;
|
||||
define([], function() { return {Contents: Contents}; });
|
||||
|
@ -1,16 +1,14 @@
|
||||
// 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 = {};
|
||||
@ -18,7 +16,7 @@ define([
|
||||
this.init_kernel(kernel);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
CommManager.prototype.init_kernel = function (kernel) {
|
||||
/**
|
||||
* connect the kernel, and register message handlers
|
||||
@ -30,7 +28,7 @@ define([
|
||||
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
|
||||
@ -43,21 +41,21 @@ define([
|
||||
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
|
||||
@ -66,16 +64,16 @@ define([
|
||||
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;
|
||||
@ -100,7 +98,7 @@ define([
|
||||
}, 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) {
|
||||
@ -120,7 +118,7 @@ define([
|
||||
});
|
||||
return this.comms[content.comm_id];
|
||||
};
|
||||
|
||||
|
||||
CommManager.prototype.comm_msg = function(msg) {
|
||||
var content = msg.content;
|
||||
if (this.comms[content.comm_id] === undefined) {
|
||||
@ -138,17 +136,17 @@ define([
|
||||
});
|
||||
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 = {
|
||||
@ -158,7 +156,7 @@ define([
|
||||
};
|
||||
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,
|
||||
@ -166,7 +164,7 @@ define([
|
||||
};
|
||||
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,
|
||||
@ -174,22 +172,22 @@ define([
|
||||
};
|
||||
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) {
|
||||
@ -200,17 +198,16 @@ define([
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Comm.prototype.handle_msg = function (msg) {
|
||||
this._callback('msg', msg);
|
||||
};
|
||||
|
||||
|
||||
Comm.prototype.handle_close = function (msg) {
|
||||
this._callback('close', msg);
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
module.exports = {
|
||||
'CommManager': CommManager,
|
||||
'Comm': Comm
|
||||
};
|
||||
});
|
@ -1,15 +1,12 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
'./comm',
|
||||
'./serialize',
|
||||
'base/js/events'
|
||||
], function($, utils, comm, serialize, events) {
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
var comm = require('./comm');
|
||||
var serialize = require('./serialize');
|
||||
var events = require('base/js/events');
|
||||
|
||||
/**
|
||||
* A Kernel class to communicate with the Python kernel. This
|
||||
* should generally not be constructed directly, but be created
|
||||
@ -527,7 +524,7 @@ define([
|
||||
}
|
||||
this._schedule_reconnect();
|
||||
};
|
||||
|
||||
|
||||
Kernel.prototype._schedule_reconnect = function () {
|
||||
/**
|
||||
* function to call when kernel connection is lost
|
||||
@ -545,7 +542,7 @@ define([
|
||||
console.log("Failed to reconnect, giving up.");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Kernel.prototype.stop_channels = function () {
|
||||
/**
|
||||
* Close the websocket. After successful close, the value
|
||||
@ -599,7 +596,7 @@ define([
|
||||
*/
|
||||
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
|
||||
@ -806,7 +803,7 @@ define([
|
||||
delete this._msg_callbacks[msg_id];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @function _finish_shell
|
||||
*/
|
||||
@ -832,7 +829,7 @@ define([
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set callbacks for a particular message.
|
||||
* Callbacks should be a struct of the following form:
|
||||
@ -856,7 +853,7 @@ define([
|
||||
this.last_msg_callbacks = {};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Kernel.prototype._handle_ws_message = function (e) {
|
||||
var that = this;
|
||||
this._msg_queue = this._msg_queue.then(function() {
|
||||
@ -880,7 +877,7 @@ define([
|
||||
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;
|
||||
@ -977,7 +974,7 @@ define([
|
||||
this._kernel_dead();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Handle clear_output message
|
||||
*
|
||||
@ -1060,5 +1057,4 @@ define([
|
||||
}
|
||||
};
|
||||
|
||||
return {'Kernel': Kernel};
|
||||
});
|
||||
exports.Kernel = Kernel;
|
@ -1,11 +1,7 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'underscore',
|
||||
], function (_) {
|
||||
"use strict";
|
||||
|
||||
|
||||
var _deserialize_array_buffer = function (buf) {
|
||||
var data = new DataView(buf);
|
||||
// read the header: 1 + nbufs 32b integers
|
||||
@ -29,7 +25,7 @@ define([
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
var _deserialize_binary = function(data) {
|
||||
/**
|
||||
* deserialize the binary message format
|
||||
@ -66,7 +62,7 @@ define([
|
||||
return Promise.resolve(_deserialize_binary(data));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var _serialize_binary = function (msg) {
|
||||
/**
|
||||
* implement the binary serialization protocol
|
||||
@ -109,7 +105,7 @@ define([
|
||||
// return raw ArrayBuffer
|
||||
return msg_buf.buffer;
|
||||
};
|
||||
|
||||
|
||||
var serialize = function (msg) {
|
||||
if (msg.buffers && msg.buffers.length) {
|
||||
return _serialize_binary(msg);
|
||||
@ -117,10 +113,8 @@ define([
|
||||
return JSON.stringify(msg);
|
||||
}
|
||||
};
|
||||
|
||||
var exports = {
|
||||
|
||||
module.exports = {
|
||||
deserialize : deserialize,
|
||||
serialize: serialize
|
||||
};
|
||||
return exports;
|
||||
});
|
@ -1,13 +1,10 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
'services/kernels/kernel',
|
||||
], function($, utils, kernel) {
|
||||
"use strict";
|
||||
|
||||
var utils = require('base/js/utils');
|
||||
var kernel = require('services/kernels/kernel');
|
||||
|
||||
/**
|
||||
* Session object for accessing the session REST api. The session
|
||||
* should be used to start kernels and then shut them down -- for
|
||||
@ -311,11 +308,10 @@ define([
|
||||
this.name = "SessionAlreadyStarting";
|
||||
this.message = (message || "");
|
||||
};
|
||||
|
||||
|
||||
SessionAlreadyStarting.prototype = Error.prototype;
|
||||
|
||||
return {
|
||||
|
||||
module.exports = {
|
||||
Session: Session,
|
||||
SessionAlreadyStarting: SessionAlreadyStarting
|
||||
};
|
||||
});
|
@ -1,23 +1,14 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
require([
|
||||
'jquery',
|
||||
'termjs',
|
||||
'base/js/utils',
|
||||
'base/js/page',
|
||||
'services/config',
|
||||
'terminal/js/terminado',
|
||||
'custom/custom',
|
||||
], function(
|
||||
$,
|
||||
termjs,
|
||||
utils,
|
||||
page,
|
||||
configmod,
|
||||
terminado
|
||||
){
|
||||
"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() {
|
||||
|
||||
page = new page.Page();
|
||||
|
||||
var common_config = new configmod.ConfigSection('common',
|
||||
@ -33,7 +24,7 @@ require([
|
||||
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;
|
||||
@ -43,16 +34,16 @@ require([
|
||||
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);
|
||||
@ -62,5 +53,8 @@ require([
|
||||
|
||||
// Expose terminal for fiddling with in the browser
|
||||
window.terminal = terminal;
|
||||
});
|
||||
|
||||
}).catch(function(err) {
|
||||
console.error('Could not load globals', err);
|
||||
});
|
@ -1,9 +1,12 @@
|
||||
define ([], function() {
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
function make_terminal(element, size, ws_url) {
|
||||
var termjs = require('termjs');
|
||||
|
||||
exports.make_terminal = function(element, size, ws_url) {
|
||||
var ws = new WebSocket(ws_url);
|
||||
Terminal.brokenBold = true;
|
||||
var term = new Terminal({
|
||||
termjs.Terminal.brokenBold = true;
|
||||
var term = new termjs.Terminal({
|
||||
cols: size.cols,
|
||||
rows: size.rows,
|
||||
screenKeys: false,
|
||||
@ -36,6 +39,3 @@ define ([], function() {
|
||||
};
|
||||
return {socket: ws, term: term};
|
||||
}
|
||||
|
||||
return {make_terminal: make_terminal};
|
||||
});
|
@ -1,13 +1,10 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'base/js/namespace',
|
||||
'jquery',
|
||||
'tree/js/notebooklist',
|
||||
], function(IPython, $, notebooklist) {
|
||||
"use strict";
|
||||
|
||||
var IPython = require('base/js/namespace');
|
||||
var notebooklist = require('tree/js/notebooklist');
|
||||
|
||||
var KernelList = function (selector, options) {
|
||||
/**
|
||||
* Constructor
|
||||
@ -32,7 +29,7 @@ define([
|
||||
* do nothing
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
KernelList.prototype.sessions_loaded = function (d) {
|
||||
this.sessions = d;
|
||||
this.clear_list();
|
||||
@ -68,9 +65,8 @@ define([
|
||||
})
|
||||
.appendTo(running_indicator);
|
||||
};
|
||||
|
||||
|
||||
// Backwards compatability.
|
||||
IPython.KernelList = KernelList;
|
||||
|
||||
return {'KernelList': KernelList};
|
||||
});
|
||||
exports.KernelList = KernelList;
|
@ -1,46 +1,27 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
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";
|
||||
|
||||
// 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) {
|
||||
|
||||
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"),
|
||||
@ -65,7 +46,7 @@ require([
|
||||
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);
|
||||
@ -148,12 +129,12 @@ require([
|
||||
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
|
||||
@ -169,9 +150,12 @@ require([
|
||||
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,14 +1,11 @@
|
||||
// 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;
|
||||
@ -22,20 +19,20 @@ define([
|
||||
}
|
||||
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;
|
||||
@ -70,7 +67,7 @@ define([
|
||||
menu.after(li);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
NewNotebookWidget.prototype.new_notebook = function (kernel_name) {
|
||||
/** create and open a new notebook */
|
||||
var that = this;
|
||||
@ -100,6 +97,5 @@ define([
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return {'NewNotebookWidget': NewNotebookWidget};
|
||||
});
|
||||
|
||||
exports.NewNotebookWidget = NewNotebookWidget;
|
@ -1,16 +1,13 @@
|
||||
// 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
|
||||
@ -883,5 +880,4 @@ define([
|
||||
.append(cancel_button);
|
||||
};
|
||||
|
||||
return {'NotebookList': NotebookList};
|
||||
});
|
||||
exports.NotebookList = NotebookList;
|
@ -1,12 +1,9 @@
|
||||
// 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 SesssionList = function (options) {
|
||||
/**
|
||||
* Constructor
|
||||
@ -51,7 +48,7 @@ define([
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
SesssionList.prototype.load_sessions = function(){
|
||||
var that = this;
|
||||
var settings = {
|
||||
@ -77,5 +74,4 @@ define([
|
||||
this.events.trigger('sessions_loaded.Dashboard', this.sessions);
|
||||
};
|
||||
|
||||
return {'SesssionList': SesssionList};
|
||||
});
|
||||
exports.SesssionList = SesssionList;
|
@ -1,14 +1,11 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define([
|
||||
'base/js/namespace',
|
||||
'base/js/utils',
|
||||
'jquery',
|
||||
'tree/js/notebooklist',
|
||||
], function(IPython, utils, $, notebooklist) {
|
||||
"use strict";
|
||||
|
||||
var IPython = require('base/js/namespace');
|
||||
var utils = require('base/js/utils');
|
||||
var notebooklist = require('tree/js/notebooklist');
|
||||
|
||||
var TerminalList = function (selector, options) {
|
||||
/**
|
||||
* Constructor
|
||||
@ -62,7 +59,7 @@ define([
|
||||
);
|
||||
$.ajax(url, settings);
|
||||
};
|
||||
|
||||
|
||||
TerminalList.prototype.load_terminals = function() {
|
||||
var url = utils.url_join_encode(this.base_url, 'api/terminals');
|
||||
$.ajax(url, {
|
||||
@ -86,7 +83,7 @@ define([
|
||||
}
|
||||
$('#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);
|
||||
@ -96,7 +93,7 @@ define([
|
||||
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").
|
||||
@ -117,5 +114,4 @@ define([
|
||||
item.find(".item_buttons").text("").append(shutdown_button);
|
||||
};
|
||||
|
||||
return {TerminalList: TerminalList};
|
||||
});
|
||||
exports.TerminalList = TerminalList;
|
@ -1,14 +0,0 @@
|
||||
// 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,9 +0,0 @@
|
||||
// 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,82 +0,0 @@
|
||||
// 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
|
@ -95,5 +95,5 @@ data-file-path="{{file_path}}"
|
||||
|
||||
{{super()}}
|
||||
|
||||
<script src="{{ static_url("edit/js/main.min.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{ static_url("edit/js/main.bundle.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
{% endblock %}
|
||||
|
@ -328,10 +328,6 @@ data-notebook-path="{{notebook_path}}"
|
||||
|
||||
<script src="{{ static_url("components/text-encoding/lib/encoding.js") }}" charset="utf-8"></script>
|
||||
|
||||
{% if ignore_minified_js %}
|
||||
<script src="{{ static_url("notebook/js/main.js") }}" charset="utf-8"></script>
|
||||
{% else %}
|
||||
<script src="{{ static_url("notebook/js/main.min.js") }}" charset="utf-8"></script>
|
||||
{% endif %}
|
||||
<script src="{{ static_url("notebook/js/main.bundle.js") }}" charset="utf-8"></script>
|
||||
|
||||
{% endblock %}
|
||||
|
@ -38,13 +38,10 @@
|
||||
moment: 'components/moment/moment',
|
||||
codemirror: 'components/codemirror',
|
||||
termjs: 'components/term.js/src/term',
|
||||
typeahead: 'components/jquery-typeahead/dist/jquery.typeahead'
|
||||
marked: 'components/marked/marked.min',
|
||||
caja: 'components/google-caja/html-css-sanitizer-minified'
|
||||
},
|
||||
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.min.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{ static_url("terminal/js/main.bundle.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.min.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{ static_url("tree/js/main.bundle.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() { window.a = true; });
|
||||
define('nbextensions/c', [], function() { window.c = true; });
|
||||
define('nbextensions/a', [], function() { return {load_ipython_extension: function() {window.a = true;}}; });
|
||||
define('nbextensions/c', [], function() { return {load_ipython_extension: function() {window.c = true;}}; });
|
||||
require(['base/js/utils'], function(utils) {
|
||||
utils.load_extensions('a', 'b', 'c');
|
||||
});
|
||||
@ -33,7 +33,12 @@ casper.notebook_test(function () {
|
||||
});
|
||||
|
||||
this.waitFor(function() {
|
||||
return this.evaluate(function() { return window.a; });
|
||||
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");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -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';
|
||||
return IPython._status == 'idle' || IPython._status === undefined;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
33
package.json
33
package.json
@ -9,12 +9,39 @@
|
||||
"url": "https://github.com/jupyter/notebook.git"
|
||||
},
|
||||
"scripts": {
|
||||
"bower": "bower install",
|
||||
"build": "python setup.py js css"
|
||||
"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"
|
||||
},
|
||||
"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",
|
||||
"requirejs": "^2.1.17"
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
4
setup.py
4
setup.py
@ -55,7 +55,7 @@ from setupbase import (
|
||||
check_package_data_first,
|
||||
CompileCSS,
|
||||
CompileJS,
|
||||
Bower,
|
||||
JSDeps,
|
||||
JavascriptVersion,
|
||||
css_js_prerelease,
|
||||
)
|
||||
@ -111,7 +111,7 @@ setup_args['cmdclass'] = {
|
||||
'sdist' : css_js_prerelease(sdist, strict=True),
|
||||
'css' : CompileCSS,
|
||||
'js' : CompileJS,
|
||||
'jsdeps' : Bower,
|
||||
'jsdeps' : JSDeps,
|
||||
'jsversion' : JavascriptVersion,
|
||||
}
|
||||
|
||||
|
202
setupbase.py
202
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.min.js'))
|
||||
static_data.append(pjoin('static', app, 'js', 'main.bundle.js'))
|
||||
static_data.append(pjoin('static', 'services', 'contents.bundle.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,13 +130,10 @@ 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, "moment", "min", "moment.min.js"),
|
||||
pjoin(components, "term.js", "src", "term.js"),
|
||||
pjoin(components, "text-encoding", "lib", "encoding.js"),
|
||||
pjoin(components, "marked", "marked.min.js"),
|
||||
])
|
||||
|
||||
# Ship all of Codemirror's CSS and JS
|
||||
@ -300,61 +297,28 @@ def run(cmd, *args, **kwargs):
|
||||
return check_call(cmd, *args, **kwargs)
|
||||
|
||||
|
||||
class Bower(Command):
|
||||
class JSDeps(Command):
|
||||
description = "fetch static client-side components with bower"
|
||||
|
||||
user_options = [
|
||||
('force', 'f', "force fetching of bower dependencies"),
|
||||
]
|
||||
|
||||
def initialize_options(self):
|
||||
self.force = False
|
||||
|
||||
def finalize_options(self):
|
||||
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'))
|
||||
user_options = []
|
||||
|
||||
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 initialize_options(self):
|
||||
pass
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
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(
|
||||
['bower', 'install', '--allow-root', '--config.interactive=false'],
|
||||
['npm', 'install'],
|
||||
cwd=repo_root,
|
||||
env=env
|
||||
)
|
||||
except OSError as e:
|
||||
print("Failed to run bower: %s" % e, file=sys.stderr)
|
||||
print("You can install js dependencies with `npm install`", file=sys.stderr)
|
||||
print("Failed to run `npm install`: %s" % e, file=sys.stderr)
|
||||
raise
|
||||
os.utime(self.bower_dir, None)
|
||||
# update package data in case this created new files
|
||||
update_package_data(self.distribution)
|
||||
|
||||
@ -374,103 +338,51 @@ 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
|
||||
|
||||
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
|
||||
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
|
||||
# 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 = [
|
||||
('force', 'f', "force rebuilding js targets"),
|
||||
]
|
||||
|
||||
user_options = []
|
||||
|
||||
def initialize_options(self):
|
||||
self.force = False
|
||||
pass
|
||||
|
||||
def finalize_options(self):
|
||||
self.force = bool(self.force)
|
||||
|
||||
apps = ['notebook', 'tree', 'edit', 'terminal', 'auth']
|
||||
targets = [ pjoin(static, app, 'js', 'main.min.js') for app in apps ]
|
||||
pass
|
||||
|
||||
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
|
||||
pool = ThreadPool()
|
||||
pool.map(self.build_main, self.apps)
|
||||
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
|
||||
# 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"
|
||||
@ -483,7 +395,7 @@ class JavascriptVersion(Command):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
nsfile = pjoin(repo_root, "notebook", "static", "base", "js", "namespace.js")
|
||||
nsfile = pjoin(repo_root, "notebook", "static-src", "base", "js", "namespace.js")
|
||||
with open(nsfile) as f:
|
||||
lines = f.readlines()
|
||||
with open(nsfile, 'w') as f:
|
||||
@ -502,45 +414,11 @@ 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('css')
|
||||
self.distribution.run_command('js')
|
||||
self.distribution.run_command('jsdeps')
|
||||
except Exception as 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)
|
||||
|
||||
log.warn("rebuilding js and css failed.")
|
||||
raise e
|
||||
|
||||
command.run(self)
|
||||
return DecoratedCommand
|
||||
|
Loading…
Reference in New Issue
Block a user