From 9a96eebdb18e0e9129cb959deb6debc95f95c4f6 Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Fri, 9 Sep 2016 09:36:45 -0400 Subject: [PATCH 01/12] Adding my own markdown-html validator, still needs line numbers though --- client/homebrew/brewRenderer/brewRenderer.jsx | 13 ++++++++++- shared/naturalcrit/markdown.js | 22 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/client/homebrew/brewRenderer/brewRenderer.jsx b/client/homebrew/brewRenderer/brewRenderer.jsx index 34de1f416..61e264fa8 100644 --- a/client/homebrew/brewRenderer/brewRenderer.jsx +++ b/client/homebrew/brewRenderer/brewRenderer.jsx @@ -16,7 +16,9 @@ var BrewRenderer = React.createClass({ return { viewablePageNumber: 0, height : 0, - isMounted : false + isMounted : false, + + errors : [] }; }, totalPages : 0, @@ -80,6 +82,15 @@ var BrewRenderer = React.createClass({ var pages = this.props.text.split('\\page'); this.totalPages = pages.length; + try{ + var temp = Markdown.validate(this.props.text); + + console.log(temp); + }catch(e){ + console.log('ERR', e); + } + + return _.map(pages, (page, index)=>{ if(this.shouldRender(page, index)){ return this.renderPage(page, index); diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index ba64ad7dc..caa6a2307 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -17,5 +17,27 @@ module.exports = { render : (rawText)=>{ return Markdown(rawText, {renderer : renderer}) }, + validate : (rawText)=>{ + var errors = []; + var tokens = Markdown.lexer(rawText); + + _.each(tokens, (token)=>{ + if(token.type === 'paragraph'){ + if(_.startsWith(token.text, '')){ + errors.push({ + err : ' No opening tag', + token : token + }) + } + } + }); + + return errors; + }, marked : Markdown }; From c7ccf6747cf1d59efa8536343c531402fb48bc7b Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Mon, 12 Sep 2016 09:10:36 -0400 Subject: [PATCH 02/12] Updating project version --- changelog.md | 3 +++ shared/naturalcrit/markdown.js | 43 ---------------------------------- 2 files changed, 3 insertions(+), 43 deletions(-) delete mode 100644 shared/naturalcrit/markdown.js diff --git a/changelog.md b/changelog.md index 544cf3896..cbd782e80 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,8 @@ # changelog +### Friday, 09/09/2016 - v2.4.0 +- Adding in a HTML validator that will display warnings whenever you save. This should stop a lot of the issues generated with pages not showing up. + ### Saturday, 20/08/2016 - v2.3.0 - Added in a license file - Updated the welcome text diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js deleted file mode 100644 index caa6a2307..000000000 --- a/shared/naturalcrit/markdown.js +++ /dev/null @@ -1,43 +0,0 @@ -var _ = require('lodash'); -var Markdown = require('marked'); -var renderer = new Markdown.Renderer(); - -//Processes the markdown within an HTML block if it's just a class-wrapper -renderer.html = function (html) { - if(_.startsWith(_.trim(html), '')){ - var openTag = html.substring(0, html.indexOf('>')+1); - html = html.substring(html.indexOf('>')+1); - html = html.substring(0, html.lastIndexOf('')); - return `${openTag} ${Markdown(html)} `; - } - return html; -}; - -module.exports = { - render : (rawText)=>{ - return Markdown(rawText, {renderer : renderer}) - }, - validate : (rawText)=>{ - var errors = []; - var tokens = Markdown.lexer(rawText); - - _.each(tokens, (token)=>{ - if(token.type === 'paragraph'){ - if(_.startsWith(token.text, '')){ - errors.push({ - err : ' No opening tag', - token : token - }) - } - } - }); - - return errors; - }, - marked : Markdown -}; From 9eb26a95f3ce0295fed11189d9d0c4e4f21342c2 Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Mon, 12 Sep 2016 09:35:47 -0400 Subject: [PATCH 03/12] IMproved validator logic --- shared/naturalcrit/markdown.js | 91 ++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 shared/naturalcrit/markdown.js diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js new file mode 100644 index 000000000..6263e6854 --- /dev/null +++ b/shared/naturalcrit/markdown.js @@ -0,0 +1,91 @@ +var _ = require('lodash'); +var Markdown = require('marked'); +var renderer = new Markdown.Renderer(); + +//Processes the markdown within an HTML block if it's just a class-wrapper +renderer.html = function (html) { + if(_.startsWith(_.trim(html), '')){ + var openTag = html.substring(0, html.indexOf('>')+1); + html = html.substring(html.indexOf('>')+1); + html = html.substring(0, html.lastIndexOf('')); + return `${openTag} ${Markdown(html)} `; + } + return html; +}; + +module.exports = { + render : (rawText)=>{ + return Markdown(rawText, {renderer : renderer}) + }, + validate : (rawText)=>{ + var currentLine = 0; + var errors = []; + var tokens = Markdown.lexer(rawText); + + _.each(tokens, (token)=>{ + if(token.type === 'paragraph' || token.type === 'html'){ + + var hasOpen = token.text.indexOf('') !== -1; + + if(hasClose && token.text.length > 6){ + errors.push({ + err : ' Closing tags must be on their own line', + token : token, + line : currentLine + }); + } + else if(hasOpen && !hasClose){ + errors.push({ + err : ' No closing tag', + token : token, + line : currentLine + }); + } + else if(hasClose && !hasOpen){ + errors.push({ + err : ' No opening tag', + token : token, + line : currentLine + }); + } + + + /* + + + if(_.startsWith(token.text, '')){ + //Do a check to make sure it's on it's own line + + errors.push({ + err : ' No opening tag', + token : token, + line : currentLine + }) + } + */ + } + //console.log(token); + }); + + return errors; + }, + marked : Markdown +}; + + +/* Test Cases + + + + + + + +*/ \ No newline at end of file From cd2337ff2cb62a702b8b82f88de03238d81005f6 Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Mon, 12 Sep 2016 09:58:32 -0400 Subject: [PATCH 04/12] Experimenting with validation more --- client/homebrew/brewRenderer/brewRenderer.jsx | 16 +++++ shared/naturalcrit/markdown.js | 60 +++++++------------ 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/client/homebrew/brewRenderer/brewRenderer.jsx b/client/homebrew/brewRenderer/brewRenderer.jsx index 61e264fa8..ecb748ed2 100644 --- a/client/homebrew/brewRenderer/brewRenderer.jsx +++ b/client/homebrew/brewRenderer/brewRenderer.jsx @@ -75,6 +75,20 @@ var BrewRenderer = React.createClass({ }, renderPage : function(pageText, index){ + + var html = Markdown.render(pageText) + + var checkHTML = function(html) { + var doc = document.createElement('div'); + doc.innerHTML = html; + console.log(doc.innerHTML); + return ( doc.innerHTML === html ); + } + + console.log('page', index, checkHTML(html)); + + + return
}, @@ -82,6 +96,8 @@ var BrewRenderer = React.createClass({ var pages = this.props.text.split('\\page'); this.totalPages = pages.length; + + //TESTING VALIDATION try{ var temp = Markdown.validate(this.props.text); diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 6263e6854..dc2d63db5 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -20,59 +20,43 @@ module.exports = { validate : (rawText)=>{ var currentLine = 0; var errors = []; - var tokens = Markdown.lexer(rawText); + var tokens = Markdown.lexer(rawText, {renderer : renderer}); - _.each(tokens, (token)=>{ + return _.filter(_.map(tokens, (token)=>{ if(token.type === 'paragraph' || token.type === 'html'){ var hasOpen = token.text.indexOf('') !== -1; - if(hasClose && token.text.length > 6){ - errors.push({ - err : ' Closing tags must be on their own line', + + if(hasOpen && !hasClose){ + return { + err : 'No closing tag', token : token, line : currentLine - }); + }; } - else if(hasOpen && !hasClose){ - errors.push({ - err : ' No closing tag', + if(hasClose && !hasOpen){ + if(token.text.length > 6){ + return { + err : 'Closing tags must be on their own line', + token : token, + line : currentLine + }; + } + return { + err : 'No opening tag', token : token, line : currentLine - }); - } - else if(hasClose && !hasOpen){ - errors.push({ - err : ' No opening tag', - token : token, - line : currentLine - }); + }; } - - /* - - - if(_.startsWith(token.text, '')){ - //Do a check to make sure it's on it's own line - - errors.push({ - err : ' No opening tag', - token : token, - line : currentLine - }) - } - */ } //console.log(token); - }); + + //currentLine += token.text.split('\n').length + 1; + + })); return errors; }, From c49321d5905c4cfbf5b5afc7027fbfd1d178ca63 Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Wed, 14 Sep 2016 22:32:29 -0400 Subject: [PATCH 05/12] Creating new validator --- package.json | 2 +- shared/naturalcrit/markdown.js | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ce2c4821d..548f282df 100644 --- a/package.json +++ b/package.json @@ -33,4 +33,4 @@ "superagent": "^1.6.1", "vitreum": "^3.2.1" } -} +} \ No newline at end of file diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index dc2d63db5..d4fbe8192 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -17,7 +17,21 @@ module.exports = { render : (rawText)=>{ return Markdown(rawText, {renderer : renderer}) }, - validate : (rawText)=>{ + + validate : (rawText) => { + + var res = xmllint.validateXML({ + xml: rawText, + schema: "String" + }); + + console.log(res); + + + }, + + + validate2 : (rawText)=>{ var currentLine = 0; var errors = []; var tokens = Markdown.lexer(rawText, {renderer : renderer}); From dd1264d2e6eee9e7f545ea630481dd69b47479bb Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Thu, 15 Sep 2016 00:28:41 -0400 Subject: [PATCH 06/12] New html validator is working --- shared/naturalcrit/markdown.js | 114 +++++++++++++--------------- shared/naturalcrit/validate_test.js | 30 ++++++++ 2 files changed, 82 insertions(+), 62 deletions(-) create mode 100644 shared/naturalcrit/validate_test.js diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index d4fbe8192..fb4657f53 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -13,77 +13,67 @@ renderer.html = function (html) { return html; }; + +const tagTypes = ['div', 'span', 'a']; +const tagRegex = new RegExp('(' + + _.map(tagTypes, (type)=>{ + return `\\<${type}|\\`; + }).join('|') + ')', 'g'); + + module.exports = { - render : (rawText)=>{ - return Markdown(rawText, {renderer : renderer}) + marked : Markdown, + render : (rawBrewText)=>{ + return Markdown(rawBrewText, {renderer : renderer}) }, - validate : (rawText) => { - - var res = xmllint.validateXML({ - xml: rawText, - schema: "String" - }); - - console.log(res); - - - }, - - - validate2 : (rawText)=>{ - var currentLine = 0; + validate : (rawBrewText) => { var errors = []; - var tokens = Markdown.lexer(rawText, {renderer : renderer}); + var leftovers = _.reduce(rawBrewText.split('\n'), (acc, line, _lineNumber) => { + var lineNumber = _lineNumber + 1; + var matches = line.match(tagRegex); + if(!matches || !matches.length) return acc; - return _.filter(_.map(tokens, (token)=>{ - if(token.type === 'paragraph' || token.type === 'html'){ - - var hasOpen = token.text.indexOf('') !== -1; - - - if(hasOpen && !hasClose){ - return { - err : 'No closing tag', - token : token, - line : currentLine - }; - } - if(hasClose && !hasOpen){ - if(token.text.length > 6){ - return { - err : 'Closing tags must be on their own line', - token : token, - line : currentLine - }; + _.each(matches, (match)=>{ + _.each(tagTypes, (type)=>{ + if(match == `<${type}`){ + acc.push({ + type : type, + line : lineNumber + }); } - return { - err : 'No opening tag', - token : token, - line : currentLine - }; - } + if(match === ``){ + if(!acc.length){ + errors.push({ + line : lineNumber, + type : type, + err : 'Unmatched closing tag' + }); + }else if(_.last(acc).type == type){ + acc.pop(); + }else{ + errors.push({ + line : _.last(acc).line + ' to ' + lineNumber, + type : type, + err : 'Type mismatch on closing tag' + }); + acc.pop(); + } + } + }); + }); + return acc; + }, []); - } - //console.log(token); - - //currentLine += token.text.split('\n').length + 1; - - })); + _.each(leftovers, (unmatched)=>{ + errors.push({ + line : unmatched.line, + type : unmatched.type, + err : "Unmatched opening tag" + }) + }); return errors; }, - marked : Markdown }; - -/* Test Cases - - - - - - - -*/ \ No newline at end of file diff --git a/shared/naturalcrit/validate_test.js b/shared/naturalcrit/validate_test.js new file mode 100644 index 000000000..60e240040 --- /dev/null +++ b/shared/naturalcrit/validate_test.js @@ -0,0 +1,30 @@ +var test =` + + + + + + + + + +
Hellow !!!
+ + + + + + + +`; + +var markdown = require('./markdown.js'); + +console.log(markdown.validate(test)); \ No newline at end of file From 2a0c06cd3da190669303f8a014bddfc5c9e813a0 Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Thu, 15 Sep 2016 09:07:57 -0400 Subject: [PATCH 07/12] New error bar made --- client/homebrew/brewRenderer/brewRenderer.jsx | 31 ++------ .../brewRenderer/errorBar/errorBar.jsx | 72 +++++++++++++++++++ .../brewRenderer/errorBar/errorBar.less | 56 +++++++++++++++ client/homebrew/pages/newPage/newPage.jsx | 13 ++-- shared/naturalcrit/markdown.js | 9 ++- 5 files changed, 147 insertions(+), 34 deletions(-) create mode 100644 client/homebrew/brewRenderer/errorBar/errorBar.jsx create mode 100644 client/homebrew/brewRenderer/errorBar/errorBar.less diff --git a/client/homebrew/brewRenderer/brewRenderer.jsx b/client/homebrew/brewRenderer/brewRenderer.jsx index ecb748ed2..b81bbb3ba 100644 --- a/client/homebrew/brewRenderer/brewRenderer.jsx +++ b/client/homebrew/brewRenderer/brewRenderer.jsx @@ -3,13 +3,15 @@ var _ = require('lodash'); var cx = require('classnames'); var Markdown = require('naturalcrit/markdown.js'); +var ErrorBar = require('./errorBar/errorBar.jsx'); var PAGE_HEIGHT = 1056 + 30; var BrewRenderer = React.createClass({ getDefaultProps: function() { return { - text : '' + text : '', + errors : [] }; }, getInitialState: function() { @@ -75,20 +77,6 @@ var BrewRenderer = React.createClass({ }, renderPage : function(pageText, index){ - - var html = Markdown.render(pageText) - - var checkHTML = function(html) { - var doc = document.createElement('div'); - doc.innerHTML = html; - console.log(doc.innerHTML); - return ( doc.innerHTML === html ); - } - - console.log('page', index, checkHTML(html)); - - - return
}, @@ -96,17 +84,6 @@ var BrewRenderer = React.createClass({ var pages = this.props.text.split('\\page'); this.totalPages = pages.length; - - //TESTING VALIDATION - try{ - var temp = Markdown.validate(this.props.text); - - console.log(temp); - }catch(e){ - console.log('ERR', e); - } - - return _.map(pages, (page, index)=>{ if(this.shouldRender(page, index)){ return this.renderPage(page, index); @@ -122,6 +99,8 @@ var BrewRenderer = React.createClass({ ref='main' style={{height : this.state.height}}> + +
{this.renderPages()}
diff --git a/client/homebrew/brewRenderer/errorBar/errorBar.jsx b/client/homebrew/brewRenderer/errorBar/errorBar.jsx new file mode 100644 index 000000000..123eaf728 --- /dev/null +++ b/client/homebrew/brewRenderer/errorBar/errorBar.jsx @@ -0,0 +1,72 @@ +var React = require('react'); +var _ = require('lodash'); +var cx = require('classnames'); + +var ErrorBar = React.createClass({ + getDefaultProps: function() { + return { + errors : [] + }; + }, + + hasOpenError : false, + hasCloseError : false, + hasMatchError : false, + + renderErrors : function(){ + this.hasOpenError = false; + this.hasCloseError = false; + this.hasMatchError = false; + + + var errors = _.map(this.props.errors, (err, idx) => { + if(err.id == 'OPEN') this.hasOpenError = true; + if(err.id == 'CLOSE') this.hasCloseError = true; + if(err.id == 'MISMATCH') this.hasMatchError = true; + return
  • + Line {err.line} : {err.text}, '{err.type}' tag +
  • + }); + + return
      {errors}
    + }, + + renderProtip : function(){ + var msg = []; + if(this.hasOpenError){ + msg.push(
    + An unmatched opening tag means there's an opened tag that isn't closed, you need to close a tag, like this {'
    '}. Make sure to match types! +
    ); + } + + if(this.hasCloseError){ + msg.push(
    + An unmatched closing tag means you closed a tag without opening it. Either remove it, you check to where you think you opened it. +
    ); + } + + if(this.hasMatchError){ + msg.push(
    + A type mismatch means you closed a tag, but the last open tag was a different type. +
    ); + } + return
    +

    Protips!

    + {msg} +
    + }, + + render : function(){ + if(!this.props.errors.length) return null; + + return
    + +

    There are HTML errors in your markup

    + {this.renderErrors()} +
    + {this.renderProtip()} +
    + } +}); + +module.exports = ErrorBar; diff --git a/client/homebrew/brewRenderer/errorBar/errorBar.less b/client/homebrew/brewRenderer/errorBar/errorBar.less new file mode 100644 index 000000000..79d2a0ccc --- /dev/null +++ b/client/homebrew/brewRenderer/errorBar/errorBar.less @@ -0,0 +1,56 @@ + +.errorBar{ + position : absolute; + z-index : 10000; + box-sizing : border-box; + width : 100%; + margin-right : 13px; + padding : 20px; + padding-bottom : 10px; + padding-left : 100px; + background-color : @red; + color : white; + i{ + position : absolute; + left : 30px; + opacity : 0.8; + font-size : 3em; + } + h3{ + font-size : 1.1em; + font-weight : 800; + } + ul{ + margin-top : 15px; + font-size : 0.8em; + list-style-position : inside; + list-style-type : disc; + li{ + line-height : 1.6em; + } + } + hr{ + box-sizing : border-box; + height : 2px; + width : 150%; + margin-top : 25px; + margin-bottom : 15px; + margin-left : -100px; + background-color : darken(@red, 8%); + border : none; + } + .protips{ + margin-left : -80px; + font-size : 0.6em; + &>div{ + margin-bottom : 10px; + line-height : 1.2em; + } + h4{ + opacity : 0.8; + font-weight : 800; + line-height : 1.5em; + text-transform : uppercase; + } + } +} \ No newline at end of file diff --git a/client/homebrew/pages/newPage/newPage.jsx b/client/homebrew/pages/newPage/newPage.jsx index d664f88dc..242d2c736 100644 --- a/client/homebrew/pages/newPage/newPage.jsx +++ b/client/homebrew/pages/newPage/newPage.jsx @@ -8,7 +8,7 @@ var Navbar = require('../../navbar/navbar.jsx'); var EditTitle = require('../../navbar/editTitle.navitem.jsx'); var IssueNavItem = require('../../navbar/issue.navitem.jsx'); - +var Markdown = require('naturalcrit/markdown.js'); var SplitPane = require('naturalcrit/splitPane/splitPane.jsx'); var Editor = require('../../editor/editor.jsx'); var BrewRenderer = require('../../brewRenderer/brewRenderer.jsx'); @@ -22,7 +22,8 @@ var NewPage = React.createClass({ ver : '0.0.0', title : '', text: '', - isSaving : false + isSaving : false, + errors : [] }; }, @@ -57,7 +58,8 @@ var NewPage = React.createClass({ handleTextChange : function(text){ this.setState({ - text : text + text : text, + errors : Markdown.validate(text) }); localStorage.setItem(KEY, text); }, @@ -66,6 +68,7 @@ var NewPage = React.createClass({ this.setState({ isSaving : true }); + request.post('/api') .send({ title : this.state.title, @@ -112,13 +115,13 @@ var NewPage = React.createClass({ }, render : function(){ + console.log(this.state.errors); return
    {this.renderNavbar()} -
    - +
    diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index fb4657f53..fcb8d6ef2 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -47,7 +47,8 @@ module.exports = { errors.push({ line : lineNumber, type : type, - err : 'Unmatched closing tag' + text : 'Unmatched closing tag', + id : 'CLOSE' }); }else if(_.last(acc).type == type){ acc.pop(); @@ -55,7 +56,8 @@ module.exports = { errors.push({ line : _.last(acc).line + ' to ' + lineNumber, type : type, - err : 'Type mismatch on closing tag' + text : 'Type mismatch on closing tag', + id : 'MISMATCH' }); acc.pop(); } @@ -69,7 +71,8 @@ module.exports = { errors.push({ line : unmatched.line, type : unmatched.type, - err : "Unmatched opening tag" + text : "Unmatched opening tag", + id : 'OPEN' }) }); From 9f05556bc5283cc95b20299fb5bb34216762ec21 Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Thu, 15 Sep 2016 09:13:42 -0400 Subject: [PATCH 08/12] Error bar added to edit page --- client/homebrew/brewRenderer/errorBar/errorBar.jsx | 1 + client/homebrew/brewRenderer/errorBar/errorBar.less | 4 ++++ client/homebrew/pages/editPage/editPage.jsx | 12 +++++++++--- client/homebrew/pages/newPage/newPage.jsx | 4 ++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/client/homebrew/brewRenderer/errorBar/errorBar.jsx b/client/homebrew/brewRenderer/errorBar/errorBar.jsx index 123eaf728..e9ff189c9 100644 --- a/client/homebrew/brewRenderer/errorBar/errorBar.jsx +++ b/client/homebrew/brewRenderer/errorBar/errorBar.jsx @@ -62,6 +62,7 @@ var ErrorBar = React.createClass({ return

    There are HTML errors in your markup

    + If these aren't fixed your brew will not render properly when you print it to PDF or share it {this.renderErrors()}
    {this.renderProtip()} diff --git a/client/homebrew/brewRenderer/errorBar/errorBar.less b/client/homebrew/brewRenderer/errorBar/errorBar.less index 79d2a0ccc..f3f2dbaae 100644 --- a/client/homebrew/brewRenderer/errorBar/errorBar.less +++ b/client/homebrew/brewRenderer/errorBar/errorBar.less @@ -39,6 +39,10 @@ background-color : darken(@red, 8%); border : none; } + small{ + font-size: 0.6em; + opacity: 0.7; + } .protips{ margin-left : -80px; font-size : 0.6em; diff --git a/client/homebrew/pages/editPage/editPage.jsx b/client/homebrew/pages/editPage/editPage.jsx index 4b923b50f..802c881d5 100644 --- a/client/homebrew/pages/editPage/editPage.jsx +++ b/client/homebrew/pages/editPage/editPage.jsx @@ -17,7 +17,7 @@ var Editor = require('../../editor/editor.jsx'); var BrewRenderer = require('../../brewRenderer/brewRenderer.jsx'); var HijackPrint = require('../hijackPrint.js'); - +var Markdown = require('naturalcrit/markdown.js'); const SAVE_TIMEOUT = 3000; @@ -47,6 +47,7 @@ var EditPage = React.createClass({ isSaving : false, isPending : false, errors : null, + htmlErrors : [], lastUpdated : this.props.brew.updatedAt }; }, @@ -60,6 +61,10 @@ var EditPage = React.createClass({ } }; + this.setState({ + htmlErrors : Markdown.validate(this.state.text) + }) + document.onkeydown = HijackPrint(this.props.brew.shareId); }, componentWillUnmount: function() { @@ -115,7 +120,8 @@ var EditPage = React.createClass({ this.debounceSave.cancel(); this.setState({ isSaving : true, - errors : null + errors : null, + htmlErrors : Markdown.validate(this.state.text) }); request @@ -196,7 +202,7 @@ var EditPage = React.createClass({
    - +
    diff --git a/client/homebrew/pages/newPage/newPage.jsx b/client/homebrew/pages/newPage/newPage.jsx index 242d2c736..e50db1823 100644 --- a/client/homebrew/pages/newPage/newPage.jsx +++ b/client/homebrew/pages/newPage/newPage.jsx @@ -3,12 +3,13 @@ var _ = require('lodash'); var cx = require('classnames'); var request = require("superagent"); +var Markdown = require('naturalcrit/markdown.js'); + var Nav = require('naturalcrit/nav/nav.jsx'); var Navbar = require('../../navbar/navbar.jsx'); var EditTitle = require('../../navbar/editTitle.navitem.jsx'); var IssueNavItem = require('../../navbar/issue.navitem.jsx'); -var Markdown = require('naturalcrit/markdown.js'); var SplitPane = require('naturalcrit/splitPane/splitPane.jsx'); var Editor = require('../../editor/editor.jsx'); var BrewRenderer = require('../../brewRenderer/brewRenderer.jsx'); @@ -115,7 +116,6 @@ var NewPage = React.createClass({ }, render : function(){ - console.log(this.state.errors); return
    {this.renderNavbar()}
    From e576e6d9716c20dc8aca1719059688fcf8be38ba Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Thu, 15 Sep 2016 09:19:10 -0400 Subject: [PATCH 09/12] Added QoL, where if errors are present, we run the checker on text input to give quicker feedback --- client/homebrew/pages/editPage/editPage.jsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/homebrew/pages/editPage/editPage.jsx b/client/homebrew/pages/editPage/editPage.jsx index 802c881d5..de1278dba 100644 --- a/client/homebrew/pages/editPage/editPage.jsx +++ b/client/homebrew/pages/editPage/editPage.jsx @@ -86,9 +86,15 @@ var EditPage = React.createClass({ }, handleTextChange : function(text){ + + //If there are errors, run the validator on everychange to give quick feedback + var htmlErrors = this.state.htmlErrors; + if(htmlErrors.length) htmlErrors = Markdown.validate(text); + this.setState({ text : text, - isPending : true + isPending : true, + htmlErrors : htmlErrors }); (this.hasChanges() ? this.debounceSave() : this.debounceSave.cancel()); From b8effb1ed1b080977ded13874d8e8e97cd8c6708 Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Mon, 7 Nov 2016 18:45:37 -0500 Subject: [PATCH 10/12] Updated todo --- todo.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/todo.md b/todo.md index 266dad93a..55b644646 100644 --- a/todo.md +++ b/todo.md @@ -1,5 +1,14 @@ # The Homebrewery +### v2.4.0 todo +- [] Match style of snippet bar to TPK +- [] Add 'Snippets' tag to bar +- [] Add an FAQ page + - How to add images + - Pages not appearing + - Rendering is weird + - How to print to PDF + ## v2.0.0 todo X make a proper staging environment X make database backups From a439c418ef48edc5dbf6d9fbbabed035dccaffa6 Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Mon, 7 Nov 2016 19:02:43 -0500 Subject: [PATCH 11/12] Updating welcome msg and issue template --- .github/issue_template.md | 21 +++++++++---------- changelog.md | 3 +++ client/homebrew/pages/homePage/welcome_msg.md | 2 +- package.json | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.github/issue_template.md b/.github/issue_template.md index 656278d72..9abe053ce 100644 --- a/.github/issue_template.md +++ b/.github/issue_template.md @@ -1,17 +1,16 @@ -**If you are suggestting a feature or improvement**, delete everything here and just write your idea. -If you are reporting a bug, please fill out the details. If you don't, I will most likely just close the issue asking for more detail. ---- -**Browser Type/Version**: FILL OUT -**Issue Description**: FILL OUT -**Brew code to reproduce**:
    Click to expand code -``` -PUT YOUR BREW CODE HERE -``` -
    +### Additional Details -**Related Images** : IF APPLICABLE +**Share Link** : + +or + +**Brew code to reproduce** :
    Click to expand
    +
    +PASTE BREW CODE HERE
    +
    +
    \ No newline at end of file diff --git a/changelog.md b/changelog.md index cbd782e80..81d24238f 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,8 @@ # changelog +### Monday, 07/11/2016 +- Added final touches to the html validator and updating the rest of the branch + ### Friday, 09/09/2016 - v2.4.0 - Adding in a HTML validator that will display warnings whenever you save. This should stop a lot of the issues generated with pages not showing up. diff --git a/client/homebrew/pages/homePage/welcome_msg.md b/client/homebrew/pages/homePage/welcome_msg.md index 04751e4db..dbe614bd6 100644 --- a/client/homebrew/pages/homePage/welcome_msg.md +++ b/client/homebrew/pages/homePage/welcome_msg.md @@ -80,7 +80,7 @@ ___ ### Images -Images can be included 'inline' with the text using Markdown-style images. However for background images more control is needed. +Images must be hosted online somewhere, like imgur. You use the address to that image to reference it in your brew. Images can be included 'inline' with the text using Markdown-style images. However for background images more control is needed. Background images should be included as HTML-style img tags. Using inline CSS you can precisely position your image where you'd like it to be. I have added both a inflow image snippet and a background image snippet to give you exmaples of how to do it. diff --git a/package.json b/package.json index 548f282df..3bb003cf5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "homebrewery", "description": "Create authentic looking D&D homebrews using only markdown", - "version": "2.3.0", + "version": "2.4.0", "scripts": { "build": "node_modules/.bin/gulp prod", "watch": "node_modules/.bin/gulp", From b671161044368dab8b2811a580400de2c5706a0d Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Mon, 7 Nov 2016 19:10:38 -0500 Subject: [PATCH 12/12] Updating changelog --- changelog.md | 1 + todo.md | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 81d24238f..fd5400322 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,7 @@ ### Monday, 07/11/2016 - Added final touches to the html validator and updating the rest of the branch +- If anyone finds issues with the new HTML validator, please let me know. I hope this will bring a more consistent feel to Homebrewery rendering. ### Friday, 09/09/2016 - v2.4.0 - Adding in a HTML validator that will display warnings whenever you save. This should stop a lot of the issues generated with pages not showing up. diff --git a/todo.md b/todo.md index 55b644646..98a5a1ab0 100644 --- a/todo.md +++ b/todo.md @@ -1,13 +1,16 @@ # The Homebrewery ### v2.4.0 todo -- [] Match style of snippet bar to TPK -- [] Add 'Snippets' tag to bar -- [] Add an FAQ page +- [ ] Match style of snippet bar to TPK +- [ ] Add 'Snippets' tag to bar +- [ ] Add an FAQ page - How to add images - Pages not appearing - Rendering is weird - How to print to PDF +- [ ] Remove ver and each page +- [ ] Use pass-through express routes (like in tpk) + ## v2.0.0 todo X make a proper staging environment