mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-02 15:02:38 +00:00
Small User Brew theme changes.
Move the Static Theme shortcut to getBrewThemeWithCSS to drop an unneeded URL load. Change the comment in the CSS to refer to the shareURL for the theme instead of its name if it is a user theme.
This commit is contained in:
@@ -8,6 +8,7 @@ const Markdown = require('../shared/naturalcrit/markdown.js');
|
|||||||
const yaml = require('js-yaml');
|
const yaml = require('js-yaml');
|
||||||
const asyncHandler = require('express-async-handler');
|
const asyncHandler = require('express-async-handler');
|
||||||
const { nanoid } = require('nanoid');
|
const { nanoid } = require('nanoid');
|
||||||
|
var url = require('url');
|
||||||
|
|
||||||
|
|
||||||
const { DEFAULT_BREW, DEFAULT_BREW_LOAD } = require('./brewDefaults.js');
|
const { DEFAULT_BREW, DEFAULT_BREW_LOAD } = require('./brewDefaults.js');
|
||||||
@@ -282,21 +283,21 @@ const api = {
|
|||||||
const brew = req.brew;
|
const brew = req.brew;
|
||||||
splitTextStyleAndMetadata(brew);
|
splitTextStyleAndMetadata(brew);
|
||||||
res.setHeader('Content-Type', 'text/css');
|
res.setHeader('Content-Type', 'text/css');
|
||||||
const staticTheme = `/css/${req.brew.renderer}/${req.brew.theme}`;
|
const themePath = req.brew.theme[0] != '#' ? `/css/${req.brew.renderer}/${req.brew.theme}` : `/css/${req.brew.theme.slice(1)}`;
|
||||||
const userTheme = `/css/${req.brew.theme.slice(1)}`;
|
// Drop Parent theme if it has already been loaded.
|
||||||
const parentThemeImport = `@import url(\"${req.brew.theme[0] != '#' ? staticTheme : userTheme}\");\n\n/* From Brew: ${req.brew.title}*/\n\n`;
|
// This assumes the continued use of the V3/5ePHB and V3/Blank themes for the app.
|
||||||
return res.status(200).send(`${req.brew.renderer == 'legacy' ? '' : parentThemeImport}${req.brew.style}`);
|
const parentThemeImport = ((req.brew.theme != '5ePHB') && (req.brew.theme != 'Blank')) ? `@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}${req.brew.style}`);
|
||||||
},
|
},
|
||||||
getBrewThemeParent : async (req, res)=>{
|
getBrewThemeParent : async (req, res)=>{
|
||||||
const brew = req.brew;
|
const brew = req.brew;
|
||||||
splitTextStyleAndMetadata(brew);
|
splitTextStyleAndMetadata(brew);
|
||||||
// Test Hard Ignoring 5ePHB and 5eBlank due to being used for editor theming.
|
|
||||||
if((req.brew.theme == '5ePHB') ||(req.brew.theme == 'Blank')) return res.status(200).send('');
|
|
||||||
res.setHeader('Content-Type', 'text/css');
|
res.setHeader('Content-Type', 'text/css');
|
||||||
const staticTheme = `/css/${req.brew.renderer}/${req.brew.theme}`;
|
const themePath = req.brew.theme[0] != '#' ? `/css/${req.brew.renderer}/${req.brew.theme}` : `/css/${req.brew.theme.slice(1)}`;
|
||||||
const userTheme = `/css/${req.brew.theme.slice(1)}`;
|
const parentThemeImport = `@import url(\"${themePath}\");\n\n`;
|
||||||
const parentThemeImport = `@import url(\"${req.brew.theme[0] != '#' ? staticTheme : userTheme}\");\n\n/* From Brew: ${req.brew.title}*/\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}`);
|
return res.status(200).send(req.brew.renderer == 'legacy' ? '' : `${parentThemeImport}{themeLocationComment}`);
|
||||||
},
|
},
|
||||||
getStaticTheme : async(req, res)=>{
|
getStaticTheme : async(req, res)=>{
|
||||||
const themeParent = isStaticTheme(req.params.engine, req.params.id);
|
const themeParent = isStaticTheme(req.params.engine, req.params.id);
|
||||||
|
|||||||
Reference in New Issue
Block a user