Browse Source

separate node applications

master
poikilos 6 years ago
committed by Jacob Gustafson
parent
commit
e41bb0194e
  1. 3
      README.md
  2. 16
      webapp/README.md
  3. 32
      webapp/masterserver.js
  4. 29
      webapp/minetestinfo.js
  5. 53
      webapp/server.js

3
README.md

@ -1,5 +1,6 @@
# ENLIVEN # ENLIVEN
ENLIVEN is a subgame for minetest with the goals of providing immersion and lessons for humanity. ENLIVEN is a subgame for minetest with the goals of providing immersion and lessons for humanity.
(see also webapp/README.md)
## Primary Features of EnlivenMinetest Project ## Primary Features of EnlivenMinetest Project
* Server installer for ENLIVEN on linux server (Ubuntu so far) * Server installer for ENLIVEN on linux server (Ubuntu so far)
@ -13,7 +14,7 @@ ENLIVEN is a subgame for minetest with the goals of providing immersion and less
There are several improvements I may implement in new or existing mods. For more information and status, see my [Minetest Kanboard](https://poikilos.dyndns.org/kanboard/?controller=BoardViewController&action=readonly&token=f214530d2f1294d90279631ce66b2e8b8569c6f15faf3773086476158bc8). There are several improvements I may implement in new or existing mods. For more information and status, see my [Minetest Kanboard](https://poikilos.dyndns.org/kanboard/?controller=BoardViewController&action=readonly&token=f214530d2f1294d90279631ce66b2e8b8569c6f15faf3773086476158bc8).
* maintain a table of short descriptions of mods * maintain a table of short descriptions of mods
* see also EnlivenMinetest/etc/game-install-enliven-testing.sh * see also EnlivenMinetest/etc/game-install-enliven-testing.sh
* slimenodes fork: make glue replaceable with animal hide; disable jump or reduce bouncy value, otherwise bouncing gets higher indefinitely * (resolved: glue can be made from saplings [from upstream]) slimenodes fork: make glue replaceable with animal hide; disable jump or reduce bouncy value, otherwise bouncing gets higher indefinitely
* https://github.com/minetest-mods/tutor * https://github.com/minetest-mods/tutor
* https://github.com/minetest-mods/chat_anticurse * https://github.com/minetest-mods/chat_anticurse
* https://github.com/minetest-mods/cozy (sitting and laying down player animations)--compare with emote https://github.com/minetest-mods/emote.git * https://github.com/minetest-mods/cozy (sitting and laying down player animations)--compare with emote https://github.com/minetest-mods/emote.git

16
webapp/README.md

@ -1,6 +1,10 @@
# EnlivenMinetest webapp # EnlivenMinetest webapp
EnlivenMinetest Node.js webapp for web management of minetest EnlivenMinetest Node.js webapp for web management of minetest
* Must run as same user as minetestserver, and neither should be root! * Before using this webapp, make sure you have installed minetest to
$HOME/minetest with the RUN_IN_PLACE option (this option is true by
default in Final Minetest builds). In the future, this webapp should
ask you which minetest to use.
* Must run as same user as minetestserver, and neither should be root.
## Install ## Install
* Using Terminal, cd to your EnlivenMinetest/webapp diretory, then: * Using Terminal, cd to your EnlivenMinetest/webapp diretory, then:
@ -17,11 +21,20 @@ npm install
## Planned Features ## Planned Features
(~=optional)
* Replace the "write" (stdout) method of the minetestserver process (see * Replace the "write" (stdout) method of the minetestserver process (see
<https://stackoverflow.com/questions/18543047/mocha-monitor-application-output>) <https://stackoverflow.com/questions/18543047/mocha-monitor-application-output>)
* parse Lua mods * parse Lua mods
- show armor strengths - show armor strengths
* list mods (only additional ones vs basis such as Bucket_Game) * list mods (only additional ones vs basis such as Bucket_Game)
* store config file in ~/.config/EnlivenMinetest/webapp.json
* allow user to choose path of minetestserver on first run
* (~) detect location of minetestserver (based on running executable
maybe, or which is most recent in expected directories)
* choose minetest games directory separately from bin in case
not `RUN_IN_PLACE`
* choose minetest worlds directory separately from bin in case
not `RUN_IN_PLACE`
## Developer Notes ## Developer Notes
@ -53,6 +66,7 @@ return results;
``` ```
### Development Log ### Development Log
(for changelog, see CHANGELOG.md)
```bash ```bash
#!/bin/sh #!/bin/sh
sudo apt update sudo apt update

32
webapp/masterserver.js

@ -0,0 +1,32 @@
var express = require('express');
var app = express();
app.get('/get-players', function (req, res) {
res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify(players));
});
var last_announce_string = "none";
app.get('/last-announce', function (req, res) {
res.setHeader('Content-Type', 'text/plain');
res.send(last_announce_string);
});
app.get('/announce', function (req, res) {
last_announce_string = JSON.stringify(req.body);
console.log("announce got:"+last_announce_string);
res.setHeader('Content-Type', 'text/plain');
res.send();
});
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;
console.log("listserver address:");
console.log(JSON.stringify(server.address()));
console.log("(experimental WIP) Minetest master server is listening at http://%s:%s", host, port);
});

29
webapp/minetestinfo.js

