mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 08:26:16 -04:00
Show installed plugins and search new ones
This commit is contained in:
parent
dbdc53307e
commit
51cae02e9d
4 changed files with 167 additions and 2 deletions
45
src/static/js/pluginfw/installer.js
Normal file
45
src/static/js/pluginfw/installer.js
Normal file
|
@ -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);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue