'use strict'; var express = require('express'), //var exphbs = require("express-handlebars"); // exphbs = require('../../'); // "express-handlebars" cookieParser = require('cookie-parser'), bodyParser = require('body-parser'), //session = require('express-session'), fs = require('fs'); const os = require('os'); var app = express(); //app.engine('handlebars', exphbs({defaultLayout: 'main'})); //app.set('view engine', 'handlebars'); var players = []; //see https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/Introduction var prev_line = null; //#region derived from mtsenliven.py var msg_flags = ["WARNING[Server]: ", "ACTION[Server]: "] var msg_lists = {} // where flag is key for (flag in msg_flags) { msg_lists[flag] = []; } var non_unique_wraps = []; non_unique_wraps.push({ "opener":"active block modifiers took ", "closer":"ms (longer than 200ms)" }); var unique_flags = [ "leaves game", "joins game" ]; //#endregion derived from mtsenliven.py function process_logline(line) { var player_name = ""; var verb = ""; index = -1; if (player_name != "") { if (player_indices.hasOwnProperty(player_name)) { index = player_indices[player_name]; } else { index = player_count; players[index] = {}; players[index].display_name = player_name; player_count++; } } if (verb == "leaves game") { players[index].logout_time = ""; } else if (verb == "joins game") { players[index].login_time = ""; } } function relog_unique_only(output, err_flag=false) { var ret = ""; var output_strip = output.trim(); var u_prefix = "active block modifiers took "; var u_suffix = "ms (longer than 200ms)"; // (out_bytes is bytes) var show_enable = true; var found_flag = null; var f_i = null; var always_show_enable = false; var msg_msg = "previous message"; var uf_len = unique_flags.length; for (var uf_i=0; uf_i= 0) { found_flag = msg_flags[mf_i]; break; } } if (found_flag!=null) { var sub_msg = output.substring(f_i+flag.length).trim(); var nuw_len = non_unique_wraps.length; for (var nuw_i=0; nuw_i -1) { show_enable = false; } else { msg_lists[found_flag].push(sub_msg); } } } if (show_enable) { ret = output_strip; if (found_flag != null) { ret += "\n [ EnlivenMinetest ] " + msg_msg + " will be suppressed"; } } return ret; } app.get('/', function (req, res) { var ret = ""; // Whenever server starts the following is logged // (see also etc/example-input.txt): // //------------- // Separator //------------- // ret += os.homedir(); //see ~/.minetest/debug.txt //and logs archived by EnlivenMinetest: //~/.minetest/debug_archived/2018/05/08.txt var ret += ` Your browser does not support the canvas element.
loading...
`; res.send(ret); //res.render('home'); }); var server = app.listen(3000, function () { //console.log('express-handlebars example server listening on: 3000'); var host = server.address().address; var port = server.address().port; var this_log_path = os.homedir() + "/.minetest/debug_archived/2018/05/08.txt"; console.log("EnlivenMinetest webapp reading '" + this_log_path + "'..."); console.log("EnlivenMinetest webapp listening at http://%s:%s", host, port); });