summaryrefslogtreecommitdiff
path: root/routes
diff options
context:
space:
mode:
Diffstat (limited to 'routes')
-rw-r--r--routes/settings.js25
1 files changed, 23 insertions, 2 deletions
diff --git a/routes/settings.js b/routes/settings.js
index 658c0f2..59b9f80 100644
--- a/routes/settings.js
+++ b/routes/settings.js
@@ -1,8 +1,29 @@
"use strict";
+const config = require("../server/js/config");
+
function settings(req, res)
{
- res.render('settings', {showSearchBar: true});
+ res.render('settings', {showSearchBar: true, config: config.loadedConfig});
+};
+
+function save(req, res)
+{
+ let newConfig = {
+ 'settings': {
+ 'nsfw_content': ((req.body.nsfw === "on") ? true : false),
+ 'port': ((!isNaN(parseInt(req.body.port))) ? parseInt(req.body.port) : 3000),
+ 'tor': {
+ 'host': ((req.body.torHost) ? req.body.torHost : undefined),
+ 'port': ((!isNaN(parseInt(req.body.torPort))) ? parseInt(req.body.torPort) : undefined)
+ }
+ }
+ };
+
+ config.createConfig(newConfig);
+ config.loadConfig();
+
+ res.render('settings', {showSearchBar: true, config: config.loadedConfig});
};
-module.exports = settings;
+module.exports = {settings, save};