summaryrefslogtreecommitdiff
path: root/src/static
diff options
context:
space:
mode:
authorMatthias Bartelmeß <mba@fourplusone.de>2012-04-04 15:04:10 +0200
committerMatthias Bartelmeß <mba@fourplusone.de>2012-04-04 15:04:10 +0200
commit4acbb11fd57f8306e5c9e87bfff189f80be43d81 (patch)
tree2b8ca3a8873a146be182c7d3df2fb7ac3c42185d /src/static
parent5115f74f6679af7d7eda37873c92ae936e270df3 (diff)
parente387e25c05f96146c14bc04ba88330908aa70991 (diff)
downloadetherpad-lite-4acbb11fd57f8306e5c9e87bfff189f80be43d81.zip
Merge branch 'develop' into feature/implicit_hooks
Diffstat (limited to 'src/static')
-rw-r--r--src/static/js/pluginfw/plugins.js60
1 files changed, 30 insertions, 30 deletions
diff --git a/src/static/js/pluginfw/plugins.js b/src/static/js/pluginfw/plugins.js
index b56c0dd9..db0b92e4 100644
--- a/src/static/js/pluginfw/plugins.js
+++ b/src/static/js/pluginfw/plugins.js
@@ -12,10 +12,9 @@ if (!exports.isClient) {
var fs = require("fs");
var tsort = require("./tsort");
var util = require("util");
- var extend = require("node.extend");
_ = require("underscore");
}else{
- var $, jQuery
+ var $, jQuery;
$ = jQuery = require("ep_etherpad-lite/static/js/rjquery").$;
_ = require("ep_etherpad-lite/static/js/underscore");
}
@@ -31,15 +30,15 @@ exports.ensure = function (cb) {
exports.update(cb);
else
cb();
-}
+};
exports.formatPlugins = function () {
return _.keys(exports.plugins).join(", ");
-}
+};
exports.formatParts = function () {
return _.map(exports.parts, function (part) { return part.full_name; }).join("\n");
-}
+};
exports.formatHooks = function () {
var res = [];
@@ -49,7 +48,7 @@ exports.formatHooks = function () {
});
});
return res.join("\n");
-}
+};
exports.loadFn = function (path, hookName) {
var x = path.split(":");
@@ -60,7 +59,7 @@ exports.loadFn = function (path, hookName) {
fn = fn[name];
});
return fn;
-}
+};
exports.extractHooks = function (parts, hook_set_name) {
var hooks = {};
@@ -81,7 +80,7 @@ exports.extractHooks = function (parts, hook_set_name) {
});
});
return hooks;
-}
+};
if (exports.isClient) {
@@ -96,7 +95,7 @@ if (exports.isClient) {
console.error("Failed to load plugin-definitions: " + err);
cb();
});
- }
+ };
} else {
exports.update = function (cb) {
@@ -110,15 +109,15 @@ exports.update = function (cb) {
exports.loadPlugin(packages, plugin_name, plugins, parts, cb);
},
function (err) {
- exports.plugins = plugins;
+ exports.plugins = plugins;
exports.parts = exports.sortParts(parts);
exports.hooks = exports.extractHooks(exports.parts, "hooks");
- exports.loaded = true;
+ exports.loaded = true;
cb(err);
}
);
});
-}
+ };
exports.getPackages = function (cb) {
// Load list of installed NPM packages, flatten it to a list, and filter out only packages with names that
@@ -128,49 +127,50 @@ exports.getPackages = function (cb) {
var packages = {};
function flatten(deps) {
_.chain(deps).keys().each(function (name) {
- if (name.indexOf(exports.prefix) == 0) {
- packages[name] = extend({}, deps[name]);
+ if (name.indexOf(exports.prefix) === 0) {
+ packages[name] = _.clone(deps[name]);
// Delete anything that creates loops so that the plugin
// list can be sent as JSON to the web client
delete packages[name].dependencies;
delete packages[name].parent;
- }
- if (deps[name].dependencies !== undefined)
- flatten(deps[name].dependencies);
+ }
+
+ if (deps[name].dependencies !== undefined) flatten(deps[name].dependencies);
});
}
+
var tmp = {};
tmp[data.name] = data;
flatten(tmp);
cb(null, packages);
});
-}
+ };
-exports.loadPlugin = function (packages, plugin_name, plugins, parts, cb) {
+ exports.loadPlugin = function (packages, plugin_name, plugins, parts, cb) {
var plugin_path = path.resolve(packages[plugin_name].path, "ep.json");
fs.readFile(
plugin_path,
function (er, data) {
if (er) {
- console.error("Unable to load plugin definition file " + plugin_path);
+ console.error("Unable to load plugin definition file " + plugin_path);
return cb();
}
try {
var plugin = JSON.parse(data);
- plugin.package = packages[plugin_name];
- plugins[plugin_name] = plugin;
- _.each(plugin.parts, function (part) {
- part.plugin = plugin_name;
- part.full_name = plugin_name + "/" + part.name;
- parts[part.full_name] = part;
- });
+ plugin['package'] = packages[plugin_name];
+ plugins[plugin_name] = plugin;
+ _.each(plugin.parts, function (part) {
+ part.plugin = plugin_name;
+ part.full_name = plugin_name + "/" + part.name;
+ parts[part.full_name] = part;
+ });
} catch (ex) {
- console.error("Unable to parse plugin definition file " + plugin_path + ": " + ex.toString());
+ console.error("Unable to parse plugin definition file " + plugin_path + ": " + ex.toString());
}
cb();
}
);
-}
+ };
exports.partsToParentChildList = function (parts) {
var res = [];
@@ -186,7 +186,7 @@ exports.partsToParentChildList = function (parts) {
}
});
return res;
-}
+};
// Used only in Node, so no need for _