-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use NPM, node ES5, and browserify. #268
Changes from all commits
ff9406f
b88fa01
8f0ea42
22fd1bc
6a29601
ad80ae9
6469065
c180719
81a2998
3498a51
f7d546c
37d92cb
2332b71
72bdf87
e0f3141
c8ff593
4c07a8b
a719e19
6258f54
b2ae17d
aa097ba
c0a30d4
2bb0957
b2bf69f
72d052e
b8f25ee
81e0fb3
89f8dfa
f299381
9fe3f63
0650a19
0a1854a
541aed3
7df0a11
55dd626
e44d912
84c9cb7
b0ec31d
b0cd502
0bc24c5
a9610dc
69bb4b1
c802038
84ce0ce
8c8c95c
467ae32
7f41017
3bc3fda
b689700
03a5b47
7717a98
307d9ee
511bb68
8ca1e85
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"browserify": true, | ||
"node": true, | ||
"jquery": true, | ||
"predef": [ "requirejs", "define", "Promise", "CodeMirror"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
} | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What was the issue here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried using |
||
], | ||
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)); | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well this is cleaner. I wonder if we should be declaring jquery global in the files in addition to the jshintrc. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Already did :) |
||
|
||
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; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a note that since we were returning a function it's cool that the name changed here to the JavaScriptism of CamelCase. |
||
var page_instance = new page.Page(); | ||
page_instance.show(); | ||
|
||
IPython.page = page_instance; | ||
} | ||
return logout_main; | ||
}); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
modal : modal, | ||
kernel_modal : kernel_modal, | ||
edit_metadata : edit_metadata, | ||
}; | ||
|
||
return dialog; | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, so here begins the re-write of the events. Glad you figured this one out. |
||
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; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I look forward to this one being cleaned up in a different PR later. 😉 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. go for it : ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON doesn't support comments, so I'm leaving one here in GitHub. The following packages can be removed from bower and the setupbase check now, but I left them here for backwards compatibility... In case any users are loading them in via requirejs.