From 8a7e4417242da5e1ec9cdbc674671c98ea0ec46f Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Sat, 20 Aug 2016 11:43:27 -0400 Subject: [PATCH 01/12] Adding license file and changing welcome message extension --- README.md | 4 ++++ .../{welcome_msg.txt => welcome_msg.md} | 0 license | 21 +++++++++++++++++++ server.js | 2 +- 4 files changed, 26 insertions(+), 1 deletion(-) rename client/homebrew/pages/homePage/{welcome_msg.txt => welcome_msg.md} (100%) create mode 100644 license diff --git a/README.md b/README.md index a71890fb7..7ce76b9d9 100644 --- a/README.md +++ b/README.md @@ -31,3 +31,7 @@ You can use [Docker](https://docs.docker.com) to get up and running with Natural ### changelog You can check out the changelog [here](https://github.com/stolksdorf/homebrewery/blob/master/changelog.md) + +### license + +This project licensed under [MIT](./license) \ No newline at end of file diff --git a/client/homebrew/pages/homePage/welcome_msg.txt b/client/homebrew/pages/homePage/welcome_msg.md similarity index 100% rename from client/homebrew/pages/homePage/welcome_msg.txt rename to client/homebrew/pages/homePage/welcome_msg.md diff --git a/license b/license new file mode 100644 index 000000000..ca2c4162c --- /dev/null +++ b/license @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 Scott Tolksdorf + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/server.js b/server.js index 7382e411a..a8b9c88f7 100644 --- a/server.js +++ b/server.js @@ -150,7 +150,7 @@ app.get('/source/:id', function(req, res){ }); //Home and 404, etc. -var welcomeText = require('fs').readFileSync('./client/homebrew/pages/homePage/welcome_msg.txt', 'utf8'); +var welcomeText = require('fs').readFileSync('./client/homebrew/pages/homePage/welcome_msg.md', 'utf8'); var changelogText = require('fs').readFileSync('./changelog.md', 'utf8'); app.get('*', function (req, res) { vitreumRender({ From cd454e82ef37e77117fbc0e61a4fbd889cde03bc Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Sat, 20 Aug 2016 11:50:22 -0400 Subject: [PATCH 02/12] Updating the homepage a bit --- client/homebrew/pages/homePage/welcome_msg.md | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/client/homebrew/pages/homePage/welcome_msg.md b/client/homebrew/pages/homePage/welcome_msg.md index ac27ba49c..04751e4db 100644 --- a/client/homebrew/pages/homePage/welcome_msg.md +++ b/client/homebrew/pages/homePage/welcome_msg.md @@ -18,8 +18,6 @@ Like this tool? Want to buy me a beer? [Head here](https://www.patreon.com/stolk This tool will **always** be free, never have ads, and I will never offer any "premium" features or whatever. -### Bugs, Issues, Suggestions? -Have an idea of how to make The Homebrewery better? Or did you find something that wasn't quite right? Head [here](https://github.com/stolksdorf/homebrewery/issues/new) and let me know!. >##### PDF Exporting @@ -38,25 +36,19 @@ Have an idea of how to make The Homebrewery better? Or did you find something th ``` ``` -## New Things in v2.2.0! +## New Things All The Time! What's new in the latest update? Check out the full changelog [here](/changelog) -* **New Subdomain** I moved The Homebrewery to it's own subdomain. This will make it easier to build and deploy more tools in the future. - - -## V2 Overhaul -A lot of has been put into version 2 of The Homebrewery. Here are the highlights: - -* **A whole new look** The site has been re-built from the ground up! -* **Better editor and split pane** Syntax highlighting will make writing your brews even easier, and now you can customize how large your editor is. -* **More reliable rendering** Lots of work has been put into making the rendering more reliable, not just for web, but also for PDFs -* **PDF Printing on Chrome** You don't need to use Chrome Canary anymore! -* ** Performance Improvements** The site should load faster, save faster, and render large brews *much* faster. -* **Patreon page** If you like this tool and want to show some thanks you can [head here](https://www.patreon.com/stolksdorf). - +### Bugs, Issues, Suggestions? +Have an idea of how to make The Homebrewery better? Or did you find something that wasn't quite right? Head [here](https://github.com/stolksdorf/homebrewery/issues/new) and let me know!. +### Legal Junk +The Homebrewery is licensed using the [MIT License](https://github.com/stolksdorf/homebrewery/blob/master/license). Which means you are free to use The Homebrewery is any way that you want, except for claiming that you made it yourself. +If you wish to sell or in some way gain profit for what's created on this site, it's your responsibility to ensure you have the proper licenses/rights for any images or resources used. +### More Resources +If you are looking for more 5e Homebrew resources check out [r/UnearthedArcana](https://www.reddit.com/r/UnearthedArcana/) and their list of useful resources [here](https://www.reddit.com/r/UnearthedArcana/comments/3uwxx9/resources_open_to_the_community/). @@ -83,18 +75,17 @@ ___ +``` +``` + + ### Images 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. -``` -``` -### Legal Junk -You are free to use The Homebrewery is any way that you want, except for claiming that you made it yourself. If you wish to sell or in some way gain profit for what's created on this site, it's your responsibility to ensure you have the proper licenses/rights for any images or resources used. - ### Crediting Me If you'd like to credit The Homebrewery in your brew, I'd be flattered! Just reference that you made it with The Homebrewery. From 62d70022e7a1560d4f0b3cb51513d9c20af06c90 Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Sat, 20 Aug 2016 12:02:48 -0400 Subject: [PATCH 03/12] Package version is now loaded into the navbar --- changelog.md | 4 +++ client/homebrew/homebrew.jsx | 35 ++++++++++++------- client/homebrew/navbar/navbar.jsx | 5 +-- client/homebrew/pages/editPage/editPage.jsx | 3 +- client/homebrew/pages/homePage/homePage.jsx | 5 +-- client/homebrew/pages/newPage/newPage.jsx | 3 +- client/homebrew/pages/sharePage/sharePage.jsx | 3 +- package.json | 2 +- server.js | 16 ++++++--- 9 files changed, 51 insertions(+), 25 deletions(-) diff --git a/changelog.md b/changelog.md index f071e4e35..df7e68ec3 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ # changelog +### Saturday, 20/08/2016 - v2.3.0 +- Added in a license file +- Updated the welcome text + ### Friday, 29/07/2016 - v2.2.7 - Adding in descriptive note blocks. (Thanks calculuschild!) diff --git a/client/homebrew/homebrew.jsx b/client/homebrew/homebrew.jsx index 8e5172039..f5e92ee1d 100644 --- a/client/homebrew/homebrew.jsx +++ b/client/homebrew/homebrew.jsx @@ -13,9 +13,10 @@ var Router; var Homebrew = React.createClass({ getDefaultProps: function() { return { - url : "", - welcomeText : "", - changelog : "", + url : '', + welcomeText : '', + changelog : '', + version : '0.0.0', brew : { title : '', text : '', @@ -29,27 +30,35 @@ var Homebrew = React.createClass({ componentWillMount: function() { Router = CreateRouter({ '/edit/:id' : (args) => { - return + return }, '/share/:id' : (args) => { - return + return }, '/changelog' : (args) => { - return + return }, '/new' : (args) => { - return + return }, - '*' : , + '*' : , }); }, render : function(){ - return( -
- -
- ); + return
+ +
} }); diff --git a/client/homebrew/navbar/navbar.jsx b/client/homebrew/navbar/navbar.jsx index 7c822061b..7ba89a08a 100644 --- a/client/homebrew/navbar/navbar.jsx +++ b/client/homebrew/navbar/navbar.jsx @@ -6,7 +6,8 @@ var Nav = require('naturalcrit/nav/nav.jsx'); var Navbar = React.createClass({ getInitialState: function() { return { - showNonChromeWarning : false + showNonChromeWarning : false, + ver : '0.0.0' }; }, @@ -34,7 +35,7 @@ var Navbar = React.createClass({
The Homebrewery
- v2.2.8 + {`v${this.props.ver}`} {this.renderChromeWarning()} diff --git a/client/homebrew/pages/editPage/editPage.jsx b/client/homebrew/pages/editPage/editPage.jsx index 5c6bda695..4b923b50f 100644 --- a/client/homebrew/pages/editPage/editPage.jsx +++ b/client/homebrew/pages/editPage/editPage.jsx @@ -27,6 +27,7 @@ const SAVE_TIMEOUT = 3000; var EditPage = React.createClass({ getDefaultProps: function() { return { + ver : '0.0.0', id : null, brew : { title : '', @@ -170,7 +171,7 @@ var EditPage = React.createClass({ } }, renderNavbar : function(){ - return + return diff --git a/client/homebrew/pages/homePage/homePage.jsx b/client/homebrew/pages/homePage/homePage.jsx index 6023d4382..7e3a7031d 100644 --- a/client/homebrew/pages/homePage/homePage.jsx +++ b/client/homebrew/pages/homePage/homePage.jsx @@ -19,7 +19,8 @@ var BrewRenderer = require('../../brewRenderer/brewRenderer.jsx'); var HomePage = React.createClass({ getDefaultProps: function() { return { - welcomeText : "" + welcomeText : '', + ver : '0.0.0' }; }, getInitialState: function() { @@ -48,7 +49,7 @@ var HomePage = React.createClass({ }); }, renderNavbar : function(){ - return + return diff --git a/client/homebrew/pages/newPage/newPage.jsx b/client/homebrew/pages/newPage/newPage.jsx index 448c70cbf..eeb74ffd7 100644 --- a/client/homebrew/pages/newPage/newPage.jsx +++ b/client/homebrew/pages/newPage/newPage.jsx @@ -19,6 +19,7 @@ const KEY = 'homebrewery-new'; var NewPage = React.createClass({ getInitialState: function() { return { + ver : '0.0.0', title : 'My Awesome Brew v99', text: '', isSaving : false @@ -98,7 +99,7 @@ var NewPage = React.createClass({ }, renderNavbar : function(){ - return + return diff --git a/client/homebrew/pages/sharePage/sharePage.jsx b/client/homebrew/pages/sharePage/sharePage.jsx index aa9c86044..ebe2f54d0 100644 --- a/client/homebrew/pages/sharePage/sharePage.jsx +++ b/client/homebrew/pages/sharePage/sharePage.jsx @@ -14,6 +14,7 @@ var HijackPrint = require('../hijackPrint.js'); var SharePage = React.createClass({ getDefaultProps: function() { return { + ver : '0.0.0', brew : { title : '', text : '', @@ -34,7 +35,7 @@ var SharePage = React.createClass({ render : function(){ return
- + {this.props.brew.title} diff --git a/package.json b/package.json index 55a06fdfd..98be04952 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.2.8", + "version": "2.3.0", "scripts": { "postinstall": "gulp prod", "start": "node server.js" diff --git a/server.js b/server.js index a8b9c88f7..47dd148e1 100644 --- a/server.js +++ b/server.js @@ -43,7 +43,7 @@ app.get('/admin', function(req, res){ //Populate homebrew routes app = require('./server/homebrew.api.js')(app); -//app = require('./server/homebrew.server.js')(app); + var HomebrewModel = require('./server/homebrew.model.js').model; @@ -53,6 +53,11 @@ var sanitizeBrew = function(brew){ return cleanBrew; }; +//Load project version +var projectVersion = require('./package.json').version; + +console.log(projectVersion); + //Edit Page app.get('/edit/:id', function(req, res){ @@ -71,7 +76,8 @@ app.get('/edit/:id', function(req, res){ prerenderWith : './client/homebrew/homebrew.jsx', initialProps: { url: req.originalUrl, - brew : resObj || errObj + brew : resObj || errObj, + version : projectVersion }, clearRequireCache : !process.env.PRODUCTION, }, function (err, page) { @@ -102,7 +108,8 @@ app.get('/share/:id', function(req, res){ prerenderWith : './client/homebrew/homebrew.jsx', initialProps: { url: req.originalUrl, - brew : sanitizeBrew(resObj.toJSON() || errObj) + brew : sanitizeBrew(resObj.toJSON() || errObj), + version : projectVersion }, clearRequireCache : !process.env.PRODUCTION, }, function (err, page) { @@ -160,7 +167,8 @@ app.get('*', function (req, res) { initialProps: { url: req.originalUrl, welcomeText : welcomeText, - changelog : changelogText + changelog : changelogText, + version : projectVersion }, clearRequireCache : !process.env.PRODUCTION, }, function (err, page) { From 6b337b5d699b0b1582cec63d048e5fda9ce937bc Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Sat, 20 Aug 2016 12:23:24 -0400 Subject: [PATCH 04/12] Added in a much better error page --- changelog.md | 2 + client/homebrew/homebrew.jsx | 9 ++++ client/homebrew/pages/editPage/editPage.jsx | 3 ++ client/homebrew/pages/errorPage/errorPage.jsx | 46 +++++++++++++++++++ .../homebrew/pages/errorPage/errorPage.less | 5 ++ server.js | 26 +++++------ 6 files changed, 76 insertions(+), 15 deletions(-) create mode 100644 client/homebrew/pages/errorPage/errorPage.jsx create mode 100644 client/homebrew/pages/errorPage/errorPage.less diff --git a/changelog.md b/changelog.md index df7e68ec3..d8b02ab38 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,8 @@ ### Saturday, 20/08/2016 - v2.3.0 - Added in a license file - Updated the welcome text +- Added in a much better Error page + ### Friday, 29/07/2016 - v2.2.7 - Adding in descriptive note blocks. (Thanks calculuschild!) diff --git a/client/homebrew/homebrew.jsx b/client/homebrew/homebrew.jsx index f5e92ee1d..ae711cda9 100644 --- a/client/homebrew/homebrew.jsx +++ b/client/homebrew/homebrew.jsx @@ -8,6 +8,7 @@ var HomePage = require('./pages/homePage/homePage.jsx'); var EditPage = require('./pages/editPage/editPage.jsx'); var SharePage = require('./pages/sharePage/sharePage.jsx'); var NewPage = require('./pages/newPage/newPage.jsx'); +var ErrorPage = require('./pages/errorPage/errorPage.jsx'); var Router; var Homebrew = React.createClass({ @@ -30,6 +31,10 @@ var Homebrew = React.createClass({ componentWillMount: function() { Router = CreateRouter({ '/edit/:id' : (args) => { + if(!this.props.brew.editId){ + return + } + return { + if(!this.props.brew.shareId){ + return + } + return { if(this.state.isSaving || this.state.isPending){ diff --git a/client/homebrew/pages/errorPage/errorPage.jsx b/client/homebrew/pages/errorPage/errorPage.jsx new file mode 100644 index 000000000..2f02951f9 --- /dev/null +++ b/client/homebrew/pages/errorPage/errorPage.jsx @@ -0,0 +1,46 @@ +var React = require('react'); +var _ = require('lodash'); +var cx = require('classnames'); + +var Nav = require('naturalcrit/nav/nav.jsx'); +var Navbar = require('../../navbar/navbar.jsx'); +var PatreonNavItem = require('../../navbar/patreon.navitem.jsx'); +var IssueNavItem = require('../../navbar/issue.navitem.jsx'); +var RecentNavItem = require('../../navbar/recent.navitem.jsx'); + +var BrewRenderer = require('../../brewRenderer/brewRenderer.jsx'); + +var ErrorPage = React.createClass({ + getDefaultProps: function() { + return { + ver : '0.0.0', + errorId: '' + }; + }, + + text : '# Oops \n We could not find a brew with that id. **Sorry!**', + + render : function(){ + return
+ + + + Crit Fail! + + + + + + + + + + +
+ +
+
+ } +}); + +module.exports = ErrorPage; diff --git a/client/homebrew/pages/errorPage/errorPage.less b/client/homebrew/pages/errorPage/errorPage.less new file mode 100644 index 000000000..48ba0f93e --- /dev/null +++ b/client/homebrew/pages/errorPage/errorPage.less @@ -0,0 +1,5 @@ +.errorPage{ + .errorTitle{ + background-color: @orange; + } +} \ No newline at end of file diff --git a/server.js b/server.js index 47dd148e1..763f98aa9 100644 --- a/server.js +++ b/server.js @@ -56,16 +56,11 @@ var sanitizeBrew = function(brew){ //Load project version var projectVersion = require('./package.json').version; -console.log(projectVersion); - //Edit Page app.get('/edit/:id', function(req, res){ HomebrewModel.find({editId : req.params.id}, function(err, objs){ - if(err || !objs.length) return res.status(404).send('Could not find Homebrew with that id'); - var resObj = null; - var errObj = {text: "# oops\nCould not find the homebrew."} if(objs.length){ resObj = objs[0].toJSON(); } @@ -76,7 +71,7 @@ app.get('/edit/:id', function(req, res){ prerenderWith : './client/homebrew/homebrew.jsx', initialProps: { url: req.originalUrl, - brew : resObj || errObj, + brew : resObj || {}, version : projectVersion }, clearRequireCache : !process.env.PRODUCTION, @@ -90,16 +85,15 @@ app.get('/edit/:id', function(req, res){ //Share Page app.get('/share/:id', function(req, res){ HomebrewModel.find({shareId : req.params.id}, function(err, objs){ - if(err || !objs.length) return res.status(404).send('Could not find Homebrew with that id'); - - var resObj = null; - var errObj = {text: "# oops\nCould not find the homebrew."} + var brew = {}; if(objs.length){ - resObj = objs[0]; + var resObj = objs[0]; resObj.lastViewed = new Date(); resObj.views = resObj.views + 1; resObj.save(); + + brew = resObj.toJSON(); } vitreumRender({ @@ -108,7 +102,7 @@ app.get('/share/:id', function(req, res){ prerenderWith : './client/homebrew/homebrew.jsx', initialProps: { url: req.originalUrl, - brew : sanitizeBrew(resObj.toJSON() || errObj), + brew : sanitizeBrew(brew || {}), version : projectVersion }, clearRequireCache : !process.env.PRODUCTION, @@ -123,13 +117,15 @@ var Markdown = require('naturalcrit/markdown.js'); var PHBStyle = '' app.get('/print/:id', function(req, res){ HomebrewModel.find({shareId : req.params.id}, function(err, objs){ - if(err || !objs.length) return res.status(404).send('Could not find Homebrew with that id'); - - var brew = null; + var brew = {}; if(objs.length){ brew = objs[0]; } + if(err || !objs.length){ + brew.text = '# Oops \n We could not find a brew with that id. **Sorry!**'; + } + var content = _.map(brew.text.split('\\page'), function(pageText, index){ return `
` + Markdown.render(pageText) + '
'; }).join('\n'); From 90c695c005d6ef425f0fee0cf1fc046fbbc38495 Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Sat, 20 Aug 2016 12:33:11 -0400 Subject: [PATCH 05/12] Visitng a deleted brew will now remove it from your recent list --- changelog.md | 2 +- client/homebrew/navbar/recent.navitem.jsx | 27 +++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index d8b02ab38..d39056010 100644 --- a/changelog.md +++ b/changelog.md @@ -4,7 +4,7 @@ - Added in a license file - Updated the welcome text - Added in a much better Error page - +- If you visit a deleted brew, it will now remove it from your recent list. (Thanks u/sIllverback!) ### Friday, 29/07/2016 - v2.2.7 - Adding in descriptive note blocks. (Thanks calculuschild!) diff --git a/client/homebrew/navbar/recent.navitem.jsx b/client/homebrew/navbar/recent.navitem.jsx index 0835f53ba..bd1e1e738 100644 --- a/client/homebrew/navbar/recent.navitem.jsx +++ b/client/homebrew/navbar/recent.navitem.jsx @@ -122,6 +122,12 @@ module.exports = { }), both : React.createClass({ + getDefaultProps: function() { + return { + errorId : null + }; + }, + getInitialState: function() { return { showDropdown: false, @@ -131,9 +137,26 @@ module.exports = { }, componentDidMount: function() { + + var edited = JSON.parse(localStorage.getItem(EDIT_KEY) || '[]'); + var viewed = JSON.parse(localStorage.getItem(VIEW_KEY) || '[]'); + + if(this.props.errorId){ + edited = _.filter(edited, (edit) => { + return edit.id !== this.props.errorId; + }); + viewed = _.filter(viewed, (view) => { + return view.id !== this.props.errorId; + }); + + localStorage.setItem(EDIT_KEY, JSON.stringify(edited)); + localStorage.setItem(VIEW_KEY, JSON.stringify(viewed)); + } + + this.setState({ - edit : JSON.parse(localStorage.getItem(EDIT_KEY) || '[]'), - view : JSON.parse(localStorage.getItem(VIEW_KEY) || '[]') + edit : edited, + view : viewed }); }, From 019383ebdd52fc463ae0a4db098e1e054cb6916d Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Sat, 20 Aug 2016 12:44:39 -0400 Subject: [PATCH 06/12] Improved the html parsing slightly --- changelog.md | 2 ++ client/homebrew/pages/editPage/editPage.jsx | 4 ++++ shared/naturalcrit/markdown.js | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index d39056010..259be0f4e 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,8 @@ - Updated the welcome text - Added in a much better Error page - If you visit a deleted brew, it will now remove it from your recent list. (Thanks u/sIllverback!) +- Improved parsing of embedded html text in brews. (Thanks u/com-charizard!) +- ### Friday, 29/07/2016 - v2.2.7 - Adding in descriptive note blocks. (Thanks calculuschild!) diff --git a/client/homebrew/pages/editPage/editPage.jsx b/client/homebrew/pages/editPage/editPage.jsx index b2b7551fa..b8f42b0a7 100644 --- a/client/homebrew/pages/editPage/editPage.jsx +++ b/client/homebrew/pages/editPage/editPage.jsx @@ -52,6 +52,10 @@ var EditPage = React.createClass({ }, savedBrew : null, + test : ()=>{ + + }, + componentDidMount: function(){ console.log('getting here'); diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 1a35e65ce..ba64ad7dc 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -4,7 +4,7 @@ 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), '
')){ + if(_.startsWith(_.trim(html), '')){ var openTag = html.substring(0, html.indexOf('>')+1); html = html.substring(html.indexOf('>')+1); html = html.substring(0, html.lastIndexOf('
')); From 0a7b5382163d5c317fe0791945857d329dd986a6 Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Sat, 20 Aug 2016 13:02:52 -0400 Subject: [PATCH 07/12] Added in the new coverpage snippet --- .../homebrew/editor/snippets/coverpage.gen.js | 117 ++++++++++++++++++ client/homebrew/editor/snippets/snippets.js | 8 +- 2 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 client/homebrew/editor/snippets/coverpage.gen.js diff --git a/client/homebrew/editor/snippets/coverpage.gen.js b/client/homebrew/editor/snippets/coverpage.gen.js new file mode 100644 index 000000000..d4b69d637 --- /dev/null +++ b/client/homebrew/editor/snippets/coverpage.gen.js @@ -0,0 +1,117 @@ +var _ = require('lodash'); + +var titles = [ + "The Burning Gallows", + "The Ring of Nenlast", + "Below the Blind Tavern", + "Below the Hungering River", + "Before Bahamut's Land", + "The Cruel Grave from Within", + "The Strength of Trade Road", + "Through The Raven Queen's Worlds", + "Within the Settlement", + "The Crown from Within", + "The Merchant Within the Battlefield", + "Ioun's Fading Traveler", + "The Legion Ingredient", + "The Explorer Lure", + "Before the Charming Badlands", + "The Living Dead Above the Fearful Cage", + "Vecna's Hidden Sage", + "Bahamut's Demonspawn", + "Across Gruumsh's Elemental Chaos", + "The Blade of Orcus", + "Beyond Revenge", + "Brain of Insanity", + "Breed Battle!, A New Beginning", + "Evil Lake, A New Beginning", + "Invasion of the Gigantic Cat, Part II", + "Kraken War 2020", + "The Body Whisperers", + "The Diabolical Tales of the Ape-Women", + "The Doctor Immortal", + "The Doctor from Heaven", + "The Graveyard", + "Azure Core", + "Core Battle", + "Core of Heaven: The Guardian of Amazement", + "Deadly Amazement III", + "Dry Chaos IX", + "Gate Thunder", + "Guardian: Skies of the Dark Wizard", + "Lute of Eternity", + "Mercury's Planet: Brave Evolution", + "Ruby of Atlantis: The Quake of Peace", + "Sky of Zelda: The Thunder of Force", + "Vyse's Skies", + "White Greatness III", + "Yellow Divinity", + "Zidane's Ghost" +]; + +var subtitles = [ + "In an ominous universe, a botanist opposes terrorism.", + "In a demon-haunted city, in an age of lies and hate, a physicist tries to find an ancient treasure and battles a mob of aliens.", + "In a land of corruption, two cyberneticists and a dungeon delver search for freedom.", + "In an evil empire of horror, two rangers battle the forces of hell.", + "In a lost city, in an age of sorcery, a librarian quests for revenge.", + "In a universe of illusions and danger, three time travellers and an adventurer search for justice.", + "In a forgotten universe of barbarism, in an era of terror and mysticism, a virtual reality programmer and a spy try to find vengance and battle crime.", + "In a universe of demons, in an era of insanity and ghosts, three bodyguards and a bodyguard try to find vengance.", + "In a kingdom of corruption and battle, seven artificial intelligences try to save the last living fertile woman.", + "In a universe of virutal reality and agony, in an age of ghosts and ghosts, a fortune-teller and a wanderer try to avert the apocalypse.", + "In a crime-infested kingdom, three martial artists quest for the truth and oppose evil.", + "In a terrifying universe of lost souls, in an era of lost souls, eight dancers fight evil.", + "In a galaxy of confusion and insanity, three martial artists and a duke battle a mob of psychics.", + "In an amazing kingdom, a wizard and a secretary hope to prevent the destruction of mankind.", + "In a kingdom of deception, a reporter searches for fame.", + "In a hellish empire, a swordswoman and a duke try to find the ultimate weapon and battle a conspiracy.", + "In an evil galaxy of illusion, in a time of technology and misery, seven psychiatrists battle crime.", + "In a dark city of confusion, three swordswomen and a singer battle lawlessness.", + "In an ominous empire, in an age of hate, two philosophers and a student try to find justice and battle a mob of mages intent on stealing the souls of the innocent.", + "In a kingdom of panic, six adventurers oppose lawlessness.", + "In a land of dreams and hopelessness, three hackers and a cyborg search for justice.", + "On a planet of mysticism, three travelers and a fire fighter quest for the ultimate weapon and oppose evil.", + "In a wicked universe, five seers fight lawlessness.", + "In a kingdom of death, in an era of illusion and blood, four colonists search for fame.", + "In an amazing kingdom, in an age of sorcery and lost souls, eight space pirates quest for freedom.", + "In a cursed empire, five inventors oppose terrorism.", + "On a crime-ridden planet of conspiracy, a watchman and an artificial intelligence try to find love and oppose lawlessness.", + "In a forgotten land, a reporter and a spy try to stop the apocalypse.", + "In a forbidden land of prophecy, a scientist and an archivist oppose a cabal of barbarians intent on stealing the souls of the innocent.", + "On an infernal world of illusion, a grave robber and a watchman try to find revenge and combat a syndicate of mages intent on stealing the source of all magic.", + "In a galaxy of dark magic, four fighters seek freedom.", + "In an empire of deception, six tomb-robbers quest for the ultimate weapon and combat an army of raiders.", + "In a kingdom of corruption and lost souls, in an age of panic, eight planetologists oppose evil.", + "In a galaxy of misery and hopelessness, in a time of agony and pain, five planetologists search for vengance.", + "In a universe of technology and insanity, in a time of sorcery, a computer techician quests for hope.", + "On a planet of dark magic and barbarism, in an age of horror and blasphemy, seven librarians search for fame.", + "In an empire of dark magic, in a time of blood and illusions, four monks try to find the ultimate weapon and combat terrorism.", + "In a forgotten empire of dark magic, six kings try to prevent the destruction of mankind.", + "In a galaxy of dark magic and horror, in an age of hopelessness, four marines and an outlaw combat evil.", + "In a mysterious city of illusion, in an age of computerization, a witch-hunter tries to find the ultimate weapon and opposes an evil corporation.", + "In a damned kingdom of technology, a virtual reality programmer and a fighter seek fame.", + "In a hellish kingdom, in an age of blasphemy and blasphemy, an astrologer searches for fame.", + "In a damned world of devils, an alien and a ranger quest for love and oppose a syndicate of demons.", + "In a cursed galaxy, in a time of pain, seven librarians hope to avert the apocalypse.", + "In a crime-infested galaxy, in an era of hopelessness and panic, three champions and a grave robber try to solve the ultimate crime." +]; + + +module.exports = () => { + return ` + +
+ +# ${_.sample(titles)} + +
+
+##### ${_.sample(subtitles)} +
+ +\\page` +} \ No newline at end of file diff --git a/client/homebrew/editor/snippets/snippets.js b/client/homebrew/editor/snippets/snippets.js index 2dbea7cf9..1d0eec785 100644 --- a/client/homebrew/editor/snippets/snippets.js +++ b/client/homebrew/editor/snippets/snippets.js @@ -3,6 +3,7 @@ var ClassTableGen = require('./classtable.gen.js'); var MonsterBlockGen = require('./monsterblock.gen.js'); var ClassFeatureGen = require('./classfeature.gen.js'); var FullClassGen = require('./fullclass.gen.js'); +var CoverPageGen = require('./coverpage.gen.js'); module.exports = [ @@ -130,7 +131,12 @@ module.exports = [ name : 'Wide Monster Stat Block', icon : 'fa-paw', gen : MonsterBlockGen.full, - } + }, + { + name : 'Cover Page', + icon : 'fa-file-word-o', + gen : CoverPageGen, + }, ] }, From ef8784ccf2a8b7cab90fcb620e88c4ab97f2e60e Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Sat, 20 Aug 2016 13:20:32 -0400 Subject: [PATCH 08/12] Homebrewery will now try and insert a better title for you if you dont provide one --- changelog.md | 2 +- client/homebrew/pages/homePage/homePage.jsx | 1 - client/homebrew/pages/newPage/newPage.jsx | 2 +- server/homebrew.api.js | 15 +++++++++++++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 259be0f4e..5b8ed4daa 100644 --- a/changelog.md +++ b/changelog.md @@ -6,7 +6,7 @@ - Added in a much better Error page - If you visit a deleted brew, it will now remove it from your recent list. (Thanks u/sIllverback!) - Improved parsing of embedded html text in brews. (Thanks u/com-charizard!) -- +- Added in a new coverpage snippet ### Friday, 29/07/2016 - v2.2.7 - Adding in descriptive note blocks. (Thanks calculuschild!) diff --git a/client/homebrew/pages/homePage/homePage.jsx b/client/homebrew/pages/homePage/homePage.jsx index 7e3a7031d..e75dfc751 100644 --- a/client/homebrew/pages/homePage/homePage.jsx +++ b/client/homebrew/pages/homePage/homePage.jsx @@ -31,7 +31,6 @@ var HomePage = React.createClass({ handleSave : function(){ request.post('/api') .send({ - title : 'Change This', text : this.state.text }) .end((err, res)=>{ diff --git a/client/homebrew/pages/newPage/newPage.jsx b/client/homebrew/pages/newPage/newPage.jsx index eeb74ffd7..d664f88dc 100644 --- a/client/homebrew/pages/newPage/newPage.jsx +++ b/client/homebrew/pages/newPage/newPage.jsx @@ -20,7 +20,7 @@ var NewPage = React.createClass({ getInitialState: function() { return { ver : '0.0.0', - title : 'My Awesome Brew v99', + title : '', text: '', isSaving : false }; diff --git a/server/homebrew.api.js b/server/homebrew.api.js index caa7fedd5..a21ff7933 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -27,11 +27,26 @@ var getTopBrews = function(cb){ }); } +var getGoodBrewTitle = (text) => { + var titlePos = text.indexOf('# '); + if(titlePos !== -1){ + var ending = text.indexOf('\n', titlePos); + return text.substring(titlePos + 2, ending); + }else{ + return _.find(text.split('\n'), (line)=>{ + return line; + }); + } +}; + module.exports = function(app){ app.post('/api', function(req, res){ var newHomebrew = new HomebrewModel(req.body); + if(!newHomebrew.title){ + newHomebrew.title = getGoodBrewTitle(newHomebrew.text); + } newHomebrew.save(function(err, obj){ if(err){ console.error(err, err.toString(), err.stack); From 888d3faa4c5badbdfbcb03cf51b8178771683439 Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Sat, 20 Aug 2016 13:26:48 -0400 Subject: [PATCH 09/12] Editor and renderer redraw when you resize the browser --- changelog.md | 3 +++ client/homebrew/brewRenderer/brewRenderer.jsx | 9 +++++++++ client/homebrew/editor/editor.jsx | 14 ++++++++++---- client/homebrew/pages/editPage/editPage.jsx | 7 ------- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/changelog.md b/changelog.md index 5b8ed4daa..3842385a8 100644 --- a/changelog.md +++ b/changelog.md @@ -7,6 +7,9 @@ - If you visit a deleted brew, it will now remove it from your recent list. (Thanks u/sIllverback!) - Improved parsing of embedded html text in brews. (Thanks u/com-charizard!) - Added in a new coverpage snippet +- Homebrewery will now try and onsert a good title for your brew if you don't provide one +- Homebrewery now re-renders properly when you zoom + ### Friday, 29/07/2016 - v2.2.7 - Adding in descriptive note blocks. (Thanks calculuschild!) diff --git a/client/homebrew/brewRenderer/brewRenderer.jsx b/client/homebrew/brewRenderer/brewRenderer.jsx index 9f18db9cd..34de1f416 100644 --- a/client/homebrew/brewRenderer/brewRenderer.jsx +++ b/client/homebrew/brewRenderer/brewRenderer.jsx @@ -23,11 +23,20 @@ var BrewRenderer = React.createClass({ height : 0, componentDidMount: function() { + this.updateSize(); + window.addEventListener("resize", this.updateSize); + }, + componentWillUnmount: function() { + window.removeEventListener("resize", this.updateSize); + }, + + updateSize : function() { this.setState({ height : this.refs.main.parentNode.clientHeight, isMounted : true }); }, + handleScroll : function(e){ this.setState({ viewablePageNumber : Math.floor(e.target.scrollTop / PAGE_HEIGHT) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index dda0dce9c..7a8dcb061 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -28,9 +28,19 @@ var Editor = React.createClass({ }, componentDidMount: function() { + this.updateEditorSize(); + window.addEventListener("resize", this.updateEditorSize); + }, + componentWillUnmount: function() { + window.removeEventListener("resize", this.updateEditorSize); + }, + + updateEditorSize : function() { var paneHeight = this.refs.main.parentNode.clientHeight; paneHeight -= this.refs.snippetBar.clientHeight + 1; this.refs.codeEditor.codeMirror.setSize(null, paneHeight); + + this.refs.codeEditor.updateSize(); }, handleTextChange : function(text){ @@ -48,10 +58,6 @@ var Editor = React.createClass({ this.refs.codeEditor.setCursorPosition(this.cursorPosition.line, this.cursorPosition.ch + injectText.length); }, - //Called when there are changes to the editor's dimensions - update : function(){ - this.refs.codeEditor.updateSize(); - }, renderSnippetGroups : function(){ return _.map(Snippets, (snippetGroup)=>{ diff --git a/client/homebrew/pages/editPage/editPage.jsx b/client/homebrew/pages/editPage/editPage.jsx index b8f42b0a7..4b923b50f 100644 --- a/client/homebrew/pages/editPage/editPage.jsx +++ b/client/homebrew/pages/editPage/editPage.jsx @@ -52,14 +52,7 @@ var EditPage = React.createClass({ }, savedBrew : null, - test : ()=>{ - - }, - componentDidMount: function(){ - - console.log('getting here'); - this.debounceSave = _.debounce(this.save, SAVE_TIMEOUT); window.onbeforeunload = ()=>{ if(this.state.isSaving || this.state.isPending){ From b134e11a863453fd755da6a8a5ff79ceb4b2b25f Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Sat, 20 Aug 2016 13:29:28 -0400 Subject: [PATCH 10/12] Fixed a unclick bug with the splitpane --- client/homebrew/editor/editor.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 7a8dcb061..d79ef4a98 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -27,6 +27,7 @@ var Editor = React.createClass({ ch : 0 }, + componentDidMount: function() { this.updateEditorSize(); window.addEventListener("resize", this.updateEditorSize); @@ -39,8 +40,6 @@ var Editor = React.createClass({ var paneHeight = this.refs.main.parentNode.clientHeight; paneHeight -= this.refs.snippetBar.clientHeight + 1; this.refs.codeEditor.codeMirror.setSize(null, paneHeight); - - this.refs.codeEditor.updateSize(); }, handleTextChange : function(text){ @@ -58,6 +57,10 @@ var Editor = React.createClass({ this.refs.codeEditor.setCursorPosition(this.cursorPosition.line, this.cursorPosition.ch + injectText.length); }, + //Called when there are changes to the editor's dimensions + update : function(){ + this.refs.codeEditor.updateSize(); + }, renderSnippetGroups : function(){ return _.map(Snippets, (snippetGroup)=>{ From 78426135c61aeacacf4e8be61d64a3aeeb6393d5 Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Sat, 20 Aug 2016 13:33:15 -0400 Subject: [PATCH 11/12] Note blocks now don't overlap titles --- changelog.md | 1 + client/homebrew/phbStyle/phb.style.less | 4 ++-- phb.standalone.css | 8 ++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index 3842385a8..4ffb9a268 100644 --- a/changelog.md +++ b/changelog.md @@ -9,6 +9,7 @@ - Added in a new coverpage snippet - Homebrewery will now try and onsert a good title for your brew if you don't provide one - Homebrewery now re-renders properly when you zoom +- Fixed the noteblock overlapping into titles (thanks u/dsompura!) ### Friday, 29/07/2016 - v2.2.7 diff --git a/client/homebrew/phbStyle/phb.style.less b/client/homebrew/phbStyle/phb.style.less index a09676acf..7a5736fc7 100644 --- a/client/homebrew/phbStyle/phb.style.less +++ b/client/homebrew/phbStyle/phb.style.less @@ -195,8 +195,8 @@ body { } } //If a note starts a column, give it space at the top to render border - pre+blockquote{ - margin-top : 11px; + pre+blockquote, h2+blockquote, h3+blockquote, h4+blockquote, h5+blockquote { + margin-top : 13px; } //***************************** // * MONSTER STAT BLOCK diff --git a/phb.standalone.css b/phb.standalone.css index 3327cf453..adcf20c11 100644 --- a/phb.standalone.css +++ b/phb.standalone.css @@ -375,8 +375,12 @@ body { font-size: 0.352cm; line-height: 1.1em; } -.phb pre + blockquote { - margin-top: 11px; +.phb pre + blockquote, +.phb h2 + blockquote, +.phb h3 + blockquote, +.phb h4 + blockquote, +.phb h5 + blockquote { + margin-top: 13px; } .phb hr + blockquote { position: relative; From 43ec212be9d9a9a64bf235fb240b4749927f9fbf Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Sat, 20 Aug 2016 13:40:05 -0400 Subject: [PATCH 12/12] Fixed a bad route in the admin page --- changelog.md | 1 + client/admin/homebrewAdmin/homebrewAdmin.jsx | 2 +- server/homebrew.api.js | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 4ffb9a268..544cf3896 100644 --- a/changelog.md +++ b/changelog.md @@ -10,6 +10,7 @@ - Homebrewery will now try and onsert a good title for your brew if you don't provide one - Homebrewery now re-renders properly when you zoom - Fixed the noteblock overlapping into titles (thanks u/dsompura!) +- Fixed a bad search route in the admin panel (thanks u/SnappyTom!) ### Friday, 29/07/2016 - v2.2.7 diff --git a/client/admin/homebrewAdmin/homebrewAdmin.jsx b/client/admin/homebrewAdmin/homebrewAdmin.jsx index c6a7ddb2b..6397f1bd0 100644 --- a/client/admin/homebrewAdmin/homebrewAdmin.jsx +++ b/client/admin/homebrewAdmin/homebrewAdmin.jsx @@ -28,7 +28,7 @@ var HomebrewAdmin = React.createClass({ fetchBrews : function(page){ - request.get('/homebrew/api/search') + request.get('/api/search') .query({ admin_key : this.props.admin_key, count : this.state.count, diff --git a/server/homebrew.api.js b/server/homebrew.api.js index a21ff7933..2e031b6c8 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -107,6 +107,7 @@ module.exports = function(app){ app.get('/api/search', mw.adminOnly, function(req, res){ + var page = req.query.page || 0; var count = req.query.count || 20;