Improve portable themes (#1470)

This commit is contained in:
Tim Wilkinson 2024-09-07 09:40:34 -07:00 committed by GitHub
parent 861e299251
commit 0cb8138250
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 5 deletions

View File

@ -599,18 +599,19 @@ global.handle_request = function(env)
return; return;
} }
const rpath = `${config.application}/resource/${env.PATH_INFO}`;
const gzrpath = `${rpath}.gz`;
const localnode = env.HTTP_HOST === "localnode" || env.HTTP_HOST === "localnode.local.mesh"; const localnode = env.HTTP_HOST === "localnode" || env.HTTP_HOST === "localnode.local.mesh";
const cachecontrol = localnode || !config.resourcehash ? "no-store" : "max-age=604800"; const cachecontrol = localnode || !config.resourcehash ? "no-store" : "max-age=604800";
if (localnode && config.resourcehash) { if (localnode && config.resourcehash && fs.access(gzrpath)) {
const themecss = fs.readlink(`${config.application}/resource/css/theme.version`); const themecss = fs.readlink(`${config.application}/resource/css/theme.version`);
if (env.PATH_INFO !== `/css/theme.${themecss}.css` && index(env.PATH_INFO || "", "/css/theme.") === 0 && uciMethods.get("aredn", "@theme[0]", "portable") === "1") { if (env.PATH_INFO !== `/css/theme.${themecss}.css` && index(env.PATH_INFO, "/css/theme.") === 0 && uciMethods.get("aredn", "@theme[0]", "portable") === "1") {
uhttpd.send(`Status: 302 Found\r\nContent-Type: text/css\r\nCache-Control: no-store\r\nLocation: /a/css/theme.${themecss}.css\r\n\r\n`); uhttpd.send(`Status: 302 Found\r\nContent-Type: text/css\r\nCache-Control: no-store\r\nLocation: /a/css/theme.${themecss}.css\r\n\r\n`);
return; return;
} }
} }
const rpath = `${config.application}/resource/${env.PATH_INFO || "unknown"}`;
const gzrpath = `${rpath}.gz`;
if (fs.access(gzrpath)) { if (fs.access(gzrpath)) {
uhttpd.send("Status: 200 OK\r\nContent-Encoding: gzip\r\n"); uhttpd.send("Status: 200 OK\r\nContent-Encoding: gzip\r\n");
if (substr(rpath, -3) === ".js") { if (substr(rpath, -3) === ".js") {