This commit is contained in:
Flummi
2021-04-22 04:12:40 +02:00
parent 97519de05b
commit 4f35261e66
22 changed files with 322 additions and 158 deletions

14
src/inc/routes/theme.mjs Normal file
View File

@ -0,0 +1,14 @@
import router from "../router.mjs";
import cfg from "../../../config.json";
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();
});