mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-22 18:17:49 +01:00
add /static dir for js files owo
This commit is contained in:
parent
52cebeb965
commit
b0591974c8
1 changed files with 42 additions and 32 deletions
|
@ -24,12 +24,12 @@ module.exports = function (app, config, renderTemplate) {
|
|||
var html_location = "./css/";
|
||||
|
||||
app.get("/privacy", function (req, res) {
|
||||
if ( req.hostname == "poketube.fun" ) {
|
||||
renderTemplate(res, req, "priv.ejs", {
|
||||
if (req.hostname == "poketube.fun") {
|
||||
renderTemplate(res, req, "priv.ejs", {
|
||||
isMobile: req.useragent.isMobile,
|
||||
});
|
||||
});
|
||||
} else {
|
||||
renderTemplate(res, req, "priv-custom.ejs");
|
||||
renderTemplate(res, req, "priv-custom.ejs");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -55,40 +55,50 @@ module.exports = function (app, config, renderTemplate) {
|
|||
app.get("/credits", function (req, res) {
|
||||
renderTemplate(res, req, "want-you-gone.ejs");
|
||||
});
|
||||
|
||||
app.get("/customize", function (req, res) {
|
||||
const tab = req.query.tab;
|
||||
|
||||
renderTemplate(res, req, "custom-css.ejs", {
|
||||
tab,
|
||||
});
|
||||
app.get("/customize", function (req, res) {
|
||||
const tab = req.query.tab;
|
||||
|
||||
renderTemplate(res, req, "custom-css.ejs", {
|
||||
tab,
|
||||
});
|
||||
});
|
||||
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const CleanCSS = require("clean-css");
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const CleanCSS = require("clean-css");
|
||||
|
||||
const cssDir = "./css/";
|
||||
const cssDir = "./css/";
|
||||
|
||||
app.get("/css/:id", (req, res) => {
|
||||
const filePath = path.join(cssDir, req.params.id);
|
||||
if (!fs.existsSync(filePath)) {
|
||||
res.status(404).send("File not found");
|
||||
return;
|
||||
}
|
||||
app.get("/css/:id", (req, res) => {
|
||||
const filePath = path.join(cssDir, req.params.id);
|
||||
if (!fs.existsSync(filePath)) {
|
||||
res.status(404).send("File not found");
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.params.id.endsWith(".css")) {
|
||||
// Minimize the CSS file
|
||||
const css = fs.readFileSync(filePath, "utf8");
|
||||
const minimizedCss = new CleanCSS().minify(css).styles;
|
||||
// Serve the minimized CSS file
|
||||
res.header("Content-Type", "text/css");
|
||||
res.send(minimizedCss);
|
||||
} else {
|
||||
// Serve the original file
|
||||
res.sendFile(req.params.id, { root: html_location });
|
||||
}
|
||||
});
|
||||
if (req.params.id.endsWith(".css")) {
|
||||
// Minimize the CSS file
|
||||
const css = fs.readFileSync(filePath, "utf8");
|
||||
const minimizedCss = new CleanCSS().minify(css).styles;
|
||||
// Serve the minimized CSS file
|
||||
res.header("Content-Type", "text/css");
|
||||
res.send(minimizedCss);
|
||||
} else {
|
||||
// Serve the original file
|
||||
res.sendFile(req.params.id, { root: html_location });
|
||||
}
|
||||
|
||||
if (req.params.id.endsWith(".js")) {
|
||||
res.redirect("/static/" + req.params.id);
|
||||
}
|
||||
});
|
||||
|
||||
app.get("/static/:id", (req, res) => {
|
||||
if (req.params.id.endsWith(".css")) {
|
||||
res.redirect("/css/" + req.params.id);
|
||||
}
|
||||
|
||||
res.sendFile(req.params.id, { root: html_location });
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue