aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Kronqvist <work.joelkronqvist@gmail.com>2022-11-05 13:07:11 +0200
committerJoel Kronqvist <work.joelkronqvist@gmail.com>2022-11-05 13:07:11 +0200
commit0f2d56eafd01b5e728f96cf327f1a3e881a21225 (patch)
treeed845c70cd9408398235cc8d1cd9e00105a2f5b3
parent4a9dca9ffccb087135c6e2d0eebae45cd567036d (diff)
downloadLYLLRuoka-0f2d56eafd01b5e728f96cf327f1a3e881a21225.tar.gz
LYLLRuoka-0f2d56eafd01b5e728f96cf327f1a3e881a21225.zip
Hid vegetarian food when it is the same as the normal food. Added date logging to init.sh.
-rw-r--r--food.js4
-rwxr-xr-xinit.sh6
-rw-r--r--server.js2
3 files changed, 7 insertions, 5 deletions
diff --git a/food.js b/food.js
index 7a9691d..8de8dcd 100644
--- a/food.js
+++ b/food.js
@@ -3,8 +3,8 @@ const open = require("./Functions/open.js");
const { weekdayToNumber } = require("./Functions/dateFuncs.js");
function* scrapeFood(data)
-{
- const foodRegex = /<title>(\w{2} (?:\d\d?\.){2}\d{4})<\/title><description><!\[CDATA\[(Lounas) ?:? ?(.*?)(Kasvislounas) ?:? ?(.*?)]]><\/description>/gm;
+{
+ const foodRegex = /<title>(\w{2} (?:\d\d?\.){2}\d{4})<\/title><description><!\[CDATA\[(Lounas) ?:? ?(.*?)<br>(Kasvislounas) ?:? ?(.*?)]]><\/description>/
const foods = data.matchAll(foodRegex);
for(const food of foods)
{
diff --git a/init.sh b/init.sh
index 5fb171f..fb5d611 100755
--- a/init.sh
+++ b/init.sh
@@ -2,7 +2,7 @@
exec 1>>/var/slogs
exec 2>>/var/slogs
echo ""
-echo "# Init running"
+echo "# Init running at $(date)"
echo "# Waiting for connection..."
while ! ping 'example.org' -c 1; do
@@ -26,6 +26,8 @@ while echo "# node server.js:"; do
# Sleep below, so that the loop can't cause too big a load to the server, if the server terminates very fast.
sleep 5
- echo "SERVER TERMINATED!"
+ echo "# Server terminated at $(date)"
echo "--------"
+ echo ""
+ echo ""
done
diff --git a/server.js b/server.js
index 905fe63..c2b0449 100644
--- a/server.js
+++ b/server.js
@@ -283,7 +283,7 @@ async function buildMain(args)
res["food-header"] = `Kouluruoka ${weekdays[day]}`;
res["food"] = "Päivän ruoka puuttuu tietokannasta.";
}
- if (vege[0] !== undefined) {
+ if ((vege[0] !== undefined) && (vege[0].food !== res["food"])) {
res["vege-header"] = vege[0].header;
res["vege"] = vege[0].food;
} else {