kopia lustrzana https://github.com/c9/core
don't use client side plugin style
rodzic
cb9e4b38e4
commit
5dff95e0e2
|
@ -4,131 +4,106 @@
|
||||||
* @copyright 2013, Ajax.org B.V.
|
* @copyright 2013, Ajax.org B.V.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
"use strict";
|
||||||
"use strict";
|
|
||||||
|
|
||||||
main.consumes = ["Plugin", "connect.static"];
|
|
||||||
main.provides = ["c9.static.plugins"];
|
|
||||||
return main;
|
|
||||||
|
|
||||||
|
main.consumes = [
|
||||||
|
"connect.static"
|
||||||
|
];
|
||||||
|
main.provides = ["c9.static.plugins"];
|
||||||
|
|
||||||
function main(options, imports, register) {
|
module.exports = main;
|
||||||
var Plugin = imports.Plugin;
|
|
||||||
var statics = imports["connect.static"];
|
function main(options, imports, register) {
|
||||||
var fs = require("fs");
|
var statics = imports["connect.static"];
|
||||||
|
var fs = require("fs");
|
||||||
var whitelist = options.whitelist;
|
|
||||||
var blacklist = options.blacklist;
|
|
||||||
|
|
||||||
/***** Initialization *****/
|
|
||||||
|
|
||||||
var plugin = new Plugin("Ajax.org", main.consumes);
|
|
||||||
|
|
||||||
var loaded = false;
|
|
||||||
function load(){
|
|
||||||
if (loaded) return false;
|
|
||||||
loaded = true;
|
|
||||||
|
|
||||||
var requirePaths = {
|
|
||||||
ace: "lib/ace/lib/ace",
|
|
||||||
ace_tree: "lib/ace_tree/lib/ace_tree",
|
|
||||||
treehugger: "lib/treehugger/lib/treehugger",
|
|
||||||
acorn: "lib/treehugger/lib/treehugger/js",
|
|
||||||
tern: "lib/tern",
|
|
||||||
ui: "lib/ui",
|
|
||||||
c9: "lib/c9",
|
|
||||||
frontdoor: "lib/frontdoor",
|
|
||||||
};
|
|
||||||
|
|
||||||
if (whitelist === "*") {
|
|
||||||
statics.addStatics([{
|
|
||||||
path: __dirname + "/../../node_modules",
|
|
||||||
mount: "/lib"
|
|
||||||
}]);
|
|
||||||
|
|
||||||
statics.addStatics([{
|
var whitelist = options.whitelist;
|
||||||
path: __dirname + "/../../plugins",
|
var blacklist = options.blacklist;
|
||||||
mount: "/plugins",
|
|
||||||
rjs: requirePaths
|
var requirePaths = {
|
||||||
}]);
|
ace: "lib/ace/lib/ace",
|
||||||
} else {
|
ace_tree: "lib/ace_tree/lib/ace_tree",
|
||||||
[
|
treehugger: "lib/treehugger/lib/treehugger",
|
||||||
"ace_tree",
|
acorn: "lib/treehugger/lib/treehugger/js",
|
||||||
"acorn",
|
tern: "lib/tern",
|
||||||
"tern",
|
ui: "lib/ui",
|
||||||
"treehugger",
|
c9: "lib/c9",
|
||||||
"pivottable",
|
frontdoor: "lib/frontdoor",
|
||||||
"architect",
|
};
|
||||||
"source-map",
|
|
||||||
"rusha",
|
if (whitelist === "*") {
|
||||||
"c9",
|
statics.addStatics([{
|
||||||
"ui",
|
path: __dirname + "/../../node_modules",
|
||||||
"emmet",
|
mount: "/lib"
|
||||||
"frontdoor",
|
}]);
|
||||||
"mocha", // TESTING
|
|
||||||
"chai", // TESTING
|
|
||||||
].forEach(function(name) {
|
|
||||||
statics.addStatics([{
|
|
||||||
path: __dirname + "/../../node_modules/" + name,
|
|
||||||
mount: "/lib/" + name
|
|
||||||
}]);
|
|
||||||
});
|
|
||||||
|
|
||||||
statics.addStatics([{
|
|
||||||
path: __dirname + "/../../node_modules/ace",
|
|
||||||
mount: "/lib/ace",
|
|
||||||
rjs: requirePaths
|
|
||||||
}]);
|
|
||||||
|
|
||||||
statics.addStatics(fs.readdirSync(__dirname + "/../")
|
|
||||||
.filter(function(path) {
|
|
||||||
if (path in blacklist)
|
|
||||||
return false;
|
|
||||||
else if (path in whitelist)
|
|
||||||
return true;
|
|
||||||
else if (path.indexOf("c9.ide.") === 0)
|
|
||||||
return true;
|
|
||||||
else if (path.indexOf("c9.account") === 0)
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
})
|
|
||||||
.map(function(path) {
|
|
||||||
return {
|
|
||||||
path: __dirname + "/../../plugins/" + path,
|
|
||||||
mount: "/plugins/" + path
|
|
||||||
};
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
statics.addStatics([{
|
|
||||||
path: __dirname + "/www",
|
|
||||||
mount: "/"
|
|
||||||
}]);
|
|
||||||
|
|
||||||
statics.addStatics([{
|
|
||||||
path: __dirname + "/../../docs",
|
|
||||||
mount: "/docs"
|
|
||||||
}]);
|
|
||||||
|
|
||||||
}
|
statics.addStatics([{
|
||||||
|
path: __dirname + "/../../plugins",
|
||||||
/***** Lifecycle *****/
|
mount: "/plugins",
|
||||||
|
rjs: requirePaths
|
||||||
plugin.on("load", function(){
|
}]);
|
||||||
load();
|
} else {
|
||||||
});
|
[
|
||||||
plugin.on("unload", function(){
|
"ace_tree",
|
||||||
loaded = false;
|
"acorn",
|
||||||
|
"tern",
|
||||||
|
"treehugger",
|
||||||
|
"pivottable",
|
||||||
|
"architect",
|
||||||
|
"source-map",
|
||||||
|
"rusha",
|
||||||
|
"c9",
|
||||||
|
"ui",
|
||||||
|
"emmet",
|
||||||
|
"frontdoor",
|
||||||
|
"mocha", // TESTING
|
||||||
|
"chai", // TESTING
|
||||||
|
].forEach(function(name) {
|
||||||
|
statics.addStatics([{
|
||||||
|
path: __dirname + "/../../node_modules/" + name,
|
||||||
|
mount: "/lib/" + name
|
||||||
|
}]);
|
||||||
});
|
});
|
||||||
|
|
||||||
/***** Register and define API *****/
|
statics.addStatics([{
|
||||||
|
path: __dirname + "/../../node_modules/ace",
|
||||||
|
mount: "/lib/ace",
|
||||||
|
rjs: requirePaths
|
||||||
|
}]);
|
||||||
|
|
||||||
plugin.freezePublicAPI({});
|
statics.addStatics(fs.readdirSync(__dirname + "/../")
|
||||||
|
.filter(function(path) {
|
||||||
register(null, {
|
if (path in blacklist)
|
||||||
"c9.static.plugins": plugin
|
return false;
|
||||||
});
|
else if (path in whitelist)
|
||||||
|
return true;
|
||||||
|
else if (path.indexOf("c9.ide.") === 0)
|
||||||
|
return true;
|
||||||
|
else if (path.indexOf("c9.account") === 0)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
.map(function(path) {
|
||||||
|
return {
|
||||||
|
path: __dirname + "/../../plugins/" + path,
|
||||||
|
mount: "/plugins/" + path
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
statics.addStatics([{
|
||||||
|
path: __dirname + "/www",
|
||||||
|
mount: "/"
|
||||||
|
}]);
|
||||||
|
|
||||||
|
statics.addStatics([{
|
||||||
|
path: __dirname + "/../../docs",
|
||||||
|
mount: "/docs"
|
||||||
|
}]);
|
||||||
|
|
||||||
|
register(null, {
|
||||||
|
"c9.static.plugins": {}
|
||||||
|
});
|
||||||
|
}
|
Ładowanie…
Reference in New Issue