allow editing index html when debug_enabled = true

This commit is contained in:
jomo 2015-10-14 23:42:27 +02:00
parent a3cbedb859
commit f0df78e6a9
2 changed files with 16 additions and 3 deletions

View File

@ -28,7 +28,7 @@ var config = {
}, },
server: { server: {
http_timeout: 2000, // ms until connection to Mojang is dropped http_timeout: 2000, // ms until connection to Mojang is dropped
debug_enabled: false, // enables logging.debug debug_enabled: false, // enables logging.debug & editing index page
log_time: true // set to false if you use an external logger that provides timestamps log_time: true // set to false if you use an external logger that provides timestamps
} }
}; };

View File

@ -1,12 +1,25 @@
var logging = require("../logging");
var config = require("../../config"); var config = require("../../config");
var path = require("path"); var path = require("path");
var read = require("fs").readFileSync; var read = require("fs").readFileSync;
var ejs = require("ejs"); var ejs = require("ejs");
var str = read(path.join(__dirname, "..", "views", "index.html.ejs"), "utf-8"); var str;
var index = ejs.compile(str); var index;
function compile() {
logging.log("Compiling index page");
str = read(path.join(__dirname, "..", "views", "index.html.ejs"), "utf-8");
index = ejs.compile(str);
}
compile();
module.exports = function(req, callback) { module.exports = function(req, callback) {
if (config.server.debug_enabled) {
// allow changes without reloading
compile();
}
var html = index({ var html = index({
title: "Crafatar", title: "Crafatar",
domain: "https://" + req.headers.host, domain: "https://" + req.headers.host,