Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.11.0 #1265

Merged
merged 26 commits into from
Mar 1, 2021
Merged

v2.11.0 #1265

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e2cd7d9
Legacy renderer (#1184)
calculuschild Feb 3, 2021
de1017a
Legacy renderer (#1229)
calculuschild Feb 5, 2021
2fe3533
Revert accidental color change
calculuschild Feb 5, 2021
c642a35
Fix brew styles overwriting each other. (#1230)
calculuschild Feb 5, 2021
e5ccfa3
Fix /page not working in legacy mode. (#1233)
calculuschild Feb 8, 2021
ee4ecc0
Default 'legacy' if not set. Auto-change styles.
calculuschild Feb 8, 2021
146da57
Apply Legacy\v3 renderer to print page (#1235)
calculuschild Feb 9, 2021
ecae16b
Update robots.txt (#1239)
G-Ambatte Feb 19, 2021
7057422
Enable caching of static assets (#1217)
AlexeySachkov Feb 19, 2021
009a11a
Add QR-Code as snippet under Editor (#539)
bakgaard Feb 20, 2021
468b731
Unify brew structure in all pages
calculuschild Feb 21, 2021
68811eb
Implementing magic item snippet from Issue 671. (#842)
chrisbrickhouse Feb 25, 2021
2942660
Bump codemirror from 5.59.2 to 5.59.4 (#1258)
dependabot-preview[bot] Feb 25, 2021
721511e
Bump query-string from 6.13.8 to 6.14.0 (#1236)
dependabot-preview[bot] Feb 25, 2021
f2d07a6
Bump @babel/preset-env from 7.12.11 to 7.13.5 (#1257)
dependabot-preview[bot] Feb 25, 2021
7daec67
Bump lodash from 4.17.20 to 4.17.21 (#1252)
dependabot-preview[bot] Feb 25, 2021
ff70b5c
Bump mongoose from 5.11.13 to 5.11.18 (#1256)
dependabot-preview[bot] Feb 25, 2021
37d0a4a
Bump googleapis from 67.0.0 to 67.1.0 (#1245)
dependabot-preview[bot] Feb 25, 2021
bc86c1b
Bump eslint from 7.18.0 to 7.20.0 (#1244)
dependabot-preview[bot] Feb 25, 2021
c979f02
Update Marked.js version
calculuschild Feb 26, 2021
03b0266
Bump @babel/preset-react from 7.12.10 to 7.12.13 (#1225)
dependabot-preview[bot] Feb 26, 2021
19a2ecd
Bump @babel/core from 7.12.10 to 7.13.1 (#1254)
dependabot-preview[bot] Feb 26, 2021
1e64e49
Bump nconf from 0.11.1 to 0.11.2 (#1216)
dependabot-preview[bot] Feb 26, 2021
481c9f0
Fix title issue (#1251)
G-Ambatte Feb 26, 2021
9dcce15
Updated extraKeys (bold and italic) and added new shortcut (for span …
RKuerten Mar 1, 2021
5824ab6
Merge branch 'PRODUCTION' into master
calculuschild Mar 1, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
root : true,
parserOptions : {
ecmaVersion : 9,
ecmaVersion : 2021,
sourceType : 'module',
ecmaFeatures : {
jsx : true
Expand Down
38 changes: 20 additions & 18 deletions client/homebrew/editor/editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ const SNIPPETBAR_HEIGHT = 25;
const Editor = createClass({
getDefaultProps : function() {
return {
value : '',
brew : {
text : ''
},
onChange : ()=>{},

metadata : {},
onMetadataChange : ()=>{},
showMetaButton : true,
renderer : 'legacy'
Expand Down Expand Up @@ -59,7 +60,7 @@ const Editor = createClass({
this.cursorPosition = curpos;
},
handleInject : function(injectText){
const lines = this.props.value.split('\n');
const lines = this.props.brew.text.split('\n');
lines[this.cursorPosition.line] = splice(lines[this.cursorPosition.line], this.cursorPosition.ch, injectText);

this.handleTextChange(lines.join('\n'));
Expand All @@ -72,7 +73,7 @@ const Editor = createClass({
},

getCurrentPage : function(){
const lines = this.props.value.split('\n').slice(0, this.cursorPosition.line + 1);
const lines = this.props.brew.text.split('\n').slice(0, this.cursorPosition.line + 1);
return _.reduce(lines, (r, line)=>{
if(line.indexOf('\\page') !== -1) r++;
return r;
Expand All @@ -87,7 +88,7 @@ const Editor = createClass({
const customHighlights = codeMirror.getAllMarks();
for (let i=0;i<customHighlights.length;i++) customHighlights[i].clear();

const lineNumbers = _.reduce(this.props.value.split('\n'), (r, line, lineNumber)=>{
const lineNumbers = _.reduce(this.props.brew.text.split('\n'), (r, line, lineNumber)=>{

//reset custom line styles
codeMirror.removeLineClass(lineNumber, 'background');
Expand All @@ -108,21 +109,14 @@ const Editor = createClass({
r.push(lineNumber);
}

if(line.startsWith('\\column')){
if(line.match(/^\\column$/)){
codeMirror.addLineClass(lineNumber, 'text', 'columnSplit');
r.push(lineNumber);
}

if(line.startsWith('{{') || line.startsWith('}}')){
let endCh = line.length+1;
const match = line.match(/{{(?:[\w,#-]|="[\w, ]*")*\s*|}}/);
if(match)
endCh = match.index+match[0].length;
codeMirror.markText({ line: lineNumber, ch: 0 }, { line: lineNumber, ch: endCh }, { className: 'block' });
}

// Highlight inline spans {{content}}
if(line.includes('{{') && line.includes('}}')){
const regex = /{{(?:[\w,#-]|="[\w, ]*")*\s*|}}/g;
const regex = /{{(?:="[\w,\-. ]*"|[^"'\s])*\s*|}}/g;
let match;
let blockCount = 0;
while ((match = regex.exec(line)) != null) {
Expand All @@ -137,6 +131,14 @@ const Editor = createClass({
}
codeMirror.markText({ line: lineNumber, ch: match.index }, { line: lineNumber, ch: match.index + match[0].length }, { className: 'inline-block' });
}
} else if(line.trimLeft().startsWith('{{') || line.trimLeft().startsWith('}}')){
// Highlight block divs {{\n Content \n}}
let endCh = line.length+1;

const match = line.match(/^ *{{(?:="[\w,\-. ]*"|[^"'\s])*$|^ *}}$/);
if(match)
endCh = match.index+match[0].length;
codeMirror.markText({ line: lineNumber, ch: 0 }, { line: lineNumber, ch: endCh }, { className: 'block' });
}
}

Expand All @@ -159,7 +161,7 @@ const Editor = createClass({
renderMetadataEditor : function(){
if(!this.state.showMetadataEditor) return;
return <MetadataEditor
metadata={this.props.metadata}
metadata={this.props.brew}
onChange={this.props.onMetadataChange}
/>;
},
Expand All @@ -169,7 +171,7 @@ const Editor = createClass({
return (
<div className='editor' ref='main'>
<SnippetBar
brew={this.props.value}
brew={this.props.brew}
onInject={this.handleInject}
onToggle={this.handgleToggle}
showmeta={this.state.showMetadataEditor}
Expand All @@ -180,7 +182,7 @@ const Editor = createClass({
ref='codeEditor'
wrap={true}
language='gfm'
value={this.props.value}
value={this.props.brew.text}
onChange={this.handleTextChange}
onCursorActivity={this.handleCursorActivty} />

Expand Down
4 changes: 2 additions & 2 deletions client/homebrew/editor/metadataEditor/metadataEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const MetadataEditor = createClass({
},

handleDelete : function(){
if(this.props.metadata.authors.length <= 1){
if(this.props.metadata.authors && this.props.metadata.authors.length <= 1){
if(!confirm('Are you sure you want to delete this brew? Because you are the only owner of this brew, the document will be deleted permanently.')) return;
if(!confirm('Are you REALLY sure? You will not be able to recover the document.')) return;
} else {
Expand Down Expand Up @@ -114,7 +114,7 @@ const MetadataEditor = createClass({

renderAuthors : function(){
let text = 'None.';
if(this.props.metadata.authors.length){
if(this.props.metadata.authors && this.props.metadata.authors.length){
text = this.props.metadata.authors.join(', ');
}
return <div className='field authors'>
Expand Down
4 changes: 2 additions & 2 deletions client/homebrew/editor/snippetbar/snippetbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const execute = function(val, brew){
const Snippetbar = createClass({
getDefaultProps : function() {
return {
brew : '',
brew : {},
onInject : ()=>{},
onToggle : ()=>{},
showmeta : false,
Expand Down Expand Up @@ -80,7 +80,7 @@ module.exports = Snippetbar;
const SnippetGroup = createClass({
getDefaultProps : function() {
return {
brew : '',
brew : {},
groupName : '',
icon : 'fas fa-rocket',
snippets : [],
Expand Down
20 changes: 19 additions & 1 deletion client/homebrew/editor/snippetbar/snippets/magic.gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ const spellNames = [
'Ultimate Rite of the Confetti Angel',
'Ultimate Ritual of Mouthwash',
];
const itemNames = [
'Doorknob of Niceness',
'Paper Armor of Folding',
'Mixtape of Sadness',
'Staff of Endless Confetti',
];

module.exports = {

Expand Down Expand Up @@ -87,5 +93,17 @@ module.exports = {
'A *continual flame* can be covered or hidden but not smothered or quenched.',
'\n\n\n'
].join('\n');
},

item : function() {
return [
`#### ${_.sample(itemNames)}`,
`*${_.sample(['Wondrous item', 'Armor', 'Weapon'])}, ${_.sample(['Common', 'Uncommon', 'Rare', 'Very Rare', 'Legendary', 'Artifact'])} (requires attunement)*`,
`:`,
`This knob is pretty nice. When attached to a door, it allows a user to`,
`open that door with the strength of the nearest animal. For example, if`,
`there is a cow nearby, the user will have the "strength of a cow" while`,
`opening this door.`
].join('\n');
}
};
};
22 changes: 20 additions & 2 deletions client/homebrew/editor/snippetbar/snippets/snippets.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,21 @@ module.exports = [
},
{
name : 'Background Image',
icon : 'fas fa-times-circle',
gen : ''
icon : 'fas fa-tree',
gen : `<img src='http://i.imgur.com/hMna6G0.png' ` +
`style='position:absolute; top:50px; right:30px; width:280px'/>`
},
{
name : 'QR Code',
icon : 'fas fa-qrcode',
gen : (brew)=>{
return `<img ` +
`src='https://api.qrserver.com/v1/create-qr-code/?data=` +
`https://homebrewery.naturalcrit.com/share/${brew.shareId}` +
`&amp;size=100x100' ` +
`style='width:100px;mix-blend-mode:multiply'/>`;
}

},
{
name : 'Page Number',
Expand Down Expand Up @@ -130,6 +143,11 @@ module.exports = [
icon : 'fas fa-file-word',
gen : CoverPageGen,
},
{
name : 'Magic Item',
icon : 'fas fa-hat-wizard',
gen : MagicGen.item,
},
]
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const getTOC = (pages)=>{
};

module.exports = function(brew){
const pages = brew.split('\\page');
const pages = brew.text.split('\\page');
const TOC = getTOC(pages);
const markdown = _.reduce(TOC, (r, g1, idx1)=>{
r.push(`- **[${idx1 + 1} ${g1.title}](#p${g1.page})**`);
Expand All @@ -69,4 +69,4 @@ module.exports = function(brew){
##### Table Of Contents
${markdown}
</div>\n`;
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const getTOC = (pages)=>{
};

module.exports = function(brew){
const pages = brew.split('\\page');
const pages = brew.text.split('\\page');
const TOC = getTOC(pages);
const markdown = _.reduce(TOC, (r, g1, idx1)=>{
r.push(`- **[${idx1 + 1} ${g1.title}](#p${g1.page})**`);
Expand Down
3 changes: 1 addition & 2 deletions client/homebrew/pages/editPage/editPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,8 @@ const EditPage = createClass({
<SplitPane onDragFinish={this.handleSplitMove} ref='pane'>
<Editor
ref='editor'
value={this.state.brew.text}
brew={this.state.brew}
onChange={this.handleTextChange}
metadata={this.state.brew}
onMetadataChange={this.handleMetadataChange}
renderer={this.state.brew.renderer}
/>
Expand Down
17 changes: 11 additions & 6 deletions client/homebrew/pages/homePage/homePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const BrewRenderer = require('../../brewRenderer/brewRenderer.jsx');
const HomePage = createClass({
getDefaultProps : function() {
return {
brew : {
text : ''
},
welcomeText : '',
ver : '0.0.0'
};
Expand All @@ -29,13 +32,15 @@ const HomePage = createClass({
},
getInitialState : function() {
return {
text : this.props.welcomeText
brew : {
text : this.props.welcomeText
}
};
},
handleSave : function(){
request.post('/api')
.send({
text : this.state.text
text : this.state.brew.text
})
.end((err, res)=>{
if(err) return;
Expand All @@ -48,7 +53,7 @@ const HomePage = createClass({
},
handleTextChange : function(text){
this.setState({
text : text
brew : { text: text }
});
},
renderNavbar : function(){
Expand All @@ -71,12 +76,12 @@ const HomePage = createClass({

<div className='content'>
<SplitPane onDragFinish={this.handleSplitMove} ref='pane'>
<Editor value={this.state.text} onChange={this.handleTextChange} showMetaButton={false} ref='editor'/>
<BrewRenderer text={this.state.text} />
<Editor brew={this.state.brew} onChange={this.handleTextChange} showMetaButton={false} ref='editor'/>
<BrewRenderer text={this.state.brew.text} />
</SplitPane>
</div>

<div className={cx('floatingSaveButton', { show: this.props.welcomeText != this.state.text })} onClick={this.handleSave}>
<div className={cx('floatingSaveButton', { show: this.props.welcomeText != this.state.brew.text })} onClick={this.handleSave}>
Save current <i className='fas fa-save' />
</div>

Expand Down
Loading