From c5cd07a60a1d87be12df0d48e29aaa09cda0d2a2 Mon Sep 17 00:00:00 2001 From: Bingus_Violet Date: Wed, 7 Feb 2024 11:58:26 -0600 Subject: [PATCH] Minify style --- .gitignore | 3 ++- index.js | 20 +++++++++++--------- resources/mainPage.html | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 8aedd51..e01c8f5 100644 --- a/.gitignore +++ b/.gitignore @@ -132,4 +132,5 @@ dist # Violet's Purgatory static/index.html -static/cached \ No newline at end of file +static/cached +static/style.css \ No newline at end of file diff --git a/index.js b/index.js index c997016..6f0cdcf 100644 --- a/index.js +++ b/index.js @@ -31,7 +31,6 @@ function getThumbor() { thumbCount += 1 return thumborInstances[thumbCount % thumborInstances.length] + "unsafe" } -app.use(express.static(staticpath)) app.listen(PORT, () => { console.log("Violet's Purgatory is now listening on port: " + PORT) @@ -444,16 +443,10 @@ lanyard.addEventListener("message", async (res) => { app.get('/', async (req, res) => { var html = await (pageUpdate()) - res.send(minify.minify(html)) + res.send(minify.minify(html).toString('utf-8')) }) -app.get('/style.css', async (req, res) => { - var cssPath = path.join(resourcePath, 'style.css') - var css = fs.readFileSync(cssPath).toString() - css = minify.minify(css) - res.send(css) - console.log(css) -}) +app.use(express.static(staticpath)) app.use((req, res, next) => { res.status(404).send(` @@ -463,6 +456,15 @@ app.use((req, res, next) => { `) }) +function updateCSS() { + var css = fs.readFileSync(path.join(resourcePath, 'style.css')).toString() + + css = minify.minify(css) + fs.writeFileSync(path.join(staticpath, 'style.css'), css) // Will add more in the future +} + +updateCSS() + async function updateCommits() { var codebergResponse = await (await fetch(`https://codeberg.org/Bingus_Violet/Violets-Purgatory/src/branch/${process.env.BRANCH || "origin"}`)).text() var commits = codebergResponse.substring(0, codebergResponse.indexOf("Commits")) diff --git a/resources/mainPage.html b/resources/mainPage.html index 4979cb1..01b4c52 100644 --- a/resources/mainPage.html +++ b/resources/mainPage.html @@ -5,7 +5,7 @@ - + Violet's Purgatory