aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.h.kronqvist@gmail.com>2022-01-19 16:23:56 +0200
committerJoel Kronqvist <joel.h.kronqvist@gmail.com>2022-01-19 16:23:56 +0200
commit708996ed58f031fd31d7696a98adfc287db9905a (patch)
tree7f0e89c2b17e8d51259a515f19e28fcfeb68c8b9
parenta259127b9fa0349c73340c882f6525f27f7caaed (diff)
downloadLYLLRuoka-708996ed58f031fd31d7696a98adfc287db9905a.tar.gz
LYLLRuoka-708996ed58f031fd31d7696a98adfc287db9905a.zip
Tested on Linux Mint & some bug fixes
-rw-r--r--.gitignore4
-rw-r--r--README.md7
-rw-r--r--scrape.js2
-rw-r--r--server.js9
4 files changed, 15 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1ca582b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+Classes
+node_modules
+package-lock.json
+shifts.txt \ No newline at end of file
diff --git a/README.md b/README.md
index 5ac073c..c593e02 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,12 @@
Readme coming soon!
## Setup
-If you want to set up the server, you will have to get a SSL certificate or generate one yourself. If you want to run a dedicated server that can update, you also need to add the cron jobs from crontab\_add. You must create a MySQL DB and give its login info in ../dblogin.txt. The database should have the following tables set up:
+You will need a SSL certificate if you want to use https.
+You need to install node.js and MySQL (+ npm install mysql2).
+You will need to update the server with the help of the food shift message and a tab separated list of classes (just copypaste from excel from the Kurssitarjotin)
+You probably want to set up cron to run some cronjobs from crontab_add.txt.
+You need to provide the login info to the MySQL DB in ../dblogin.txt. Logging in as root was found problematic on Mint, but feel free to try if you want to.
+You should create the following tables, because the server code wont do it for you.
CREATE TABLE shiftnames (
day INT,
diff --git a/scrape.js b/scrape.js
index 0ae30aa..c7a5743 100644
--- a/scrape.js
+++ b/scrape.js
@@ -1,5 +1,5 @@
const https = require("https");
-const parse = require("./DBPARSE.js");
+const parse = require("./dbparse.js");
const fs = require("fs");
const events = require("events");
diff --git a/server.js b/server.js
index 1431465..b01b6de 100644
--- a/server.js
+++ b/server.js
@@ -32,8 +32,8 @@ async function init()
scrape.food(scrape.link(1)),
scrape.food(scrape.link(2)),
openFile("../dblogin.txt"),
- openFile("../Certificate/key.pem"),
- openFile("../Certificate/cert.pem")
+ openFile("../Certificate/key.pem"),
+ openFile("../Certificate/cert.pem")
]);
// https options, you need to get a certificate in the file ../Certificate for the server to work
@@ -93,7 +93,7 @@ async function init()
}
// start server
- const runningServer = http.createServer(server).listen(8080);
+ const runningServer = https.createServer(httpsOpts, server).listen(8080);
// stop server
async function closeServer() {
@@ -160,7 +160,7 @@ async function buildMain(args)
const d = new Date();
let day = d.getDay();
day = (day + +(day === 0) * 7) - 1;
- const actualDay = day;
+ const actualDay = day + (+(day === 0) * 7);
day = +(!(day === 5) && !(day === 6)) * day;
if ((typeof query.day === "string") && (parseInt(query.day).toString() === query.day) && (!isNaN(parseInt(query.day))) && (parseInt(query.day) >= 0) && (parseInt(query.day) < 5))
day = parseInt(query.day);
@@ -216,7 +216,6 @@ async function buildMain(args)
// get the food
day += (day === 0) * 7;
- actualDay += (actualDay === 0) * 7;
let food;
food = foods[ +(day < actualDay) ][day];
if (food !== undefined)