mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-27 20:23:08 +00:00
* Legacy renderer (#1184)
* Include two versions of Marked.js
* Include two versions of Marked.js
* Working two different render pipelines
Adds stylesheet "styleLegacy.less"
Adds markdownHandler "markdownLegacy.js"
The BrewRenderer will switch between these and the new pipeline dependent on the "version" prop passed in.
* Mustache-style div blocks
* Legacy snippets & columnbreak
* Codemirror styling for Div Blocks
* Lint
* Codemirror highlights for inline Divs as well
These will turn red `{{class Content}}`
Multi-line divs will turn purple
```
{{class,class2
content
}}
```
No real need for these to be different colors. Just for testing.
* More lint
* Update dependencies.
* Adding Button to switch render pipelines
* Update Marked.js
* Popup alert to refresh page when renderer changed
* Don't compress files in Development (very slow)
* Block DIV or inline Span depending on {{ placement
* \column emits a Div instead of Span
* Allow share page to use new renderer
* {{ divs no longer need empty lines. Spans work in lists.
* Typo
* Typo
* Enforce \page must be at start of line. Code cleanup.
* Inject newlines after/before {{/}} to avoid needing blank lines
* Fixes issues with tables.
* Remove console.log
* Fix spacing issue for Spans
* Move things from Brewrenderer to Markdown
Try to keep all custom text fiddling in one spot.
* Rename variables
* Update Font-Awesome to v5.15. Fix style issues on popups.
* Update {{ Divs/Spans, Fix nested hilighting
* Fixed Spans/divs with no tags or just commas
* Use blacklist for {{ to allow more characters
* Update package-lock.json
* Update all icons to Font-awesome 5
* V3 hidden behind config variable
Add "globalThis.enable_v3 = true" in the console to enable.
* lint
* Legacy renderer (#1229)
* Include two versions of Marked.js
* Include two versions of Marked.js
* Working two different render pipelines
Adds stylesheet "styleLegacy.less"
Adds markdownHandler "markdownLegacy.js"
The BrewRenderer will switch between these and the new pipeline dependent on the "version" prop passed in.
* Mustache-style div blocks
* Legacy snippets & columnbreak
* Codemirror styling for Div Blocks
* Lint
* Codemirror highlights for inline Divs as well
These will turn red `{{class Content}}`
Multi-line divs will turn purple
```
{{class,class2
content
}}
```
No real need for these to be different colors. Just for testing.
* More lint
* Update dependencies.
* Adding Button to switch render pipelines
* Update Marked.js
* Popup alert to refresh page when renderer changed
* Don't compress files in Development (very slow)
* Block DIV or inline Span depending on {{ placement
* \column emits a Div instead of Span
* Allow share page to use new renderer
* {{ divs no longer need empty lines. Spans work in lists.
* Typo
* Typo
* Enforce \page must be at start of line. Code cleanup.
* Inject newlines after/before {{/}} to avoid needing blank lines
* Fixes issues with tables.
* Remove console.log
* Fix spacing issue for Spans
* Move things from Brewrenderer to Markdown
Try to keep all custom text fiddling in one spot.
* Rename variables
* Update Font-Awesome to v5.15. Fix style issues on popups.
* Update {{ Divs/Spans, Fix nested hilighting
* Fixed Spans/divs with no tags or just commas
* Use blacklist for {{ to allow more characters
* Update package-lock.json
* Update all icons to Font-awesome 5
* V3 hidden behind config variable
Add "globalThis.enable_v3 = true" in the console to enable.
* lint
* Give user styles higher priority to still allow overrides
* Apply style priority to *all* user styles
* Change .legacy .v3 to .phb, .phb3
* Revert accidental color change
* Fix brew styles overwriting each other. (#1230)
* Fix /page not working in legacy mode. (#1233)
* Fix brew styles overwriting each other.
* Word wrapping, start fixing spacing on Title letter
* Fix \page in legacy brews when not at line start
* Default 'legacy' if not set. Auto-change styles.
* Fix brew styles overwriting each other.
* Word wrapping, start fixing spacing on Title letter
* Fix \page in legacy brews when not at line start
* Fix Page Padding
* Set 'legacy' as default value if not set in brew saved file.
* Apply Legacy\v3 renderer to print page (#1235)
* Update robots.txt (#1239)
* Enable caching of static assets (#1217)
* Enable caching of static assets
* Remove dependency on mime package
Since we only care about two file extensions at the moment,
there is no need to grab the whole package just to avoid
calling 'endsWith' twice.
* Add QR-Code as snippet under Editor (#539)
* Add snippet for QR-code
* Add snippet for QR-code
* Refactor to expose metadata to snippets
* Lint
Co-authored-by: Rasmus Bækgaard <git@bakgaard.net>
Co-authored-by: Trevor Buckner <calculuschild@gmail.com>
* Unify brew structure in all pages
* Implementing magic item snippet from Issue 671. (#842)
* Implementing magic item snippet from Issue 671.
* Fixes syntax errors. Function moved into existing magic module.
* Implementing magic item snippet from Issue 671.
* Fixes syntax errors. Function moved into existing magic module.
* Magic Item Snippet, <dl>, `:` for blank line
Co-authored-by: Trevor Buckner <calculuschild@gmail.com>
* Bump codemirror from 5.59.2 to 5.59.4 (#1258)
Bumps [codemirror](https://github.com/codemirror/CodeMirror) from 5.59.2 to 5.59.4.
- [Release notes](https://github.com/codemirror/CodeMirror/releases)
- [Changelog](https://github.com/codemirror/CodeMirror/blob/master/CHANGELOG.md)
- [Commits](https://github.com/codemirror/CodeMirror/compare/5.59.2...5.59.4)
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
* Bump query-string from 6.13.8 to 6.14.0 (#1236)
Bumps [query-string](https://github.com/sindresorhus/query-string) from 6.13.8 to 6.14.0.
- [Release notes](https://github.com/sindresorhus/query-string/releases)
- [Commits](https://github.com/sindresorhus/query-string/compare/v6.13.8...v6.14.0)
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
* Bump @babel/preset-env from 7.12.11 to 7.13.5 (#1257)
Bumps [@babel/preset-env](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-env) from 7.12.11 to 7.13.5.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.13.5/packages/babel-preset-env)
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
* Bump lodash from 4.17.20 to 4.17.21 (#1252)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.20 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.20...4.17.21)
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
* Bump mongoose from 5.11.13 to 5.11.18 (#1256)
Bumps [mongoose](https://github.com/Automattic/mongoose) from 5.11.13 to 5.11.18.
- [Release notes](https://github.com/Automattic/mongoose/releases)
- [Changelog](https://github.com/Automattic/mongoose/blob/master/History.md)
- [Commits](https://github.com/Automattic/mongoose/compare/5.11.13...5.11.18)
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
* Bump googleapis from 67.0.0 to 67.1.0 (#1245)
Bumps [googleapis](https://github.com/googleapis/google-api-nodejs-client) from 67.0.0 to 67.1.0.
- [Release notes](https://github.com/googleapis/google-api-nodejs-client/releases)
- [Changelog](https://github.com/googleapis/google-api-nodejs-client/blob/master/CHANGELOG.md)
- [Commits](https://github.com/googleapis/google-api-nodejs-client/compare/v67.0.0...v67.1.0)
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
* Bump eslint from 7.18.0 to 7.20.0 (#1244)
Bumps [eslint](https://github.com/eslint/eslint) from 7.18.0 to 7.20.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v7.18.0...v7.20.0)
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
* Update Marked.js version
* Bump @babel/preset-react from 7.12.10 to 7.12.13 (#1225)
Bumps [@babel/preset-react](https://github.com/babel/babel/tree/HEAD/packages/babel-preset-react) from 7.12.10 to 7.12.13.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.12.13/packages/babel-preset-react)
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
* Bump @babel/core from 7.12.10 to 7.13.1 (#1254)
Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.12.10 to 7.13.1.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.13.1/packages/babel-core)
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
* Bump nconf from 0.11.1 to 0.11.2 (#1216)
Bumps [nconf](https://github.com/flatiron/nconf) from 0.11.1 to 0.11.2.
- [Release notes](https://github.com/flatiron/nconf/releases)
- [Changelog](https://github.com/indexzero/nconf/blob/master/CHANGELOG.md)
- [Commits](https://github.com/flatiron/nconf/compare/v0.11.1...v0.11.2)
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
* Fix title issue (#1251)
* Maximum title length set to 100 characters.
* Reverse unnecessary change that was incorrectly included in previous commit.
* Reduced code change to one addition on a single line.
* Revert "Reduced code change to one addition on a single line."
This reverts commit 2a355cf115.
* Use newer syntax to shorten
Co-authored-by: Trevor Buckner <calculuschild@gmail.com>
* Updated extraKeys (bold and italic) and added new shortcut (for span tags) (#1191)
* Updated extraKeys (bold and italic) and added new shortcut (for span)
* Updated makeSpan shortcut to Ctrl/Cmd-M
* ESLint
* Space after {{ so text appears
Co-authored-by: Trevor Buckner <calculuschild@gmail.com>
Co-authored-by: G.Ambatte <sean@robertson-family.nz>
Co-authored-by: Alexey Sachkov <sachkov2011@gmail.com>
Co-authored-by: Rasmus Bækgaard <rasmus@bakgaard.net>
Co-authored-by: Rasmus Bækgaard <git@bakgaard.net>
Co-authored-by: Christian Brickhouse <chrisbrickhouse@users.noreply.github.com>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Rodrigo Kuerten <30464993+RKuerten@users.noreply.github.com>
221 lines
5.9 KiB
JavaScript
221 lines
5.9 KiB
JavaScript
require('./metadataEditor.less');
|
|
const React = require('react');
|
|
const createClass = require('create-react-class');
|
|
const _ = require('lodash');
|
|
const cx = require('classnames');
|
|
const request = require('superagent');
|
|
|
|
const SYSTEMS = ['5e', '4e', '3.5e', 'Pathfinder'];
|
|
|
|
const MetadataEditor = createClass({
|
|
getDefaultProps : function() {
|
|
return {
|
|
metadata : {
|
|
editId : null,
|
|
title : '',
|
|
description : '',
|
|
tags : '',
|
|
published : false,
|
|
authors : [],
|
|
systems : [],
|
|
renderer : 'legacy'
|
|
},
|
|
onChange : ()=>{}
|
|
};
|
|
},
|
|
|
|
handleFieldChange : function(name, e){
|
|
this.props.onChange(_.merge({}, this.props.metadata, {
|
|
[name] : e.target.value
|
|
}));
|
|
},
|
|
handleSystem : function(system, e){
|
|
if(e.target.checked){
|
|
this.props.metadata.systems.push(system);
|
|
} else {
|
|
this.props.metadata.systems = _.without(this.props.metadata.systems, system);
|
|
}
|
|
this.props.onChange(this.props.metadata);
|
|
},
|
|
handleRenderer : function(renderer, e){
|
|
if(e.target.checked){
|
|
this.props.metadata.renderer = renderer;
|
|
}
|
|
this.props.onChange(this.props.metadata);
|
|
},
|
|
handlePublish : function(val){
|
|
this.props.onChange(_.merge({}, this.props.metadata, {
|
|
published : val
|
|
}));
|
|
},
|
|
|
|
handleDelete : function(){
|
|
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 {
|
|
if(!confirm('Are you sure you want to remove this brew from your collection? This will remove you as an editor, but other owners will still be able to access the document.')) return;
|
|
if(!confirm('Are you REALLY sure? You will lose editor access to this document.')) return;
|
|
}
|
|
|
|
request.delete(`/api/${this.props.metadata.editId}`)
|
|
.send()
|
|
.end(function(err, res){
|
|
window.location.href = '/';
|
|
});
|
|
},
|
|
|
|
getRedditLink : function(){
|
|
const meta = this.props.metadata;
|
|
const title = `${meta.title} [${meta.systems.join(' ')}]`;
|
|
const text = `Hey guys! I've been working on this homebrew. I'd love your feedback. Check it out.
|
|
|
|
**[Homebrewery Link](http://homebrewery.naturalcrit.com/share/${meta.shareId})**`;
|
|
|
|
return `https://www.reddit.com/r/UnearthedArcana/submit?title=${encodeURIComponent(title)}&text=${encodeURIComponent(text)}`;
|
|
},
|
|
|
|
renderSystems : function(){
|
|
return _.map(SYSTEMS, (val)=>{
|
|
return <label key={val}>
|
|
<input
|
|
type='checkbox'
|
|
checked={_.includes(this.props.metadata.systems, val)}
|
|
onChange={(e)=>this.handleSystem(val, e)} />
|
|
{val}
|
|
</label>;
|
|
});
|
|
},
|
|
|
|
renderPublish : function(){
|
|
if(this.props.metadata.published){
|
|
return <button className='unpublish' onClick={()=>this.handlePublish(false)}>
|
|
<i className='fas fa-ban' /> unpublish
|
|
</button>;
|
|
} else {
|
|
return <button className='publish' onClick={()=>this.handlePublish(true)}>
|
|
<i className='fas fa-globe' /> publish
|
|
</button>;
|
|
}
|
|
},
|
|
|
|
renderDelete : function(){
|
|
if(!this.props.metadata.editId) return;
|
|
|
|
return <div className='field delete'>
|
|
<label>delete</label>
|
|
<div className='value'>
|
|
<button className='publish' onClick={this.handleDelete}>
|
|
<i className='fas fa-trash-alt' /> delete brew
|
|
</button>
|
|
</div>
|
|
</div>;
|
|
},
|
|
|
|
renderAuthors : function(){
|
|
let text = 'None.';
|
|
if(this.props.metadata.authors && this.props.metadata.authors.length){
|
|
text = this.props.metadata.authors.join(', ');
|
|
}
|
|
return <div className='field authors'>
|
|
<label>authors</label>
|
|
<div className='value'>
|
|
{text}
|
|
</div>
|
|
</div>;
|
|
},
|
|
|
|
renderShareToReddit : function(){
|
|
if(!this.props.metadata.shareId) return;
|
|
|
|
return <div className='field reddit'>
|
|
<label>reddit</label>
|
|
<div className='value'>
|
|
<a href={this.getRedditLink()} target='_blank' rel='noopener noreferrer'>
|
|
<button className='publish'>
|
|
<i className='fab fa-reddit-alien' /> share to reddit
|
|
</button>
|
|
</a>
|
|
</div>
|
|
</div>;
|
|
},
|
|
|
|
renderRenderOptions : function(){
|
|
if(!global.enable_v3) return;
|
|
|
|
return <div className='field systems'>
|
|
<label>Renderer</label>
|
|
<div className='value'>
|
|
<label key='legacy'>
|
|
<input
|
|
type='radio'
|
|
value = 'legacy'
|
|
name = 'renderer'
|
|
checked={this.props.metadata.renderer === 'legacy'}
|
|
onChange={(e)=>this.handleRenderer('legacy', e)} />
|
|
Legacy
|
|
</label>
|
|
|
|
<label key='V3'>
|
|
<input
|
|
type='radio'
|
|
value = 'V3'
|
|
name = 'renderer'
|
|
checked={this.props.metadata.renderer === 'V3'}
|
|
onChange={(e)=>this.handleRenderer('V3', e)} />
|
|
V3
|
|
</label>
|
|
</div>
|
|
</div>;
|
|
},
|
|
|
|
render : function(){
|
|
return <div className='metadataEditor'>
|
|
<div className='field title'>
|
|
<label>title</label>
|
|
<input type='text' className='value'
|
|
value={this.props.metadata.title}
|
|
onChange={(e)=>this.handleFieldChange('title', e)} />
|
|
</div>
|
|
<div className='field description'>
|
|
<label>description</label>
|
|
<textarea value={this.props.metadata.description} className='value'
|
|
onChange={(e)=>this.handleFieldChange('description', e)} />
|
|
</div>
|
|
{/*}
|
|
<div className='field tags'>
|
|
<label>tags</label>
|
|
<textarea value={this.props.metadata.tags}
|
|
onChange={(e)=>this.handleFieldChange('tags', e)} />
|
|
</div>
|
|
*/}
|
|
|
|
{this.renderAuthors()}
|
|
|
|
<div className='field systems'>
|
|
<label>systems</label>
|
|
<div className='value'>
|
|
{this.renderSystems()}
|
|
</div>
|
|
</div>
|
|
|
|
{this.renderRenderOptions()}
|
|
|
|
<div className='field publish'>
|
|
<label>publish</label>
|
|
<div className='value'>
|
|
{this.renderPublish()}
|
|
<small>Published homebrews will be publicly viewable and searchable (eventually...)</small>
|
|
</div>
|
|
</div>
|
|
|
|
{this.renderShareToReddit()}
|
|
|
|
{this.renderDelete()}
|
|
|
|
</div>;
|
|
}
|
|
});
|
|
|
|
module.exports = MetadataEditor;
|