diff options
author | Egil Moeller <egil.moller@freecode.no> | 2012-03-15 18:25:06 +0100 |
---|---|---|
committer | Egil Moeller <egil.moller@freecode.no> | 2012-03-15 18:25:06 +0100 |
commit | 51cae02e9dd20f483c2b71c07865561ea50eaf8b (patch) | |
tree | ba776320a05019f63669e3b3ff79927ae362a1d7 /src/static/js/pluginfw/installer.js | |
parent | dbdc53307e6b5a2b64910a4e68149bc17b30be43 (diff) | |
download | etherpad-lite-51cae02e9dd20f483c2b71c07865561ea50eaf8b.zip |
Show installed plugins and search new ones
Diffstat (limited to 'src/static/js/pluginfw/installer.js')
-rw-r--r-- | src/static/js/pluginfw/installer.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/static/js/pluginfw/installer.js b/src/static/js/pluginfw/installer.js new file mode 100644 index 00000000..3ba7f458 --- /dev/null +++ b/src/static/js/pluginfw/installer.js @@ -0,0 +1,45 @@ +var plugins = require("ep_etherpad-lite/static/js/pluginfw/plugins"); +var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks"); +var npm = require("npm"); +var registry = require("npm/lib/utils/npm-registry-client/index.js"); + +exports.uninstall = function(plugin_name, cb) { + npm.load({}, function (er) { + if (er) return cb(er) + npm.commands.uninstall([plugin_name], function (er) { + if (er) return cb(er); + hooks.aCallAll("pluginUninstall", {plugin_name: plugin_name}, function (er) { + cb(er); + }); + }) + }) +} + +exports.install = function(plugin_name, cb) { + npm.load({}, function (er) { + if (er) return cb(er) + npm.commands.install([plugin_name], function (er) { + if (er) return cb(er); + hooks.aCallAll("pluginInstall", {plugin_name: plugin_name}, function (er) { + cb(er); + }); + }); + }) +} + +exports.search = function(pattern, cb) { + npm.load({}, function (er) { + registry.get( + "/-/all", null, 600, false, true, + function (er, data) { + if (er) return cb(er); + var res = {}; + for (key in data) { + if (/*key.indexOf(plugins.prefix) == 0 &&*/ key.indexOf(pattern) != -1) + res[key] = data[key]; + } + cb(null, res); + } + ); + }); +} |