From 28446d3ae2c8408c577bcf752b12a8c9707631a2 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Wed, 10 Jul 2024 14:21:23 -0400 Subject: [PATCH] Comments for theme CSS endpoints --- server/homebrew.api.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/homebrew.api.js b/server/homebrew.api.js index b6dd9cec5..07c339d94 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -274,6 +274,7 @@ const api = { res.status(200).send(saved); }, + //Return CSS for a brew theme, with @include endpoint for its parent theme if any (except for Blank and 5ePHB) getBrewThemeCSS : async (req, res)=>{ const brew = req.brew; console.log(`getBrewThemeCSS for ${brew.shareId}`) @@ -287,6 +288,7 @@ const api = { const themeLocationComment = `/* From Brew: ${req.protocol}://${req.get('host')}/share/${req.brew.shareId} */\n\n`; return res.status(200).send(req.brew.renderer == 'legacy' ? '' : `${parentThemeImport}${themeLocationComment}${req.brew.style}`); }, + //Return @include endpoint for a theme's parent theme only getBrewThemeParentCSS : async (req, res)=>{ const brew = req.brew; console.log(`getBrewThemeParentCSS for ${brew.shareId}`) @@ -298,14 +300,15 @@ const api = { const themeLocationComment = `/* From Brew: ${req.protocol}://${req.get('host')}/share/${req.brew.shareId} */\n\n`; return res.status(200).send(req.brew.renderer == 'legacy' ? '' : `${parentThemeImport}${themeLocationComment}`); }, + //Return CSS for a static theme, with @include endpoint for its parent theme if any getStaticThemeCSS : async(req, res)=>{ if (!isStaticTheme(req.params.engine, req.params.id)) res.status(404).send(`Invalid Theme - Renderer: ${req.params.engine}, Name: ${req.params.id}`); else { - const themeParent = Themes[req.params.engine][req.params.id].baseTheme; console.log(`getStaticThemeCSS for ${themeParent}`) res.setHeader('Content-Type', 'text/css'); res.setHeader('Cache-Control', 'public, max-age: 43200, must-revalidate'); + const themeParent = Themes[req.params.engine][req.params.id].baseTheme; const parentTheme = themeParent ? `@import url(\"/css/${req.params.engine}/${themeParent}\");\n/* Static Theme ${Themes[req.params.engine][themeParent].name} */\n` : ''; return res.status(200).send(`${parentTheme}@import url(\"/themes/${req.params.engine}/${req.params.id}/style.css\");\n/* Static Theme ${Themes[req.params.engine][req.params.id].name} */\n`); }