From 503bf4b18701984a1df5949c85552b130c19eb3b Mon Sep 17 00:00:00 2001 From: Flummi Date: Tue, 28 Dec 2021 04:07:10 +0100 Subject: [PATCH] readding no js theme compatibility? --- src/inc/routes/theme.mjs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/inc/routes/theme.mjs diff --git a/src/inc/routes/theme.mjs b/src/inc/routes/theme.mjs new file mode 100644 index 0000000..e2b5566 --- /dev/null +++ b/src/inc/routes/theme.mjs @@ -0,0 +1,16 @@ +import cfg from "../config.mjs"; + +export default (router, tpl) => { + router.get(/^\/theme\//, async (req, res) => { + let theme = req.url.split[1] ?? cfg.websrv.themes[0]; + if(!cfg.websrv.themes.includes(theme)) + theme = cfg.websrv.themes[0]; + + return res.writeHead(301, { + "Cache-Control": "no-cache, public", + "Set-Cookie": `theme=${theme}; Path=/`, + "Location": req.headers.referer ?? "/" + }).end(); + }); + return router; +};