mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-28 02:42:39 +00:00
Fix @import loading on Chrome.
This commit is contained in:
@@ -9,7 +9,7 @@ const yaml = require('js-yaml');
|
||||
const app = express();
|
||||
const config = require('./config.js');
|
||||
|
||||
const { homebrewApi, getBrew, getBrewThemeWithCSS, getStaticTheme} = require('./homebrew.api.js');
|
||||
const { homebrewApi, getBrew, getBrewThemeWithCSS, getStaticTheme } = require('./homebrew.api.js');
|
||||
const GoogleActions = require('./googleActions.js');
|
||||
const serveCompressedStaticAssets = require('./static-assets.mv.js');
|
||||
const sanitizeFilename = require('sanitize-filename');
|
||||
|
||||
@@ -238,12 +238,10 @@ const api = {
|
||||
getBrewThemeWithCSS : async (req, res)=>{
|
||||
const brew = req.brew;
|
||||
splitTextStyleAndMetadata(brew);
|
||||
// if(res.hasOwnProperty('set')) {
|
||||
// res.set('Content-Type', 'text/css');
|
||||
// }
|
||||
res.set('Content-Type', 'text/css');
|
||||
const staticTheme = `/api/css/${req.brew.renderer}/${req.brew.theme}/styles.css`;
|
||||
const userTheme = `/api/css/${req.brew.theme.slice(1)}`;
|
||||
const parentThemeImport = `@import url(\"${req.brew.theme[0] != '#' ? staticTheme : userTheme}\");\n\n// From Theme: ${req.brew.title}\n\n`;
|
||||
const parentThemeImport = `@import url(\"${req.brew.theme[0] != '#' ? staticTheme : userTheme}\");\n\n/* From Brew: ${req.brew.title}*/\n\n`;
|
||||
return res.status(200).send(`${req.brew.renderer == 'legacy' ? '' : parentThemeImport}${req.brew.style}`);
|
||||
},
|
||||
getStaticTheme : async(req, res)=>{
|
||||
@@ -251,11 +249,10 @@ const api = {
|
||||
if(themeParent === undefined){
|
||||
res.status(404).send(`Invalid Theme - Engine: ${req.params.engine}, Name: ${req.params.id}`);
|
||||
} else {
|
||||
// if(res.hasOwnProperty('set')) {
|
||||
// res.set('Content-Type', 'text/css');
|
||||
// }
|
||||
const parentTheme = themeParent ? `@import url(\"/css/${req.params.engine}/${themeParent}\");\n` : '';
|
||||
return res.status(200).send(`${parentTheme}@import url(\"/themes/${req.params.engine}/${req.params.id}/style.css\");\n`);
|
||||
res.setHeader('Content-Type', 'text/css');
|
||||
res.setHeader('Cache-Control', 'public, max-age: 43200, must-revalidate');
|
||||
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`);
|
||||
}
|
||||
},
|
||||
updateBrew : async (req, res)=>{
|
||||
|
||||
Reference in New Issue
Block a user