From 991e9426c037bc98a67a39348f27499795695304 Mon Sep 17 00:00:00 2001 From: asanrom Date: Thu, 15 Sep 2016 19:32:37 +0200 Subject: [PATCH] Add option to customize control panel main page --- src/server/handlers/admin.js | 3 +++ src/server/server.js | 18 +++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/server/handlers/admin.js b/src/server/handlers/admin.js index f968346..be9a412 100644 --- a/src/server/handlers/admin.js +++ b/src/server/handlers/admin.js @@ -87,6 +87,7 @@ App.server.setHandler('admin', (context, parts) => { App.config.useproxy = !!context.post.useproxy; App.config.blockautodownload = !!context.post.blockautodownload; App.config.autoremoveuserdata = !!context.post.rmuserdata; + App.config.mainhtml = (context.post.mainhtml || '').trim(); if (context.post.wslib === 'sockjs') { App.config.websocketLibrary = 'sockjs'; } else { @@ -149,6 +150,8 @@ App.server.setHandler('admin', (context, parts) => { (App.config.blockautodownload ? 'checked="checked"' : '') + ' /> Block automated data downloads.

'; html += '

 Remove User-Data on connection reset.

'; + html += '

'; html += '

'; html += ''; diff --git a/src/server/server.js b/src/server/server.js index 4b1bf76..76f8121 100644 --- a/src/server/server.js +++ b/src/server/server.js @@ -313,13 +313,17 @@ class Server { } else if (!context.url.path || context.url.path === '/') { /* Main page */ context.setMenu(this.getMenu(context)); - FileSystem.readFile(Path.resolve(__dirname, 'main.html'), (error, data) => { - if (error) { - context.endWithError(500, 'Internal Server Error', 'Error: ' + error.code + " (" + error.message + ")"); - } else { - context.endWithWebPage(data.toString(), {title: "Showdown ChatBot - Control Panel"}); - } - }); + if (App.config.mainhtml) { + context.endWithWebPage(App.config.mainhtml, {title: "Showdown ChatBot - Control Panel"}); + } else { + FileSystem.readFile(Path.resolve(__dirname, 'main.html'), (error, data) => { + if (error) { + context.endWithError(500, 'Internal Server Error', 'Error: ' + error.code + " (" + error.message + ")"); + } else { + context.endWithWebPage(data.toString(), {title: "Showdown ChatBot - Control Panel"}); + } + }); + } } else { /* Handlers */ let urlParts = context.url.path.split('/');