Add Fathom Analytics
This commit is contained in:
parent
2d649ab017
commit
a8dc9c04d0
|
@ -14,6 +14,7 @@ const host = process.env.HOST || "localhost";
|
||||||
const port = parseInt(process.env.PORT || "") || 6119;
|
const port = parseInt(process.env.PORT || "") || 6119;
|
||||||
const tlsPort = parseInt(process.env.TLS_PORT || "") || 6120;
|
const tlsPort = parseInt(process.env.TLS_PORT || "") || 6120;
|
||||||
const useTLS = process.env.TLS ? true : false;
|
const useTLS = process.env.TLS ? true : false;
|
||||||
|
const analyticsEnabled = process.env.ANALYTICS ? true : false;
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
@ -27,7 +28,10 @@ function getQueryParams(req: Request): URLSearchParams {
|
||||||
}
|
}
|
||||||
|
|
||||||
app.get("/", (_, res) => {
|
app.get("/", (_, res) => {
|
||||||
res.render(appRoot.path + "/frontend/pages/index", { langs });
|
res.render(appRoot.path + "/frontend/pages/index", {
|
||||||
|
langs,
|
||||||
|
analyticsEnabled,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
for (const [lang, { aliases }] of Object.entries(langs)) {
|
for (const [lang, { aliases }] of Object.entries(langs)) {
|
||||||
if (aliases) {
|
if (aliases) {
|
||||||
|
@ -46,6 +50,7 @@ app.get("/:lang", (req, res) => {
|
||||||
} else if (langs[lang]) {
|
} else if (langs[lang]) {
|
||||||
res.render(appRoot.path + "/frontend/pages/app", {
|
res.render(appRoot.path + "/frontend/pages/app", {
|
||||||
config: { id: lang, ...langs[lang] },
|
config: { id: lang, ...langs[lang] },
|
||||||
|
analyticsEnabled,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
res.send(`No such language: ${lang}`);
|
res.send(`No such language: ${lang}`);
|
||||||
|
|
|
@ -23,5 +23,8 @@
|
||||||
window.rijuConfig = <%- JSON.stringify(config) %>;
|
window.rijuConfig = <%- JSON.stringify(config) %>;
|
||||||
</script>
|
</script>
|
||||||
<script src="/js/app.js"></script>
|
<script src="/js/app.js"></script>
|
||||||
|
<% if (analyticsEnabled) { %>
|
||||||
|
<script src="https://cdn.usefathom.com/script.js" site="JOBZEHJE" defer></script>
|
||||||
|
<% } %>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -26,5 +26,8 @@
|
||||||
<a href="https://github.com/raxod502/riju">on GitHub</a>.
|
<a href="https://github.com/raxod502/riju">on GitHub</a>.
|
||||||
</i>
|
</i>
|
||||||
</p>
|
</p>
|
||||||
|
<% if (analyticsEnabled) { %>
|
||||||
|
<script src="https://cdn.usefathom.com/script.js" site="JOBZEHJE" defer></script>
|
||||||
|
<% } %>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -6,10 +6,11 @@ set -o pipefail
|
||||||
TLS=1
|
TLS=1
|
||||||
TLS_PRIVATE_KEY="$(base64 /etc/letsencrypt/live/riju.codes/privkey.pem)"
|
TLS_PRIVATE_KEY="$(base64 /etc/letsencrypt/live/riju.codes/privkey.pem)"
|
||||||
TLS_CERTIFICATE="$(base64 /etc/letsencrypt/live/riju.codes/fullchain.pem)"
|
TLS_CERTIFICATE="$(base64 /etc/letsencrypt/live/riju.codes/fullchain.pem)"
|
||||||
|
ANALYTICS=1
|
||||||
|
|
||||||
# Do this separately so that errors in command substitution will crash
|
# Do this separately so that errors in command substitution will crash
|
||||||
# the script.
|
# the script.
|
||||||
export TLS TLS_PRIVATE_KEY TLS_CERTIFICATE
|
export TLS TLS_PRIVATE_KEY TLS_CERTIFICATE ANALYTICS
|
||||||
|
|
||||||
if [[ -t 1 ]]; then
|
if [[ -t 1 ]]; then
|
||||||
it=-it
|
it=-it
|
||||||
|
@ -17,5 +18,5 @@ else
|
||||||
it=
|
it=
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker run ${it} -e TLS -e TLS_PRIVATE_KEY -e TLS_CERTIFICATE \
|
docker run ${it} -e TLS -e TLS_PRIVATE_KEY -e TLS_CERTIFICATE -e ANALYTICS \
|
||||||
--rm -p 0.0.0.0:80:6119 -p 0.0.0.0:443:6120 -h riju riju:prod
|
--rm -p 0.0.0.0:80:6119 -p 0.0.0.0:443:6120 -h riju riju:prod
|
||||||
|
|
Loading…
Reference in New Issue