diff options
author | Matthias Bartelmeß <mba@fourplusone.de> | 2012-04-04 15:10:27 +0200 |
---|---|---|
committer | Matthias Bartelmeß <mba@fourplusone.de> | 2012-04-04 15:10:27 +0200 |
commit | f34e13f761646bf75d7f41a4d8958bb6033a48a8 (patch) | |
tree | f2fc4170d2a9164819c0e747586019a9825007d3 | |
parent | 4acbb11fd57f8306e5c9e87bfff189f80be43d81 (diff) | |
download | etherpad-lite-f34e13f761646bf75d7f41a4d8958bb6033a48a8.zip |
on plugin definitions, only expose plugins with client_hooks registered. dont expose 'package' property
-rw-r--r-- | src/node/hooks/express/static.js | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/node/hooks/express/static.js b/src/node/hooks/express/static.js index 9209967c..f284e478 100644 --- a/src/node/hooks/express/static.js +++ b/src/node/hooks/express/static.js @@ -6,6 +6,7 @@ var settings = require("../../utils/Settings"); var Yajsml = require('yajsml'); var fs = require("fs"); var ERR = require("async-stacktrace"); +var _ = require("underscore"); exports.expressCreateServer = function (hook_name, args, cb) { // Cache both minified and static. @@ -35,8 +36,22 @@ exports.expressCreateServer = function (hook_name, args, cb) { // serve plugin definitions // not very static, but served here so that client can do require("pluginfw/static/js/plugin-definitions.js"); args.app.get('/pluginfw/plugin-definitions.json', function (req, res, next) { + + var clientParts = _(plugins.parts) + .filter(function(part){ return _(part).has('client_hooks') }); + + var clientPlugins = {}; + + _(clientParts).chain() + .map(function(part){ return part.plugin }) + .uniq() + .each(function(name){ + clientPlugins[name] = _(plugins.plugins[name]).clone(); + delete clientPlugins[name]['package']; + }); + res.header("Content-Type","application/json; charset=utf-8"); - res.write(JSON.stringify({"plugins": plugins.plugins, "parts": plugins.parts})); + res.write(JSON.stringify({"plugins": clientPlugins, "parts": clientParts})); res.end(); }); } |