From 5dff95e0e2fbc9cf4a4b4acd0d9ac0c81cd79ac7 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Mon, 9 Mar 2015 13:41:41 +0000 Subject: [PATCH] don't use client side plugin style --- plugins/c9.ide.server/plugins.js | 215 ++++++++++++++----------------- 1 file changed, 95 insertions(+), 120 deletions(-) diff --git a/plugins/c9.ide.server/plugins.js b/plugins/c9.ide.server/plugins.js index ae1f5601..e9089348 100644 --- a/plugins/c9.ide.server/plugins.js +++ b/plugins/c9.ide.server/plugins.js @@ -4,131 +4,106 @@ * @copyright 2013, Ajax.org B.V. */ -define(function(require, exports, module) { - "use strict"; - - main.consumes = ["Plugin", "connect.static"]; - main.provides = ["c9.static.plugins"]; - return main; +"use strict"; +main.consumes = [ + "connect.static" +]; +main.provides = ["c9.static.plugins"]; - function main(options, imports, register) { - var Plugin = imports.Plugin; - 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" - }]); +module.exports = main; + +function main(options, imports, register) { + var statics = imports["connect.static"]; + var fs = require("fs"); - statics.addStatics([{ - path: __dirname + "/../../plugins", - mount: "/plugins", - rjs: requirePaths - }]); - } else { - [ - "ace_tree", - "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 - }]); - }); - - 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" - }]); + var whitelist = options.whitelist; + var blacklist = options.blacklist; + + 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" + }]); - } - - /***** Lifecycle *****/ - - plugin.on("load", function(){ - load(); - }); - plugin.on("unload", function(){ - loaded = false; + statics.addStatics([{ + path: __dirname + "/../../plugins", + mount: "/plugins", + rjs: requirePaths + }]); + } else { + [ + "ace_tree", + "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({}); - - register(null, { - "c9.static.plugins": plugin - }); + 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 + }; + }) + ); } -}); \ No newline at end of file + + statics.addStatics([{ + path: __dirname + "/www", + mount: "/" + }]); + + statics.addStatics([{ + path: __dirname + "/../../docs", + mount: "/docs" + }]); + + register(null, { + "c9.static.plugins": {} + }); +} \ No newline at end of file