mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-09 03:50:45 +08:00
Fix tests
This commit is contained in:
parent
7df0a118c7
commit
55dd626980
@ -11,10 +11,10 @@
|
||||
"bootstrap-tour": "0.9.0",
|
||||
"jquery": "components/jquery#~2.0",
|
||||
"jquery-ui": "components/jqueryui#~1.10",
|
||||
"codemirror": "~5.5",
|
||||
|
||||
"term.js": "chjj/term.js#~0.0.4",
|
||||
"backbone": "components/backbone#~1.2",
|
||||
"codemirror": "~5.5",
|
||||
"marked": "~0.3",
|
||||
"moment": "~2.8.4",
|
||||
"text-encoding": "~0.1",
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
var CodeMirror = require('codemirror/lib/codemirror');
|
||||
var $ = require('jquery');
|
||||
|
||||
/**
|
||||
@ -163,40 +162,43 @@
|
||||
.append(textarea)
|
||||
)
|
||||
);
|
||||
var editor = CodeMirror.fromTextArea(textarea[0], {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
indentUnit: 2,
|
||||
autoIndent: true,
|
||||
mode: 'application/json',
|
||||
});
|
||||
var modal_obj = modal({
|
||||
title: "Edit " + options.name + " Metadata",
|
||||
body: dialogform,
|
||||
buttons: {
|
||||
OK: { class : "btn-primary",
|
||||
click: function() {
|
||||
/**
|
||||
* validate json and set it
|
||||
*/
|
||||
var new_md;
|
||||
try {
|
||||
new_md = JSON.parse(editor.getValue());
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
error_div.text('WARNING: Could not save invalid JSON.');
|
||||
return false;
|
||||
requirejs(['codemirror/lib/codemirror'], function(CodeMirror) {
|
||||
var editor = CodeMirror.fromTextArea(textarea[0], {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
indentUnit: 2,
|
||||
autoIndent: true,
|
||||
mode: 'application/json',
|
||||
});
|
||||
var modal_obj = modal({
|
||||
title: "Edit " + options.name + " Metadata",
|
||||
body: dialogform,
|
||||
buttons: {
|
||||
OK: { class : "btn-primary",
|
||||
click: function() {
|
||||
/**
|
||||
* validate json and set it
|
||||
*/
|
||||
var new_md;
|
||||
try {
|
||||
new_md = JSON.parse(editor.getValue());
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
error_div.text('WARNING: Could not save invalid JSON.');
|
||||
return false;
|
||||
}
|
||||
options.callback(new_md);
|
||||
}
|
||||
options.callback(new_md);
|
||||
}
|
||||
},
|
||||
Cancel: {}
|
||||
},
|
||||
Cancel: {}
|
||||
},
|
||||
notebook: options.notebook,
|
||||
keyboard_manager: options.keyboard_manager,
|
||||
});
|
||||
notebook: options.notebook,
|
||||
keyboard_manager: options.keyboard_manager,
|
||||
});
|
||||
|
||||
modal_obj.on('shown.bs.modal', function(){ editor.refresh(); });
|
||||
modal_obj.on('shown.bs.modal', function(){ editor.refresh(); });
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
@ -9,16 +9,29 @@
|
||||
// events.on("event.Namespace", function () { do_stuff(); });
|
||||
// });
|
||||
"use strict";
|
||||
|
||||
var IPython = require('base/js/namespace');
|
||||
var $ = require('jquery');
|
||||
|
||||
var Events = function () {};
|
||||
|
||||
var events = new Events();
|
||||
var $events;
|
||||
if (window && window.IPython && window.IPython.$events) {
|
||||
$events = window.IPython.$events;
|
||||
} else if (global && global.IPython && global.IPython.$events) {
|
||||
$events = global.IPython.$events;
|
||||
} else {
|
||||
var $ = require('jquery');
|
||||
$events = $([new Events()]);
|
||||
}
|
||||
var events = $events[0];
|
||||
|
||||
// Backwards compatability.
|
||||
IPython.Events = Events;
|
||||
IPython.events = events;
|
||||
if (window && window.IPython) {
|
||||
window.IPython.events = events;
|
||||
window.IPython.$events = $events;
|
||||
window.IPython.Events = Events;
|
||||
} else if (global && global.IPython) {
|
||||
global.IPython.events = events;
|
||||
global.IPython.$events = $events;
|
||||
global.IPython.Events = Events;
|
||||
}
|
||||
|
||||
module.exports = $([events]);
|
||||
module.exports = $events;
|
||||
|
@ -2,8 +2,15 @@
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
"use strict";
|
||||
|
||||
var Jupyter = window.Jupyter || {};
|
||||
var Jupyter;
|
||||
if (window && window.Jupyter) {
|
||||
Jupyter = window.Jupyter;
|
||||
} else if (global && global.Jupyter) {
|
||||
Jupyter = global.Jupyter;
|
||||
} else {
|
||||
Jupyter = {};
|
||||
}
|
||||
|
||||
var jprop = function(name, loaded, module_path, global) {
|
||||
if (!Jupyter.hasOwnProperty(name)) {
|
||||
Object.defineProperty(Jupyter, name, {
|
||||
@ -16,19 +23,7 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var jprop_deferred = function(name, module_path, global) {
|
||||
if (!Jupyter.hasOwnProperty(name)) {
|
||||
Jupyter[name] = null;
|
||||
requirejs([module_path], function(loaded) {
|
||||
jprop(name, loaded, module_path, global);
|
||||
}, function(err) {
|
||||
console.warn('Jupyter.' + name + ' unavailable because "' + module_path + '" was not loaded.', err);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// expose modules
|
||||
|
||||
jprop('utils', require('base/js/utils'), 'base/js/utils');
|
||||
@ -75,9 +70,10 @@
|
||||
|
||||
Jupyter.version = "4.1.0.dev";
|
||||
Jupyter._target = '_blank';
|
||||
|
||||
|
||||
module.exports = Jupyter;
|
||||
window.Jupyter = Jupyter;
|
||||
if (window) window.Jupyter = Jupyter;
|
||||
if (global) global.Jupyter = Jupyter;
|
||||
|
||||
// deprecated since 4.0, remove in 5+
|
||||
window.IPython = Jupyter;
|
||||
if (window) window.IPython = Jupyter;
|
@ -4,9 +4,7 @@
|
||||
"use strict";
|
||||
|
||||
var $ = require('jquery');
|
||||
var CodeMirror = require('codemirror/lib/codemirror');
|
||||
var moment = require('moment');
|
||||
require('codemirror/mode/meta');
|
||||
|
||||
/**
|
||||
* Load a single extension.
|
||||
@ -624,30 +622,33 @@
|
||||
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
|
||||
callback(mode.name ? mode : modename);
|
||||
return;
|
||||
}
|
||||
|
||||
requirejs(['codemirror/lib/codemirror', 'codemirror/mode/meta'], function(CodeMirror) {
|
||||
// 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
|
||||
callback(mode.name ? mode : modename);
|
||||
return;
|
||||
}
|
||||
|
||||
// *somehow* get back a CM.modeInfo-like object that has .mode and
|
||||
// .mime
|
||||
var info = (mode && mode.mode && mode.mime && mode) ||
|
||||
CodeMirror.findModeByName(modename) ||
|
||||
CodeMirror.findModeByExtension(modename.split(".").slice(-1)) ||
|
||||
CodeMirror.findModeByMIME(modename) ||
|
||||
{mode: modename, mime: modename};
|
||||
// *somehow* get back a CM.modeInfo-like object that has .mode and
|
||||
// .mime
|
||||
var info = (mode && mode.mode && mode.mime && mode) ||
|
||||
CodeMirror.findModeByName(modename) ||
|
||||
CodeMirror.findModeByExtension(modename.split(".").slice(-1)) ||
|
||||
CodeMirror.findModeByMIME(modename) ||
|
||||
{mode: modename, mime: modename};
|
||||
|
||||
require([
|
||||
// might want to use CodeMirror.modeURL here
|
||||
['codemirror/mode', info.mode, info.mode].join('/'),
|
||||
], function() {
|
||||
// return the original mode, as from a kernelspec on first load
|
||||
// or the mimetype, as for most highlighting
|
||||
callback(mode.name ? mode : info.mime);
|
||||
}, errback
|
||||
);
|
||||
requirejs([
|
||||
// might want to use CodeMirror.modeURL here
|
||||
['codemirror/mode', info.mode, info.mode].join('/'),
|
||||
], function() {
|
||||
// return the original mode, as from a kernelspec on first load
|
||||
// or the mimetype, as for most highlighting
|
||||
callback(mode.name ? mode : info.mime);
|
||||
}, errback
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
/** Error type for wrapped XHR errors. */
|
||||
@ -726,7 +727,7 @@
|
||||
|
||||
// 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 {
|
||||
|
@ -2,10 +2,6 @@
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
"use strict";
|
||||
|
||||
// Contents must be loaded at runtime.
|
||||
// jQuery must also be loaded at runtime and available globally
|
||||
// in order for bootstrap to work...
|
||||
requirejs(['contents', 'bootstrap'], function(contents_service) {
|
||||
var $ = require('jquery');
|
||||
var IPython = require('base/js/namespace');
|
||||
var utils = require('base/js/utils');
|
||||
@ -16,7 +12,11 @@ requirejs(['contents', 'bootstrap'], function(contents_service) {
|
||||
var menubar = require('edit/js/menubar');
|
||||
var savewidget = require('edit/js/savewidget');
|
||||
var notificationarea = require('edit/js/notificationarea');
|
||||
requirejs(['custom/custom'], function() {});
|
||||
|
||||
// Contents must be loaded at runtime.
|
||||
// jQuery must also be loaded at runtime and available globally
|
||||
// in order for bootstrap to work...
|
||||
requirejs(['contents', 'bootstrap', 'custom/custom'], function(contents_service) {
|
||||
|
||||
page = new page.Page();
|
||||
|
||||
|
@ -143,7 +143,7 @@
|
||||
|
||||
// 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();
|
||||
|
@ -3,19 +3,30 @@
|
||||
// Miscellaneous javascript tests
|
||||
//
|
||||
casper.notebook_test(function () {
|
||||
console.log('b');
|
||||
var jsver = this.evaluate(function () {
|
||||
console.log('a');
|
||||
var cell = IPython.notebook.get_cell(0);
|
||||
console.log('a2');
|
||||
cell.set_text('import notebook; print(notebook.__version__)');
|
||||
console.log('a3');
|
||||
cell.execute();
|
||||
console.log('a4');
|
||||
return IPython.version;
|
||||
});
|
||||
|
||||
console.log('b2');
|
||||
this.wait_for_output(0);
|
||||
|
||||
// refactor this into just a get_output(0)
|
||||
console.log('b3');
|
||||
this.then(function () {
|
||||
console.log('c');
|
||||
var result = this.get_output_cell(0);
|
||||
console.log('c2');
|
||||
this.test.assertEquals(result.text.trim(), jsver, 'IPython.version in JS matches server-side.');
|
||||
console.log('c3');
|
||||
});
|
||||
console.log('b4');
|
||||
|
||||
});
|
||||
|
@ -60,9 +60,11 @@ casper.open_new_notebook = function () {
|
||||
require(['base/js/namespace', 'base/js/events'], function (IPython, events) {
|
||||
|
||||
events.on('kernel_idle.Kernel',function () {
|
||||
console.log('!!Event idle');
|
||||
IPython._status = 'idle';
|
||||
});
|
||||
events.on('kernel_busy.Kernel',function () {
|
||||
console.log('!!Event busy');
|
||||
IPython._status = 'busy';
|
||||
});
|
||||
});
|
||||
@ -149,6 +151,7 @@ casper.wait_for_idle = function () {
|
||||
// Waits for the notebook to idle.
|
||||
this.waitFor(function () {
|
||||
return this.evaluate(function () {
|
||||
console.log(IPython._status);
|
||||
return IPython._status == 'idle';
|
||||
});
|
||||
});
|
||||
|
@ -14,7 +14,7 @@
|
||||
"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",
|
||||
"postinstall": "npm run bower",
|
||||
"bower": "bower install --allow-root --config.interactive=false",
|
||||
"build": "npm run build:css && npm run build:js",
|
||||
"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",
|
||||
|
Loading…
Reference in New Issue
Block a user