diff options
author | John McLear <john@mclear.co.uk> | 2012-11-05 04:48:59 -0800 |
---|---|---|
committer | John McLear <john@mclear.co.uk> | 2012-11-05 04:48:59 -0800 |
commit | b6a331b9ec45035cc84b864124868af0b7b636f0 (patch) | |
tree | f48fd52dfeb1998c1db5fdc4619d911462d50c3a /src/node/hooks/express | |
parent | dfa0ae918102a5224d271216c0ab8b1bb7d3e156 (diff) | |
parent | 2f123970e646e012a0be58387b963f79cdf977a0 (diff) | |
download | etherpad-lite-b6a331b9ec45035cc84b864124868af0b7b636f0.zip |
Merge pull request #1120 from Pita/feature/settings-admin
Modify Server Settings in /admin/settings
Diffstat (limited to 'src/node/hooks/express')
-rw-r--r-- | src/node/hooks/express/adminsettings.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/node/hooks/express/adminsettings.js b/src/node/hooks/express/adminsettings.js new file mode 100644 index 00000000..db4df750 --- /dev/null +++ b/src/node/hooks/express/adminsettings.js @@ -0,0 +1,52 @@ +var path = require('path'); +var eejs = require('ep_etherpad-lite/node/eejs'); +var installer = require('ep_etherpad-lite/static/js/pluginfw/installer'); +var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks"); +var fs = require('fs'); + +exports.expressCreateServer = function (hook_name, args, cb) { + args.app.get('/admin/settings', function(req, res) { + + var render_args = { + settings: "", + search_results: {}, + errors: [] + }; + + res.send( eejs.require("ep_etherpad-lite/templates/admin/settings.html", render_args) ); + + }); +} + +exports.socketio = function (hook_name, args, cb) { + var io = args.io.of("/settings"); + io.on('connection', function (socket) { + if (!socket.handshake.session.user || !socket.handshake.session.user.is_admin) return; + + socket.on("load", function (query) { + fs.readFile('settings.json', 'utf8', function (err,data) { + if (err) { + return console.log(err); + } + else + { + socket.emit("settings", {results: data}); + } + }); + }); + + socket.on("saveSettings", function (settings) { + fs.writeFile('settings.json', settings, function (err) { + if (err) throw err; + socket.emit("saveprogress", "saved"); + }); + }); + + socket.on("restartServer", function () { + console.log("Admin request to restart server through a socket on /admin/settings"); + hooks.aCallAll("restartServer", {}, function () {}); + + }); + + }); +} |