2012-03-15 18:25:06 +01:00
|
|
|
var path = require('path');
|
|
|
|
var eejs = require('ep_etherpad-lite/node/eejs');
|
|
|
|
var installer = require('ep_etherpad-lite/static/js/pluginfw/installer');
|
2012-03-19 17:16:49 +01:00
|
|
|
var plugins = require('ep_etherpad-lite/static/js/pluginfw/plugins');
|
2012-03-15 18:25:06 +01:00
|
|
|
|
|
|
|
exports.expressCreateServer = function (hook_name, args, cb) {
|
|
|
|
args.app.get('/admin/plugins', function(req, res) {
|
|
|
|
var plugins = require("ep_etherpad-lite/static/js/pluginfw/plugins");
|
|
|
|
var render_args = {
|
|
|
|
plugins: plugins.plugins,
|
|
|
|
search_results: {},
|
|
|
|
errors: [],
|
|
|
|
};
|
|
|
|
|
2012-03-15 21:07:48 +01:00
|
|
|
res.send(eejs.require(
|
|
|
|
"ep_etherpad-lite/templates/admin/plugins.html",
|
|
|
|
render_args), {});
|
|
|
|
});
|
|
|
|
}
|
2012-03-15 18:25:06 +01:00
|
|
|
|
2012-03-15 21:07:48 +01:00
|
|
|
exports.socketio = function (hook_name, args, cb) {
|
|
|
|
var io = args.io.of("/pluginfw/installer");
|
|
|
|
io.on('connection', function (socket) {
|
2012-04-19 14:25:12 +02:00
|
|
|
if (!socket.handshake.session.user.is_admin) return;
|
|
|
|
|
2012-03-19 17:16:49 +01:00
|
|
|
socket.on("load", function (query) {
|
|
|
|
socket.emit("installed-results", {results: plugins.plugins});
|
|
|
|
});
|
|
|
|
|
2012-03-15 21:07:48 +01:00
|
|
|
socket.on("search", function (query) {
|
|
|
|
socket.emit("progress", {progress:0, message:'Fetching results...'});
|
2012-04-18 13:43:34 +02:00
|
|
|
installer.search(query, true, function (progress) {
|
2012-03-19 17:16:49 +01:00
|
|
|
if (progress.results)
|
|
|
|
socket.emit("search-result", progress);
|
|
|
|
socket.emit("progress", progress);
|
2012-03-15 18:25:06 +01:00
|
|
|
});
|
2012-03-15 21:07:48 +01:00
|
|
|
});
|
|
|
|
|
2012-03-17 18:17:10 +01:00
|
|
|
socket.on("install", function (plugin_name) {
|
|
|
|
socket.emit("progress", {progress:0, message:'Downloading and installing ' + plugin_name + "..."});
|
2012-03-19 17:16:49 +01:00
|
|
|
installer.install(plugin_name, function (progress) {
|
|
|
|
socket.emit("progress", progress);
|
2012-03-17 18:17:10 +01:00
|
|
|
});
|
2012-03-15 21:07:48 +01:00
|
|
|
});
|
|
|
|
|
2012-03-17 18:17:10 +01:00
|
|
|
socket.on("uninstall", function (plugin_name) {
|
|
|
|
socket.emit("progress", {progress:0, message:'Uninstalling ' + plugin_name + "..."});
|
2012-03-19 17:16:49 +01:00
|
|
|
installer.uninstall(plugin_name, function (progress) {
|
|
|
|
socket.emit("progress", progress);
|
2012-03-17 18:17:10 +01:00
|
|
|
});
|
2012-03-15 21:07:48 +01:00
|
|
|
});
|
2012-03-15 18:25:06 +01:00
|
|
|
});
|
2012-03-15 21:07:48 +01:00
|
|
|
}
|