0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-30 13:12:40 +00:00

Report Theme title with CSS

This adds a comment/field ( depending on endpoint ) that reports the
name of the Brew being used as a theming source.
This commit is contained in:
David Bolack
2024-02-20 16:44:17 -06:00
parent 8e48df5de1
commit e2ef9b8122

View File

@@ -220,8 +220,9 @@ const api = {
req.brew.text = req.brew.text.slice(index + 5); req.brew.text = req.brew.text.slice(index + 5);
} }
return res.status(200).send({ return res.status(200).send({
parent : req.brew.theme, parent : req.brew.theme,
theme : req.brew.style theme : req.brew.style,
themeName : req.brew.title
}); });
}, },
getBrewThemeAsCSS : async (req, res)=>{ getBrewThemeAsCSS : async (req, res)=>{
@@ -241,7 +242,7 @@ const api = {
if(res.hasOwnProperty('set')) { if(res.hasOwnProperty('set')) {
res.set('Content-Type', 'text/css'); res.set('Content-Type', 'text/css');
} }
return res.status(200).send(req.brew.style); return res.status(200).send(`// From Theme: ${req.brew.title}\n\n${req.brew.style}`);
}, },
getBrewThemeWithCSS : async (req, res)=>{ getBrewThemeWithCSS : async (req, res)=>{
req.brew.text = req.brew.text.replaceAll('\r\n', '\n'); req.brew.text = req.brew.text.replaceAll('\r\n', '\n');
@@ -260,7 +261,7 @@ const api = {
if(res.hasOwnProperty('set')) { if(res.hasOwnProperty('set')) {
res.set('Content-Type', 'text/css'); res.set('Content-Type', 'text/css');
} }
const parentThemeImport = `@import /themes/${req.brew.renderer}/${req.brew.theme}/styles.css\n\n`; const parentThemeImport = `// From Theme: ${req.brew.title}\n\n@import /themes/${req.brew.renderer}/${req.brew.theme}/styles.css\n\n`;
return res.status(200).send(`${req.brew.renderer == 'legacy' ? '' : parentThemeImport}${req.brew.style}`); return res.status(200).send(`${req.brew.renderer == 'legacy' ? '' : parentThemeImport}${req.brew.style}`);
}, },
updateBrew : async (req, res)=>{ updateBrew : async (req, res)=>{