Compare commits
4 Commits
6b817008c3
...
49d9e4e5d1
| Author | SHA1 | Date |
|---|---|---|
|
|
49d9e4e5d1 | 10 months ago |
|
|
c0092d57e6 | 11 months ago |
|
|
c96f3ea5da | 1 year ago |
|
|
8011a8fcd0 | 1 year ago |
@ -1,15 +0,0 @@
|
|||||||
|
|
||||||
ELM := $(shell command -v elm 2>/dev/null)
|
|
||||||
GUILE := $(shell command -v guile 2>/dev/null)
|
|
||||||
ART := $(shell command -v art)
|
|
||||||
ifndef ELM
|
|
||||||
ELM = $(error "elm installation not found in PATH")
|
|
||||||
endif
|
|
||||||
ifndef GUILE
|
|
||||||
GUILE = $(error "guile installation not found in PATH")
|
|
||||||
endif
|
|
||||||
ifndef ART
|
|
||||||
ART = $(error "artanis installation not found in PATH")
|
|
||||||
endif
|
|
||||||
|
|
||||||
ELM_TARGET = frontend/www/elm.js
|
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
.PHONY: all back front install
|
||||||
|
|
||||||
|
all: back front
|
||||||
|
|
||||||
|
back:
|
||||||
|
cd backend && ${MAKE}
|
||||||
|
|
||||||
|
front:
|
||||||
|
cd frontend && ${MAKE}
|
||||||
|
|
||||||
|
@public_dir@:
|
||||||
|
cd frontend && ${MAKE} install
|
||||||
|
|
||||||
|
@nginx_config@: m4/environment.m4 nginx/yacswa.conf.m4
|
||||||
|
m4 m4/environment.m4 nginx/yacswa.conf.m4 > @nginx_config@
|
||||||
|
|
||||||
|
install: @public_dir@ @nginx_config@
|
||||||
|
|
||||||
|
up: install
|
||||||
|
sudo $(LN_S) /etc/nginx/sites_available/yacswa.conf /etc/nginx/sites_enabled/
|
||||||
|
cd backend && ${MAKE} up
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
.PHONY: all deps tk csv up down
|
||||||
|
|
||||||
|
all: deps
|
||||||
|
|
||||||
|
deps: tk csv
|
||||||
|
|
||||||
|
tk:
|
||||||
|
cd deps/guile-toolkit && ${MAKE} && sudo ${MAKE} install
|
||||||
|
|
||||||
|
csv:
|
||||||
|
cd deps/guile-csv && ${MAKE} && sudo ${MAKE} install
|
||||||
|
|
||||||
|
up: deps .backend.lock
|
||||||
|
|
||||||
|
.backend.lock: main.scm
|
||||||
|
@nohup $(GUILE) ./main.scm > yacswa-backend.log & export PID=$$! & echo "Server spawned with PID $${PID}"; echo $${PID} > .backend.lock; unset PID
|
||||||
|
|
||||||
|
down:
|
||||||
|
@export PID=`cat .backend.lock`; kill -15 $${PID}; rm .backend.lock; rm bc; echo "Server on PID $${PID} down."; unset PID
|
||||||
@ -1 +1 @@
|
|||||||
Subproject commit ac87ac1294de72a6bbc84b0eb68a605d17058796
|
Subproject commit 0b20cd490312de9154d023bc8627e3c90bb5845a
|
||||||
@ -1 +1 @@
|
|||||||
Subproject commit bd06431dc8d878440f6eb2853543252434fad736
|
Subproject commit 0d1e98c17262ba7c85b2427cdca54ebe401200e9
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
# -*- Autoconf -*-
|
||||||
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
|
AC_PREREQ([2.72])
|
||||||
|
AC_INIT([Yet Another Covid Statistics Web App], [1.0], [me@bradymcd.ca])
|
||||||
|
|
||||||
|
# Pull in environment variables
|
||||||
|
AC_SUBST([server_name], [yacswa.home])
|
||||||
|
AC_SUBST([public_dir], [/srv/yacswa.home])
|
||||||
|
AC_SUBST([nginx_config], [yacswa.home.conf])
|
||||||
|
|
||||||
|
# Checks for programs.
|
||||||
|
AC_PROG_MAKE_SET
|
||||||
|
AC_CHECK_PROG(GUILE, [guile], [guile], [no])
|
||||||
|
test "$GUILE" == "no" && AC_MSG_ERROR([Guile's interpreter: 'guile' not found.])
|
||||||
|
AC_CHECK_PROG(GUILD, [guild], [guild], [no])
|
||||||
|
test "$GUILD" == "no" && AC_MSG_ERROR([Guile's compiler: 'guild' not found.])
|
||||||
|
AC_CHECK_PROG(ART, [art], [art], [no])
|
||||||
|
test "$ART" == "no" && AC_MSG_ERROR([Guile Artanis webserver: 'art' not found.])
|
||||||
|
AC_CHECK_PROG(ELM, [elm], [elm], [no])
|
||||||
|
test "$ELM" == "no" && AC_MSG_ERROR([Elm's compiler: 'elm' not found.])
|
||||||
|
AC_PROG_LN_S
|
||||||
|
|
||||||
|
|
||||||
|
AC_CONFIG_FILES([Makefile
|
||||||
|
backend/Makefile
|
||||||
|
frontend/Makefile])
|
||||||
|
AC_OUTPUT
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
|
||||||
|
all: www/elm.js
|
||||||
|
|
||||||
|
www/elm.js:
|
||||||
|
$(ELM) make src/Main.elm --output=www/elm.js
|
||||||
|
|
||||||
|
install: www/elm.js @public_dir@
|
||||||
|
|
||||||
|
@public_dir@:
|
||||||
|
mkdir @public_dir@
|
||||||
|
cp ./www/ @public_dir@
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
rm -rf @public_dir@
|
||||||
@ -1,79 +1,80 @@
|
|||||||
var ElmLocalStoragePorts = function() {};
|
const ElmLocalStoragePorts = function () {}
|
||||||
|
const localStorage = window.localStorage
|
||||||
|
|
||||||
ElmLocalStoragePorts.prototype.subscribe =
|
ElmLocalStoragePorts.prototype.subscribe =
|
||||||
function(app, getPortName, setPortName, clearPortName, responsePortName, listKeysPortName) {
|
function (app, getPortName, setPortName, clearPortName, responsePortName, listKeysPortName) {
|
||||||
if (!getPortName) getPortName = "getItem";
|
if (!getPortName) getPortName = 'getItem'
|
||||||
if (!setPortName) setPortName = "setItem";
|
if (!setPortName) setPortName = 'setItem'
|
||||||
if (!clearPortName) clearPortName = "clear";
|
if (!clearPortName) clearPortName = 'clear'
|
||||||
if (!listKeysPortName) listKeysPortName = "listKeys";
|
if (!listKeysPortName) listKeysPortName = 'listKeys'
|
||||||
if (!responsePortName) responsePortName = "response";
|
if (!responsePortName) responsePortName = 'response'
|
||||||
|
|
||||||
if (app.ports[responsePortName]) {
|
if (app.ports[responsePortName]) {
|
||||||
var responsePort = app.ports[responsePortName];
|
const responsePort = app.ports[responsePortName]
|
||||||
|
|
||||||
if (app.ports[getPortName]) {
|
if (app.ports[getPortName]) {
|
||||||
app.ports[getPortName].subscribe(function(key) {
|
app.ports[getPortName].subscribe(function (key) {
|
||||||
var val = null;
|
let val = null
|
||||||
try {
|
try {
|
||||||
val = JSON.parse(localStorage.getItem(key))
|
val = JSON.parse(localStorage.getItem(key))
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
responsePort.send({
|
responsePort.send({
|
||||||
key:key,
|
key,
|
||||||
value:val
|
value: val
|
||||||
})
|
})
|
||||||
});
|
})
|
||||||
} else {
|
} else {
|
||||||
console.warn(getPortName + ": This port is not connected.");
|
console.warn(getPortName + ': This port is not connected.')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app.ports[setPortName]) {
|
if (app.ports[setPortName]) {
|
||||||
app.ports[setPortName].subscribe(function(kv) {
|
app.ports[setPortName].subscribe(function (kv) {
|
||||||
var key = kv[0];
|
const key = kv[0]
|
||||||
var json = kv[1];
|
const json = kv[1]
|
||||||
if (json === null) {
|
if (json === null) {
|
||||||
localStorage.removeItem(key);
|
localStorage.removeItem(key)
|
||||||
} else {
|
|
||||||
localStorage.setItem(key, JSON.stringify(json));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
console.warn(setPortName + ": This port is not connected.");
|
localStorage.setItem(key, JSON.stringify(json))
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
console.warn(setPortName + ': This port is not connected.')
|
||||||
|
}
|
||||||
|
|
||||||
if (app.ports[clearPortName]) {
|
if (app.ports[clearPortName]) {
|
||||||
app.ports[clearPortName].subscribe(function(prefix) {
|
app.ports[clearPortName].subscribe(function (prefix) {
|
||||||
if (prefix) {
|
if (prefix) {
|
||||||
var cnt = localStorage.length;
|
const cnt = localStorage.length
|
||||||
for (var i = cnt - 1; i >= 0; --i) {
|
for (let i = cnt - 1; i >= 0; --i) {
|
||||||
var key = localStorage.key(i);
|
const key = localStorage.key(i)
|
||||||
if (key && key.startsWith(prefix)) {
|
if (key && key.startsWith(prefix)) {
|
||||||
localStorage.removeItem(key);
|
localStorage.removeItem(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
localStorage.clear();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
console.warn(clearPortName + ": This port is not connected.");
|
localStorage.clear()
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
console.warn(clearPortName + ': This port is not connected.')
|
||||||
|
}
|
||||||
|
|
||||||
if (app.ports[listKeysPortName]) {
|
if (app.ports[listKeysPortName]) {
|
||||||
app.ports[listKeysPortName].subscribe(function(prefix) {
|
app.ports[listKeysPortName].subscribe(function (prefix) {
|
||||||
var cnt = localStorage.length;
|
const cnt = localStorage.length
|
||||||
var keys = [];
|
const keys = []
|
||||||
for (var i = 0; i < cnt; i++) {
|
for (let i = 0; i < cnt; i++) {
|
||||||
var key = localStorage.key(i);
|
const key = localStorage.key(i)
|
||||||
if (key && key.startsWith(prefix)) {
|
if (key && key.startsWith(prefix)) {
|
||||||
keys.push(key);
|
keys.push(key)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
responsePort.send(keys);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
console.warn(listKeysPortName + ": This port is not connected.");
|
|
||||||
}
|
}
|
||||||
|
responsePort.send(keys)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
console.warn(responsePortName + ": This port is not connected.");
|
console.warn(listKeysPortName + ': This port is not connected.')
|
||||||
}
|
}
|
||||||
};
|
} else {
|
||||||
|
console.warn(responsePortName + ': This port is not connected.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
listen [::]:80;
|
||||||
|
|
||||||
|
server_name @server_name@ www.@server_name@;
|
||||||
|
|
||||||
|
root _PUBLIC_DIR_;
|
||||||
|
try_files $uri $uri/ /not_found;
|
||||||
|
|
||||||
|
location /json/pc {
|
||||||
|
proxy_pass 127.0.0.1:1665/json/pc
|
||||||
|
}
|
||||||
|
|
||||||
|
location /json/hr {
|
||||||
|
proxy_pass 127.0.0.1:1665/json/hr
|
||||||
|
}
|
||||||
|
|
||||||
|
location /json/batch {
|
||||||
|
proxy_pass 127.0.0.1:1665/json/batch
|
||||||
|
}
|
||||||
|
|
||||||
|
location /update {
|
||||||
|
proxy_pass 127.0.0.1:1665/update
|
||||||
|
}
|
||||||
|
|
||||||
|
location /not_found {
|
||||||
|
return 404;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in new issue