mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-10 09:12: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 app = express();
|
||||||
const config = require('./config.js');
|
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 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');
|
||||||
|
|||||||
@@ -238,12 +238,10 @@ const api = {
|
|||||||
getBrewThemeWithCSS : async (req, res)=>{
|
getBrewThemeWithCSS : async (req, res)=>{
|
||||||
const brew = req.brew;
|
const brew = req.brew;
|
||||||
splitTextStyleAndMetadata(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 staticTheme = `/api/css/${req.brew.renderer}/${req.brew.theme}/styles.css`;
|
||||||
const userTheme = `/api/css/${req.brew.theme.slice(1)}`;
|
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}`);
|
return res.status(200).send(`${req.brew.renderer == 'legacy' ? '' : parentThemeImport}${req.brew.style}`);
|
||||||
},
|
},
|
||||||
getStaticTheme : async(req, res)=>{
|
getStaticTheme : async(req, res)=>{
|
||||||
@@ -251,11 +249,10 @@ const api = {
|
|||||||
if(themeParent === undefined){
|
if(themeParent === undefined){
|
||||||
res.status(404).send(`Invalid Theme - Engine: ${req.params.engine}, Name: ${req.params.id}`);
|
res.status(404).send(`Invalid Theme - Engine: ${req.params.engine}, Name: ${req.params.id}`);
|
||||||
} else {
|
} else {
|
||||||
// if(res.hasOwnProperty('set')) {
|
res.setHeader('Content-Type', 'text/css');
|
||||||
// res.set('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` : '';
|
||||||
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/* 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`);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateBrew : async (req, res)=>{
|
updateBrew : async (req, res)=>{
|
||||||
|
|||||||
Reference in New Issue
Block a user