mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-04 21:12:41 +00:00
Remove getBrewThemeParentCSS
This commit is contained in:
@@ -9,7 +9,7 @@ const yaml = require('js-yaml');
|
|||||||
const app = express();
|
const app = express();
|
||||||
const config = require('./config.js');
|
const config = require('./config.js');
|
||||||
|
|
||||||
const { homebrewApi, getBrew, getBrewThemeCSS, getStaticThemeCSS, getBrewThemeParentCSS } = require('./homebrew.api.js');
|
const { homebrewApi, getBrew, getBrewThemeCSS, getStaticThemeCSS } = require('./homebrew.api.js');
|
||||||
const GoogleActions = require('./googleActions.js');
|
const GoogleActions = require('./googleActions.js');
|
||||||
const serveCompressedStaticAssets = require('./static-assets.mv.js');
|
const serveCompressedStaticAssets = require('./static-assets.mv.js');
|
||||||
const sanitizeFilename = require('sanitize-filename');
|
const sanitizeFilename = require('sanitize-filename');
|
||||||
@@ -81,7 +81,6 @@ app.get('/robots.txt', (req, res)=>{
|
|||||||
|
|
||||||
app.get('/css/:id', asyncHandler(getBrew('theme', false)), asyncHandler(getBrewThemeCSS));
|
app.get('/css/:id', asyncHandler(getBrew('theme', false)), asyncHandler(getBrewThemeCSS));
|
||||||
app.get('/css/:engine/:id/', asyncHandler(getStaticThemeCSS));
|
app.get('/css/:engine/:id/', asyncHandler(getStaticThemeCSS));
|
||||||
app.get('/cssParent/:id', asyncHandler(getBrew('theme', false)), asyncHandler(getBrewThemeParentCSS));
|
|
||||||
|
|
||||||
|
|
||||||
//Home page
|
//Home page
|
||||||
|
|||||||
@@ -274,41 +274,28 @@ const api = {
|
|||||||
|
|
||||||
res.status(200).send(saved);
|
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)
|
//Return CSS for a brew theme, with @include endpoint for its parent theme if any
|
||||||
getBrewThemeCSS : async (req, res)=>{
|
getBrewThemeCSS : async (req, res)=>{
|
||||||
const brew = req.brew;
|
const brew = req.brew;
|
||||||
console.log(`getBrewThemeCSS for ${brew.shareId}`)
|
console.log(`getBrewThemeCSS for ${brew.shareId}`)
|
||||||
splitTextStyleAndMetadata(brew);
|
splitTextStyleAndMetadata(brew);
|
||||||
res.setHeader('Content-Type', 'text/css');
|
res.setHeader('Content-Type', 'text/css');
|
||||||
const themePath = Themes[_.upperFirst(req.brew.renderer)].hasOwnProperty(req.brew.theme) ? `/css/${req.brew.renderer}/${req.brew.theme}` : `/css/${req.brew.theme}`;
|
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.
|
|
||||||
console.log(`and parentThemeImport for ${brew.theme}`)
|
console.log(`and parentThemeImport for ${brew.theme}`)
|
||||||
const parentThemeImport = ((req.brew.theme != '5ePHB') && (req.brew.theme != 'Blank')) ? `@import url(\"${themePath}\");\n\n`:'';
|
const parentThemeImport = `@import url(\"${themePath}\");\n\n`;
|
||||||
const themeLocationComment = `/* From Brew: ${req.protocol}://${req.get('host')}/share/${req.brew.shareId} */\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}`);
|
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}`)
|
|
||||||
splitTextStyleAndMetadata(brew);
|
|
||||||
res.setHeader('Content-Type', 'text/css');
|
|
||||||
console.log(`getBrewThemeParentCSS parent is ${brew.theme}`)
|
|
||||||
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}`);
|
|
||||||
},
|
|
||||||
//Return CSS for a static theme, with @include endpoint for its parent theme if any
|
//Return CSS for a static theme, with @include endpoint for its parent theme if any
|
||||||
getStaticThemeCSS : async(req, res)=>{
|
getStaticThemeCSS : async(req, res)=>{
|
||||||
if (!isStaticTheme(req.params.engine, req.params.id))
|
if (!isStaticTheme(req.params.engine, req.params.id))
|
||||||
res.status(404).send(`Invalid Theme - Renderer: ${req.params.engine}, Name: ${req.params.id}`);
|
res.status(404).send(`Invalid Theme - Renderer: ${req.params.engine}, Name: ${req.params.id}`);
|
||||||
else {
|
else {
|
||||||
console.log(`getStaticThemeCSS for ${themeParent}`)
|
|
||||||
res.setHeader('Content-Type', 'text/css');
|
res.setHeader('Content-Type', 'text/css');
|
||||||
res.setHeader('Cache-Control', 'public, max-age: 43200, must-revalidate');
|
res.setHeader('Cache-Control', 'public, max-age: 43200, must-revalidate');
|
||||||
const themeParent = Themes[req.params.engine][req.params.id].baseTheme;
|
const themeParent = Themes[req.params.engine][req.params.id].baseTheme;
|
||||||
|
console.log(`getStaticThemeCSS for ${req.params.id}`)
|
||||||
|
console.log(`and parentThemeImport for ${themeParent}`)
|
||||||
const parentTheme = themeParent ? `@import url(\"/css/${req.params.engine}/${themeParent}\");\n/* Static Theme ${Themes[req.params.engine][themeParent].name} */\n` : '';
|
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`);
|
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`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user