Skip to content

Commit

Permalink
Add option to customize control panel main page
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinSRG committed Sep 15, 2016
1 parent 0d81296 commit 991e942
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/server/handlers/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -149,6 +150,8 @@ App.server.setHandler('admin', (context, parts) => {
(App.config.blockautodownload ? 'checked="checked"' : '') + ' /></label>&nbsp;Block automated data downloads.</p>';
html += '<p><label><input type="checkbox" name="rmuserdata" value="true" ' +
(App.config.autoremoveuserdata ? 'checked="checked"' : '') + ' /></label>&nbsp;Remove User-Data on connection reset.</p>';
html += '<p><textarea name="mainhtml" cols="80" rows="4" placeholder="Custom HTML for main page. Leave this blank for default page.">' +
(App.config.mainhtml || '') + '</textarea></p>';
html += '<p><input type="submit" name="savechanges" value="Save Changes" /></p>';
html += '</form>';

Expand Down
18 changes: 11 additions & 7 deletions src/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('/');
Expand Down

0 comments on commit 991e942

Please sign in to comment.