@ -0,0 +1,29 @@
var fs = require('fs');
const profilePath = require('os').homedir();
exports.profilePath = profilePath;
var minetestPath = profilePath + "/minetest"; // TODO: differs from .minetest if not RUN_IN_PLACE
exports.minetestPath = function() {
return minetestPath;
}
const myName = "minetestinfo.js";
var skinDir = "";
exports.skinDir = function () {
return skinDir;
}
exports.regeneratePaths = function () {
exports.skinDir = exports.minetestPath + "/games/Bucket_Game/mods/codercore/coderskins/textures";
if (fs.existsSync( minetestPath + "/games/ENLIVEN")) {
skinDir = minetestPath + "/games/ENLIVEN/mods/codercore/coderskins/textures";
}
console.log("[" + myName + "] skinDir: \"" + skinDir + "\"");
}
var thisMinetest = "/tank/local/owner/minetest";
if (fs.existsSync(thisMinetest)) {
minetestPath = thisMinetest;
}
exports.regeneratePaths();

53
webapp/server.js

@ -5,10 +5,6 @@
//return process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME']; //return process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];
//} //}
const profilePath = require('os').homedir();
var minetestPath = profilePath + "/minetest"; // TODO: differs from .minetest if not RUN_IN_PLACE
var skinDir = "";
var tz_offset = 240; //subtract this from server time to get local time; 4hrs is 240; 5hrs is 300 var tz_offset = 240; //subtract this from server time to get local time; 4hrs is 240; 5hrs is 300
// TODO: handle tz_offset not divisible by 60 // TODO: handle tz_offset not divisible by 60
// var selected_date_s = null; // var selected_date_s = null;
@ -26,6 +22,11 @@ const os = require('os');
var formidable = require('formidable') var formidable = require('formidable')
var querystring = require("querystring"); // built-in var querystring = require("querystring"); // built-in
var mv = require('mv'); var mv = require('mv');
// TODO: var config = require(storage_path + '/config.js') // config file contains all tokens and other private info
// var fun = require('./functions.js'); // functions file contains our non-app-specific functions including those for our Passport and database work
var mt = require('./minetestinfo.js'); // functions file contains our non-app-specific functions including those for our Passport and database work
// var util = require('util') // var util = require('util')
var app = express(); var app = express();
@ -56,14 +57,6 @@ var unique_flags = [
]; ];
//#endregion derived from mtsenliven.py //#endregion derived from mtsenliven.py
function regeneratePaths() {
skinDir = minetestPath + "/games/Bucket_Game/mods/codercore/coderskins/textures";
//doesn't work due to bug:
//if (fs.existsSync( minetestPath + "/games/ENLIVEN")) {
//skinDir = minetestPath + "/games/ENLIVEN/mods/codercore/coderskins/textures";
//}
console.log("skinDir: \"" + skinDir + "\"");
}
function process_logline(line, line_number) { function process_logline(line, line_number) {
//selected_date_s //selected_date_s
@ -291,29 +284,6 @@ function read_log() {
} }
} }
app.get('/get-players', function (req, res) {
res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify(players));
});
var last_announce_string = "none";
app.get('/last-announce', function (req, res) {
res.setHeader('Content-Type', 'text/plain');
res.send(last_announce_string);
});
app.get('/announce', function (req, res) {
last_announce_string = JSON.stringify(req.body);
console.log("announce got:"+last_announce_string);
res.setHeader('Content-Type', 'text/plain');
res.send();
});
app.get('/skin-form', function (req, res) { app.get('/skin-form', function (req, res) {
var ret = ""; var ret = "";
ret += '<html><body style="font-family:calibri,sans">'+"\n"; ret += '<html><body style="font-family:calibri,sans">'+"\n";
@ -351,8 +321,8 @@ app.post('/set-skin', function (req, res){
form.parse(req, function(err, fields, files) { form.parse(req, function(err, fields, files) {
if (err) next(err); if (err) next(err);
destNameNoExt = destNameNoExt = "player_" + fields.userName; destNameNoExt = destNameNoExt = "player_" + fields.userName;
directPath = skinDir + "/" + destNameNoExt + ".png"; directPath = mt.skinDir() + "/" + destNameNoExt + ".png";
indirectPath = skinDir + "/" + destNameNoExt + ".skin"; indirectPath = mt.skinDir() + "/" + destNameNoExt + ".skin";
// TODO: make sure my_file and userName values are present // TODO: make sure my_file and userName values are present
if (files.hasOwnProperty('userFile')) { if (files.hasOwnProperty('userFile')) {
if (fields.hasOwnProperty('userName')) { if (fields.hasOwnProperty('userName')) {
@ -474,13 +444,10 @@ Your browser does not support the canvas element.
var server = app.listen(3000, function () { var server = app.listen(64638, function () {
// 8123 is default for Minecraft DynMap
// 64638 spells 'minet' on a telephone keypad, but 6463, 6472 is already Discord RPC server
//console.log('express-handlebars example server listening on: 3000'); //console.log('express-handlebars example server listening on: 3000');
var thisMinetest = "/tank/local/owner/minetest";
if (fs.existsSync(thisMinetest)) {
minetestPath = thisMinetest;
}
regeneratePaths();
var host = server.address().address; var host = server.address().address;
var port = server.address().port; var port = server.address().port;
console.log("server address:"); console.log("server address:");

Loading…
Cancel
Save