0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-06-22 00:38:38 +00:00

Merge pull request #4593 from dbolack-ab/V4_Persistant_Templates

Template class persistence
This commit is contained in:
Víctor Losada Hernández
2026-06-02 16:28:01 +02:00
committed by GitHub
4 changed files with 1380 additions and 1194 deletions
+18 -1
View File
@@ -91,6 +91,7 @@ const BrewPage = (props)=>{
//v=====--------------------< Brew Renderer Component >-------------------=====v// //v=====--------------------< Brew Renderer Component >-------------------=====v//
let renderedPages = []; let renderedPages = [];
let pageTemplates = [];
let rawPages = []; let rawPages = [];
const BrewRenderer = (props)=>{ const BrewRenderer = (props)=>{
@@ -208,6 +209,20 @@ const BrewRenderer = (props)=>{
styles = _.mapKeys(styles, (v, k)=>k.startsWith('--') ? k : _.camelCase(k)); // Convert CSS to camelCase for React styles = _.mapKeys(styles, (v, k)=>k.startsWith('--') ? k : _.camelCase(k)); // Convert CSS to camelCase for React
classes = [classes, injectedTags.classes].join(' ').trim(); classes = [classes, injectedTags.classes].join(' ').trim();
attributes = injectedTags.attributes; attributes = injectedTags.attributes;
if(global.enablev4) {
if (attributes && Object.hasOwn(attributes, 'hbtemplate')) {
pageTemplates[index] = attributes['hbtemplate'];
}
}
}
if(global.enablev4) {
// If we don't have a template for this page, look backwards until one is found or the first page.
if(!pageTemplates[index]) {
for (let i=index;i>=0; i--) {
// If one is found, add the template attribute
if (pageTemplates[i]) attributes['hbtemplate'] = pageTemplates[i];
}
}
} }
pageText = pageText.includes('\n') ? pageText.substring(pageText.indexOf('\n') + 1) : ''; // Remove the \page line pageText = pageText.includes('\n') ? pageText.substring(pageText.indexOf('\n') + 1) : ''; // Remove the \page line
} }
@@ -226,8 +241,10 @@ const BrewRenderer = (props)=>{
if(props.errors && props.errors.length) if(props.errors && props.errors.length)
return renderedPages; return renderedPages;
if(rawPages.length != renderedPages.length) // Re-render all pages when page count changes if(rawPages.length != renderedPages.length) { // Re-render all pages when page count changes
renderedPages.length = 0; renderedPages.length = 0;
pageTemplates.length = 0;
}
// Render currently-edited page first so cross-page effects (variables, links) can propagate out first // Render currently-edited page first so cross-page effects (variables, links) can propagate out first
if(rawPages.length > props.currentEditorCursorPageNum -1) if(rawPages.length > props.currentEditorCursorPageNum -1)
+7 -1
View File
@@ -37,9 +37,15 @@ const Homebrew = (props)=>{
lang : '' lang : ''
}, },
userThemes, userThemes,
brews brews,
enablev4
} = props; } = props;
global.account = account;
global.version = version;
global.config = config;
global.enablev4 = enablev4;
const backgroundObject = ()=>{ const backgroundObject = ()=>{
if(config?.deployment || (config?.local && config?.development)) { if(config?.deployment || (config?.local && config?.development)) {
const bgText = config?.deployment || 'Local'; const bgText = config?.deployment || 'Local';
+2 -1
View File
@@ -7,5 +7,6 @@
"local_environments" : ["docker", "local"], "local_environments" : ["docker", "local"],
"publicUrl" : "https://homebrewery.naturalcrit.com", "publicUrl" : "https://homebrewery.naturalcrit.com",
"hb_images" : null, "hb_images" : null,
"hb_fonts" : null "hb_fonts" : null,
"enablev4" : true
} }
+1353 -1191
View File
File diff suppressed because it is too large Load Diff