0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-03 14:52:38 +00:00

pull from master and suggested fixes

This commit is contained in:
Víctor Losada Hernández
2024-04-02 14:09:53 +02:00
parent aae574e4e5
commit 8a15172db1
14 changed files with 154 additions and 154 deletions

View File

@@ -211,11 +211,11 @@ const BrewRenderer = (props)=>{
<RenderWarnings /> <RenderWarnings />
<NotificationPopup /> <NotificationPopup />
</div> </div>
<link href={`/themes/${rendererPath}/Blank/style.css`} type="text/css" rel='stylesheet'/> <link href={`/themes/${rendererPath}/Blank/style.css`} type='text/css' rel='stylesheet'/>
{baseThemePath && {baseThemePath &&
<link href={`/themes/${rendererPath}/${baseThemePath}/style.css`} type="text/css" rel='stylesheet'/> <link href={`/themes/${rendererPath}/${baseThemePath}/style.css`} type='text/css' rel='stylesheet'/>
} }
<link href={`/themes/${rendererPath}/${themePath}/style.css`} type="text/css" rel='stylesheet'/> <link href={`/themes/${rendererPath}/${themePath}/style.css`} type='text/css' rel='stylesheet'/>
{/* Apply CSS from Style tab and render pages from Markdown tab */} {/* Apply CSS from Style tab and render pages from Markdown tab */}
{state.isMounted {state.isMounted

View File

@@ -26,8 +26,8 @@ const NotificationPopup = createClass({
<> <>
<li key='psa'> <li key='psa'>
<em>Don't store IMAGES in Google Drive</em><br /> <em>Don't store IMAGES in Google Drive</em><br />
Google Drive is not an image service, and will block images from being used Google Drive is not an image service, and will block images from being used
in brews if they get more views than expected. Google has confirmed they won't fix in brews if they get more views than expected. Google has confirmed they won't fix
this, so we recommend you look for another image hosting service such as imgur, ImgBB or Google Photos. this, so we recommend you look for another image hosting service such as imgur, ImgBB or Google Photos.
</li> </li>

View File

@@ -161,7 +161,7 @@ const Snippetbar = createClass({
onClick={this.props.unfoldCode} > onClick={this.props.unfoldCode} >
<i className='fas fa-expand-alt' /> <i className='fas fa-expand-alt' />
</div> </div>
</> </>;
} }
@@ -181,7 +181,7 @@ const Snippetbar = createClass({
<i className='fas fa-palette' /> <i className='fas fa-palette' />
{this.state.themeSelector && this.renderThemeSelector()} {this.state.themeSelector && this.renderThemeSelector()}
</div> </div>
<div className='divider'></div> <div className='divider'></div>
<div className={cx('text', { selected: this.props.view === 'text' })} <div className={cx('text', { selected: this.props.view === 'text' })}
onClick={()=>this.props.onViewChange('text')}> onClick={()=>this.props.onViewChange('text')}>

View File

@@ -42,7 +42,7 @@ const ErrorNavItem = createClass({
</div> </div>
</Nav.item>; </Nav.item>;
} }
if(status === 412) { if(status === 412) {
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'> return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
Oops! Oops!
@@ -51,7 +51,7 @@ const ErrorNavItem = createClass({
</div> </div>
</Nav.item>; </Nav.item>;
} }
if(HBErrorCode === '04') { if(HBErrorCode === '04') {
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'> return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
Oops! Oops!
@@ -76,10 +76,10 @@ const ErrorNavItem = createClass({
if(response.body?.errors?.[0].reason == 'storageQuotaExceeded') { if(response.body?.errors?.[0].reason == 'storageQuotaExceeded') {
return <Nav.item className='save error' icon='fas fa-exclamation-triangle'> return <Nav.item className='save error' icon='fas fa-exclamation-triangle'>
Oops! Oops!
<div className='errorContainer' onClick={clearError}> <div className='errorContainer' onClick={clearError}>
Can't save because your Google Drive seems to be full! Can't save because your Google Drive seems to be full!
</div> </div>
</Nav.item>; </Nav.item>;
} }
if(response.req.url.match(/^\/api.*Google.*$/m)){ if(response.req.url.match(/^\/api.*Google.*$/m)){

View File

@@ -7,58 +7,58 @@ const BREWKEY = 'homebrewery-new';
const STYLEKEY = 'homebrewery-new-style'; const STYLEKEY = 'homebrewery-new-style';
const METAKEY = 'homebrewery-new-meta'; const METAKEY = 'homebrewery-new-meta';
const NewBrew = () => { const NewBrew = ()=>{
const handleFileChange = (e) => { const handleFileChange = (e)=>{
const file = e.target.files[0]; const file = e.target.files[0];
if (file) { if(file) {
const reader = new FileReader(); const reader = new FileReader();
reader.onload = (e) => { reader.onload = (e)=>{
const fileContent = e.target.result; const fileContent = e.target.result;
const newBrew = { const newBrew = {
text: fileContent, text : fileContent,
style: '' style : ''
}; };
if(fileContent.startsWith('```metadata')) { if(fileContent.startsWith('```metadata')) {
splitTextStyleAndMetadata(newBrew); // Modify newBrew directly splitTextStyleAndMetadata(newBrew); // Modify newBrew directly
localStorage.setItem(BREWKEY, newBrew.text); localStorage.setItem(BREWKEY, newBrew.text);
localStorage.setItem(STYLEKEY, newBrew.style); localStorage.setItem(STYLEKEY, newBrew.style);
localStorage.setItem(METAKEY, JSON.stringify(_.pick(newBrew, ['title', 'description', 'tags', 'systems', 'renderer', 'theme', 'lang']))); localStorage.setItem(METAKEY, JSON.stringify(_.pick(newBrew, ['title', 'description', 'tags', 'systems', 'renderer', 'theme', 'lang'])));
window.location.href = '/new'; window.location.href = '/new';
} else { } else {
alert('This file is invalid, please, enter a valid file'); alert('This file is invalid, please, enter a valid file');
} }
}; };
reader.readAsText(file); reader.readAsText(file);
} }
}; };
return ( return (
<Nav.dropdown> <Nav.dropdown>
<Nav.item <Nav.item
className='new' className='new'
color='purple' color='purple'
icon='fa-solid fa-plus-square'> icon='fa-solid fa-plus-square'>
new new
</Nav.item> </Nav.item>
<Nav.item <Nav.item
className='fromBlank' className='fromBlank'
href='/new' href='/new'
newTab={true} newTab={true}
color='purple' color='purple'
icon='fa-solid fa-file'> icon='fa-solid fa-file'>
from blank from blank
</Nav.item> </Nav.item>
<Nav.item <Nav.item
className='fromFile' className='fromFile'
color='purple' color='purple'
icon='fa-solid fa-upload' icon='fa-solid fa-upload'
onClick={() => { document.getElementById('uploadTxt').click(); }}> onClick={()=>{ document.getElementById('uploadTxt').click(); }}>
<input id="uploadTxt" className='newFromLocal' type="file" onChange={handleFileChange} style={{ display: 'none' }} /> <input id='uploadTxt' className='newFromLocal' type='file' onChange={handleFileChange} style={{ display: 'none' }} />
from file from file
</Nav.item> </Nav.item>
</Nav.dropdown> </Nav.dropdown>
); );
}; };
module.exports = NewBrew; module.exports = NewBrew;

View File

@@ -262,8 +262,8 @@ const ListPage = createClass({
render : function(){ render : function(){
return <div className='listPage sitePage'> return <div className='listPage sitePage'>
{/*<style>@layer V3_5ePHB, bundle;</style>*/} {/*<style>@layer V3_5ePHB, bundle;</style>*/}
<link href='/themes/V3/Blank/style.css' type="text/css" rel='stylesheet'/> <link href='/themes/V3/Blank/style.css' type='text/css' rel='stylesheet'/>
<link href='/themes/V3/5ePHB/style.css' type="text/css" rel='stylesheet'/> <link href='/themes/V3/5ePHB/style.css' type='text/css' rel='stylesheet'/>
{this.props.navItems} {this.props.navItems}
{this.renderSortOptions()} {this.renderSortOptions()}
{this.renderTagsOptions()} {this.renderTagsOptions()}

View File

@@ -34,7 +34,7 @@ const PrintPage = createClass({
style : this.props.brew.style || undefined, style : this.props.brew.style || undefined,
renderer : this.props.brew.renderer || 'legacy', renderer : this.props.brew.renderer || 'legacy',
theme : this.props.brew.theme || '5ePHB', theme : this.props.brew.theme || '5ePHB',
lang : this.props.brew.lang || 'en' lang : this.props.brew.lang || 'en'
} }
}; };
}, },
@@ -52,7 +52,7 @@ const PrintPage = createClass({
style : styleStorage, style : styleStorage,
renderer : metaStorage?.renderer || 'legacy', renderer : metaStorage?.renderer || 'legacy',
theme : metaStorage?.theme || '5ePHB', theme : metaStorage?.theme || '5ePHB',
lang : metaStorage?.lang || 'en' lang : metaStorage?.lang || 'en'
} }
}; };
}); });
@@ -96,11 +96,11 @@ const PrintPage = createClass({
return <div> return <div>
<Meta name='robots' content='noindex, nofollow' /> <Meta name='robots' content='noindex, nofollow' />
<link href={`/themes/${rendererPath}/Blank/style.css`} type="text/css" rel='stylesheet'/> <link href={`/themes/${rendererPath}/Blank/style.css`} type='text/css' rel='stylesheet'/>
{baseThemePath && {baseThemePath &&
<link href={`/themes/${rendererPath}/${baseThemePath}/style.css`} type="text/css" rel='stylesheet'/> <link href={`/themes/${rendererPath}/${baseThemePath}/style.css`} type='text/css' rel='stylesheet'/>
} }
<link href={`/themes/${rendererPath}/${themePath}/style.css`} type="text/css" rel='stylesheet'/> <link href={`/themes/${rendererPath}/${themePath}/style.css`} type='text/css' rel='stylesheet'/>
{/* Apply CSS from Style tab */} {/* Apply CSS from Style tab */}
{this.renderStyle()} {this.renderStyle()}
<div className='pages' ref='pages' lang={this.state.brew.lang}> <div className='pages' ref='pages' lang={this.state.brew.lang}>

View File

@@ -30,7 +30,7 @@ const junkBrewPipeline = [
{ $match : { { $match : {
updatedAt : { $lt: Moment().subtract(30, 'days').toDate() }, updatedAt : { $lt: Moment().subtract(30, 'days').toDate() },
lastViewed : { $lt: Moment().subtract(30, 'days').toDate() } lastViewed : { $lt: Moment().subtract(30, 'days').toDate() }
}}, } },
{ $project: { textBinSize: { $binarySize: '$textBin' } } }, { $project: { textBinSize: { $binarySize: '$textBin' } } },
{ $match: { textBinSize: { $lt: 140 } } }, { $match: { textBinSize: { $lt: 140 } } },
{ $limit: 100 } { $limit: 100 }

View File

@@ -1,22 +1,22 @@
const _ = require('lodash'); const _ = require('lodash');
const yaml = require('js-yaml'); const yaml = require('js-yaml');
const splitTextStyleAndMetadata = (brew) => { const splitTextStyleAndMetadata = (brew)=>{
brew.text = brew.text.replaceAll('\r\n', '\n'); brew.text = brew.text.replaceAll('\r\n', '\n');
if (brew.text.startsWith('```metadata')) { if(brew.text.startsWith('```metadata')) {
const index = brew.text.indexOf('```\n\n'); const index = brew.text.indexOf('```\n\n');
const metadataSection = brew.text.slice(12, index - 1); const metadataSection = brew.text.slice(12, index - 1);
const metadata = yaml.load(metadataSection); const metadata = yaml.load(metadataSection);
Object.assign(brew, _.pick(metadata, ['title', 'description', 'tags', 'systems', 'renderer', 'theme', 'lang'])); Object.assign(brew, _.pick(metadata, ['title', 'description', 'tags', 'systems', 'renderer', 'theme', 'lang']));
brew.text = brew.text.slice(index + 5); brew.text = brew.text.slice(index + 5);
} }
if (brew.text.startsWith('```css')) { if(brew.text.startsWith('```css')) {
const index = brew.text.indexOf('```\n\n'); const index = brew.text.indexOf('```\n\n');
brew.style = brew.text.slice(7, index - 1); brew.style = brew.text.slice(7, index - 1);
brew.text = brew.text.slice(index + 5); brew.text = brew.text.slice(index + 5);
} }
}; };
module.exports = { module.exports = {
splitTextStyleAndMetadata splitTextStyleAndMetadata
}; };

View File

@@ -436,7 +436,7 @@ const CodeEditor = createClass({
render : function(){ render : function(){
return <> return <>
<link href={`../homebrew/cm-themes/${this.props.editorTheme}.css`} type="text/css" rel='stylesheet' /> <link href={`../homebrew/cm-themes/${this.props.editorTheme}.css`} type='text/css' rel='stylesheet' />
<div className='codeEditor' ref='editor' style={this.props.style}/> <div className='codeEditor' ref='editor' style={this.props.style}/>
</>; </>;
} }

View File

@@ -1,47 +1,47 @@
const _ = require("lodash"); const _ = require('lodash');
const quotes = [ const quotes = [
"The sword glinted in the dim light, its edges keen and deadly. As the adventurer reached for it, he couldn't help but feel a surge of excitement mixed with fear. This was no ordinary blade.", 'The sword glinted in the dim light, its edges keen and deadly. As the adventurer reached for it, he couldn\'t help but feel a surge of excitement mixed with fear. This was no ordinary blade.',
"The dragon's roar shook the ground beneath their feet, and the brave knight stood tall, his sword at the ready. He knew that this would be the battle of his life, but he was determined to emerge victorious.", 'The dragon\'s roar shook the ground beneath their feet, and the brave knight stood tall, his sword at the ready. He knew that this would be the battle of his life, but he was determined to emerge victorious.',
"The wizard's laboratory was a sight to behold, filled with bubbling cauldrons, ancient tomes, and strange artifacts from distant lands. As the apprentice gazed around in wonder, she knew that she was about to embark on a journey unlike any other.", 'The wizard\'s laboratory was a sight to behold, filled with bubbling cauldrons, ancient tomes, and strange artifacts from distant lands. As the apprentice gazed around in wonder, she knew that she was about to embark on a journey unlike any other.',
"The tavern was packed with rowdy patrons, their voices raised in song and laughter. The bard took center stage, strumming his lute and launching into a tale of adventure and heroism that had the crowd hanging on his every word.", 'The tavern was packed with rowdy patrons, their voices raised in song and laughter. The bard took center stage, strumming his lute and launching into a tale of adventure and heroism that had the crowd hanging on his every word.',
"The thief crept through the shadows, his eyes scanning the room for any sign of danger. He knew that one false move could mean the difference between success and failure, and he was determined to come out on top.", 'The thief crept through the shadows, his eyes scanning the room for any sign of danger. He knew that one false move could mean the difference between success and failure, and he was determined to come out on top.',
"The elf queen stood atop her castle walls, surveying the kingdom below with a mix of pride and sadness. She knew that the coming war would be brutal, but she was determined to protect her people at all costs.", 'The elf queen stood atop her castle walls, surveying the kingdom below with a mix of pride and sadness. She knew that the coming war would be brutal, but she was determined to protect her people at all costs.',
"The necromancer's tower loomed in the distance, its dark spires piercing the sky. As the adventurers approached, they could feel the chill of death emanating from within", 'The necromancer\'s tower loomed in the distance, its dark spires piercing the sky. As the adventurers approached, they could feel the chill of death emanating from within',
"The ranger moved through the forest like a shadow, his senses attuned to every sound and movement around him. He knew that danger lurked behind every tree, but he was ready for whatever came his way.", 'The ranger moved through the forest like a shadow, his senses attuned to every sound and movement around him. He knew that danger lurked behind every tree, but he was ready for whatever came his way.',
"The paladin knelt before the altar, his hands clasped in prayer. He knew that his faith would be tested in the days ahead, but he was ready to face whatever trials lay in store for him.", 'The paladin knelt before the altar, his hands clasped in prayer. He knew that his faith would be tested in the days ahead, but he was ready to face whatever trials lay in store for him.',
"The druid communed with the spirits of nature, his mind merging with the trees, the animals, and the very earth itself. He knew that his power came with a great responsibility, and he was determined to use it for the greater good.", 'The druid communed with the spirits of nature, his mind merging with the trees, the animals, and the very earth itself. He knew that his power came with a great responsibility, and he was determined to use it for the greater good.',
]; ];
const authors = [ const authors = [
"Unknown", 'Unknown',
"James Wyatt", 'James Wyatt',
"Eolande Blackwood", 'Eolande Blackwood',
"Ragnar Ironheart", 'Ragnar Ironheart',
"Lyra Nightshade", 'Lyra Nightshade',
"Valtorius Darkstar", 'Valtorius Darkstar',
"Isadora Fireheart", 'Isadora Fireheart',
"Theron Shadowbane", 'Theron Shadowbane',
"Lirien Starweaver", 'Lirien Starweaver',
"Drogathar Bonecrusher", 'Drogathar Bonecrusher',
"Kaelen Frostblade", 'Kaelen Frostblade',
]; ];
const books = [ const books = [
"The Blade of Destiny", 'The Blade of Destiny',
"Dragonfire and Steel", 'Dragonfire and Steel',
"The Bard's Tale", 'The Bard\'s Tale',
"Darkness Rising", 'Darkness Rising',
"The Sacred Quest", 'The Sacred Quest',
"Shadows in the Forest", 'Shadows in the Forest',
"The Starweaver Chronicles", 'The Starweaver Chronicles',
"Beneath the Bones", 'Beneath the Bones',
"Moonlit Magic", 'Moonlit Magic',
"Frost and Fury", 'Frost and Fury',
]; ];
module.exports = () => { module.exports = ()=>{
return ` return `
{{quote {{quote
${_.sample(quotes)} ${_.sample(quotes)}

View File

@@ -29,7 +29,7 @@ const getTOC = (pages)=>{
const res = []; const res = [];
_.each(pages, (page, pageNum)=>{ _.each(pages, (page, pageNum)=>{
if(!page.includes("{{frontCover}}") && !page.includes("{{insideCover}}") && !page.includes("{{partCover}}") && !page.includes("{{backCover}}")) { if(!page.includes('{{frontCover}}') && !page.includes('{{insideCover}}') && !page.includes('{{partCover}}') && !page.includes('{{backCover}}')) {
const lines = page.split('\n'); const lines = page.split('\n');
_.each(lines, (line)=>{ _.each(lines, (line)=>{
if(_.startsWith(line, '# ')){ if(_.startsWith(line, '# ')){

View File

@@ -718,7 +718,7 @@
p { p {
font-family: 'Overpass'; font-family: 'Overpass';
font-size: 0.332cm; font-size: 0.332cm;
line-height: 0.5cm; line-height: 0.35cm;
} }
hr + p { hr + p {
margin-top : 0.6cm; margin-top : 0.6cm;

View File

@@ -307,8 +307,8 @@ module.exports = [
/**************** FONTS *************/ /**************** FONTS *************/
{ {
groupName : 'Fonts', groupName : 'Fonts',
icon : 'fas fa-keyboard', icon : 'fas fa-keyboard',
view : 'text', view : 'text',
snippets : [ snippets : [
{ {
name : 'Open Sans', name : 'Open Sans',
@@ -341,59 +341,59 @@ module.exports = [
gen : dedent`{{font-family:MrEavesRemake Dummy Text}}` gen : dedent`{{font-family:MrEavesRemake Dummy Text}}`
}, },
{ {
name: 'Solbera Imitation Remake', name : 'Solbera Imitation Remake',
icon: 'font SolberaImitationRemake', icon : 'font SolberaImitationRemake',
gen: dedent`{{font-family:SolberaImitationRemake Dummy Text}}` gen : dedent`{{font-family:SolberaImitationRemake Dummy Text}}`
}, },
{ {
name: 'Scaly Sans Small Caps Remake', name : 'Scaly Sans Small Caps Remake',
icon: 'font ScalySansSmallCapsRemake', icon : 'font ScalySansSmallCapsRemake',
gen: dedent`{{font-family:ScalySansSmallCapsRemake Dummy Text}}` gen : dedent`{{font-family:ScalySansSmallCapsRemake Dummy Text}}`
}, },
{ {
name: 'Walter Turncoat', name : 'Walter Turncoat',
icon: 'font WalterTurncoat', icon : 'font WalterTurncoat',
gen: dedent`{{font-family:WalterTurncoat Dummy Text}}` gen : dedent`{{font-family:WalterTurncoat Dummy Text}}`
}, },
{ {
name: 'Lato', name : 'Lato',
icon: 'font Lato', icon : 'font Lato',
gen: dedent`{{font-family:Lato Dummy Text}}` gen : dedent`{{font-family:Lato Dummy Text}}`
}, },
{ {
name: 'Courier', name : 'Courier',
icon: 'font Courier', icon : 'font Courier',
gen: dedent`{{font-family:Courier Dummy Text}}` gen : dedent`{{font-family:Courier Dummy Text}}`
}, },
{ {
name: 'Nodesto Caps Condensed', name : 'Nodesto Caps Condensed',
icon: 'font NodestoCapsCondensed', icon : 'font NodestoCapsCondensed',
gen: dedent`{{font-family:NodestoCapsCondensed Dummy Text}}` gen : dedent`{{font-family:NodestoCapsCondensed Dummy Text}}`
}, },
{ {
name: 'Overpass', name : 'Overpass',
icon: 'font Overpass', icon : 'font Overpass',
gen: dedent`{{font-family:Overpass Dummy Text}}` gen : dedent`{{font-family:Overpass Dummy Text}}`
}, },
{ {
name: 'Davek', name : 'Davek',
icon: 'font Davek', icon : 'font Davek',
gen: dedent`{{font-family:Davek Dummy Text}}` gen : dedent`{{font-family:Davek Dummy Text}}`
}, },
{ {
name: 'Iokharic', name : 'Iokharic',
icon: 'font Iokharic', icon : 'font Iokharic',
gen: dedent`{{font-family:Iokharic Dummy Text}}` gen : dedent`{{font-family:Iokharic Dummy Text}}`
}, },
{ {
name: 'Rellanic', name : 'Rellanic',
icon: 'font Rellanic', icon : 'font Rellanic',
gen: dedent`{{font-family:Rellanic Dummy Text}}` gen : dedent`{{font-family:Rellanic Dummy Text}}`
}, },
{ {
name: 'Times New Roman', name : 'Times New Roman',
icon: 'font TimesNewRoman', icon : 'font TimesNewRoman',
gen: dedent`{{font-family:"Times New Roman" Dummy Text}}` gen : dedent`{{font-family:"Times New Roman" Dummy Text}}`
} }
] ]
}, },