0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00

Rework detection of user brews to look up themeid in static themes list before assuming is a user brew.

Ended up being a fairly straightforward change. A few ternaries got smooshed or inverted. Passes builtin and local tests. Need to compare on the test instance.
This commit is contained in:
David Bolack
2024-07-08 18:12:58 -05:00
parent ea6595d4d6
commit 656edb07ea
5 changed files with 18 additions and 22 deletions

View File

@@ -89,13 +89,13 @@ const api = {
if(brews) {
for await (const brew of brews) {
userThemes.Brew[`#${brew.shareId}`] = {
userThemes.Brew[brew.shareId] = {
name : brew.title,
renderer : 'V3',
baseTheme : '',
baseSnippets : false,
author : brew.authors[0],
path : `#${brew.shareId}`,
path : brew.shareId,
thumbnail : brew.thumbnail.length > 0 ? brew.thumbnail : '/assets/naturalCritLogoWhite.svg'
};
}
@@ -285,7 +285,7 @@ const api = {
const brew = req.brew;
splitTextStyleAndMetadata(brew);
res.setHeader('Content-Type', 'text/css');
const themePath = req.brew.theme[0] != '#' ? `/css/${req.brew.renderer}/${req.brew.theme}` : `/css/${req.brew.theme.slice(1)}`;
const themePath = themes[_.upperFirst(req.brew.renderer)].hasOwnProperty(req.brew.theme) ? `/css/${req.brew.renderer}/${req.brew.theme}` : `/css/${req.brew.theme}`;
// Drop Parent theme if it has already been loaded.
// This assumes the continued use of the V3/5ePHB and V3/Blank themes for the app.
const parentThemeImport = ((req.brew.theme != '5ePHB') && (req.brew.theme != 'Blank')) ? `@import url(\"${themePath}\");\n\n`:'';
@@ -296,7 +296,7 @@ const api = {
const brew = req.brew;
splitTextStyleAndMetadata(brew);
res.setHeader('Content-Type', 'text/css');
const themePath = req.brew.theme[0] != '#' ? `/css/${req.brew.renderer}/${req.brew.theme}` : `/css/${req.brew.theme.slice(1)}`;
const themePath = themes[_.upperFirst(req.brew.renderer)].hasOwnProperty(req.brew.theme) ? `/css/${req.brew.renderer}/${req.brew.theme}` : `/css/${req.brew.theme}`;
const parentThemeImport = `@import url(\"${themePath}\");\n\n`;
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}`);