0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-27 07:23:09 +00:00

Compare commits

...

6 Commits
v3 ... v2.7.5

Author SHA1 Message Date
Scott Tolksdorf
643f6f933d Fixing issue#413 class feature duping entire brew 2018-11-07 16:00:24 -05:00
Trevor Buckner
a1140f75d8 Fix border-image bug on PDFs
I think this might be caused by a new bug in Chrome or something since it seems to have popped up in GMBinder as well in the last couple weeks. See #683

Anyway, the error only occurs on the Class Table and Descriptive Text Box, which are also the only ones to use `border-image-repeat: round`. I changed it to `border-image-repeat: stretch` which solves the graphical issue and doesn't affect the appearance otherwise in this particular case.
2018-11-07 14:57:52 -05:00
Scott Tolksdorf
b68c6a4ad2 Added ability to hide render wanring notification 2017-04-22 12:09:18 -04:00
Scott Tolksdorf
6e0f042b42 Adding quick fix for PPR getting out of sync 2017-03-03 19:25:56 -05:00
Scott Tolksdorf
c47d492ed3 fix 2017-02-18 14:48:45 -05:00
Scott Tolksdorf
18852932e8 Added new delete brew option on user page 2017-02-18 14:46:14 -05:00
9 changed files with 209 additions and 156 deletions

View File

@@ -1,5 +1,15 @@
# changelog # changelog
### Saturday, 22/04/217 - v2.7.4
- Give ability to hide the render warning notification
### Friday, 03/03/2017 - v2.7.3
- Increasing the range on the Partial Page Rendering for a quick-fix for it getting out of sync on long brews.
### Saturday, 18/02/2017 - v2.7.2
- Adding ability to delete a brew from the user page, incase the user creates a brew that makes the edit page unrender-able. (re:309)
## BIG NEWS ## BIG NEWS
With the next major release of Homebrewery, v3.0.0, this tool *will no longer support raw HTML input for brew code*. Most issues and errors users are having are because of this feature and it's become too taxing to help and fix these issues. With the next major release of Homebrewery, v3.0.0, this tool *will no longer support raw HTML input for brew code*. Most issues and errors users are having are because of this feature and it's become too taxing to help and fix these issues.

View File

@@ -77,9 +77,13 @@ const BrewRenderer = React.createClass({
if(!this.state.isMounted) return false; if(!this.state.isMounted) return false;
var viewIndex = this.state.viewablePageNumber; var viewIndex = this.state.viewablePageNumber;
if(index == viewIndex - 3) return true;
if(index == viewIndex - 2) return true;
if(index == viewIndex - 1) return true; if(index == viewIndex - 1) return true;
if(index == viewIndex) return true; if(index == viewIndex) return true;
if(index == viewIndex + 1) return true; if(index == viewIndex + 1) return true;
if(index == viewIndex + 2) return true;
if(index == viewIndex + 3) return true;
//Check for style tages //Check for style tages
if(pageText.indexOf('<style>') !== -1) return true; if(pageText.indexOf('<style>') !== -1) return true;

View File

@@ -2,7 +2,7 @@ var _ = require('lodash');
module.exports = function(classname){ module.exports = function(classname){
classname = classname || _.sample(['archivist', 'fancyman', 'linguist', 'fletcher', classname = _.sample(['archivist', 'fancyman', 'linguist', 'fletcher',
'notary', 'berserker-typist', 'fishmongerer', 'manicurist', 'haberdasher', 'concierge']) 'notary', 'berserker-typist', 'fishmongerer', 'manicurist', 'haberdasher', 'concierge'])
classname = classname.toLowerCase(); classname = classname.toLowerCase();

View File

@@ -2,6 +2,7 @@ const React = require('react');
const _ = require('lodash'); const _ = require('lodash');
const cx = require('classnames'); const cx = require('classnames');
const moment = require('moment'); const moment = require('moment');
const request = require("superagent");
const BrewItem = React.createClass({ const BrewItem = React.createClass({
getDefaultProps: function() { getDefaultProps: function() {
@@ -15,6 +16,24 @@ const BrewItem = React.createClass({
}; };
}, },
deleteBrew : function(){
if(!confirm("are you sure you want to delete this brew?")) return;
if(!confirm("are you REALLY sure? You will not be able to recover it")) return;
request.get('/api/remove/' + this.props.brew.editId)
.send()
.end(function(err, res){
location.reload();
});
},
renderDeleteBrewLink: function(){
if(!this.props.brew.editId) return;
return <a onClick={this.deleteBrew}>
<i className='fa fa-trash' />
</a>
},
renderEditLink: function(){ renderEditLink: function(){
if(!this.props.brew.editId) return; if(!this.props.brew.editId) return;
@@ -47,6 +66,7 @@ const BrewItem = React.createClass({
<i className='fa fa-share-alt' /> <i className='fa fa-share-alt' />
</a> </a>
{this.renderEditLink()} {this.renderEditLink()}
{this.renderDeleteBrewLink()}
</div> </div>
</div> </div>
} }

View File

@@ -415,7 +415,7 @@ body {
border : initial; border : initial;
border-style : solid; border-style : solid;
border-image-outset : 25px 17px; border-image-outset : 25px 17px;
border-image-repeat : round; border-image-repeat : stretch;
border-image-slice : 150 200 150 200; border-image-slice : 150 200 150 200;
border-image-source : @frameBorderImage; border-image-source : @frameBorderImage;
border-image-width : 47px; border-image-width : 47px;
@@ -423,9 +423,9 @@ body {
margin-bottom : 10px; margin-bottom : 10px;
} }
} }
//***************************** //************************************
// * CLASS TABLE // * DESCRIPTIVE TEXT BOX
// *****************************/ // ************************************/
.phb .descriptive{ .phb .descriptive{
display : block-inline; display : block-inline;
margin-bottom : 1em; margin-bottom : 1em;
@@ -433,7 +433,7 @@ body {
font-family : ScalySans; font-family : ScalySans;
border-style : solid; border-style : solid;
border-width : 7px; border-width : 7px;
border-image : @descriptiveBoxImage 12 round; border-image : @descriptiveBoxImage 12 stretch;
border-image-outset : 4px; border-image-outset : 4px;
box-shadow : 0px 0px 6px #faf7ea; box-shadow : 0px 0px 6px #faf7ea;
p{ p{

View File

@@ -1,7 +1,7 @@
{ {
"name": "homebrewery", "name": "homebrewery",
"description": "Create authentic looking D&D homebrews using only markdown", "description": "Create authentic looking D&D homebrews using only markdown",
"version": "2.7.1", "version": "2.7.5",
"scripts": { "scripts": {
"dev": "node scripts/dev.js", "dev": "node scripts/dev.js",
"quick": "node scripts/quick.js", "quick": "node scripts/quick.js",

279
server.js
View File

@@ -1,141 +1,140 @@
const _ = require('lodash'); const _ = require('lodash');
const jwt = require('jwt-simple'); const jwt = require('jwt-simple');
const express = require("express"); const express = require("express");
const app = express(); const app = express();
app.use(express.static(__dirname + '/build'));'' app.use(express.static(__dirname + '/build'));''
app.use(require('body-parser').json({limit: '25mb'})); app.use(require('body-parser').json({limit: '25mb'}));
app.use(require('cookie-parser')()); app.use(require('cookie-parser')());
const config = require('nconf') const config = require('nconf')
.argv() .argv()
.env({ lowerCase: true }) .env({ lowerCase: true })
.file('environment', { file: `config/${process.env.NODE_ENV}.json` }) .file('environment', { file: `config/${process.env.NODE_ENV}.json` })
.file('defaults', { file: 'config/default.json' }); .file('defaults', { file: 'config/default.json' });
//DB //DB
require('mongoose') require('mongoose')
.connect(process.env.MONGODB_URI || process.env.MONGOLAB_URI || 'mongodb://localhost/naturalcrit') .connect(process.env.MONGODB_URI || process.env.MONGOLAB_URI || 'mongodb://localhost/naturalcrit')
.connection.on('error', () => { .connection.on('error', () => {
console.log('Error : Could not connect to a Mongo Database.'); console.log('Error : Could not connect to a Mongo Database.');
console.log(' If you are running locally, make sure mongodb.exe is running.'); console.log(' If you are running locally, make sure mongodb.exe is running.');
}); });
//Account MIddleware //Account MIddleware
app.use((req, res, next) => { app.use((req, res, next) => {
if(req.cookies && req.cookies.nc_session){ if(req.cookies && req.cookies.nc_session){
try{ try{
req.account = jwt.decode(req.cookies.nc_session, config.get('secret')); req.account = jwt.decode(req.cookies.nc_session, config.get('secret'));
}catch(e){} }catch(e){}
} }
return next(); return next();
}); });
app.use(require('./server/homebrew.api.js')); app.use(require('./server/homebrew.api.js'));
app.use(require('./server/admin.api.js')); app.use(require('./server/admin.api.js'));
const HomebrewModel = require('./server/homebrew.model.js').model; const HomebrewModel = require('./server/homebrew.model.js').model;
const welcomeText = require('fs').readFileSync('./client/homebrew/pages/homePage/welcome_msg.md', 'utf8'); const welcomeText = require('fs').readFileSync('./client/homebrew/pages/homePage/welcome_msg.md', 'utf8');
const changelogText = require('fs').readFileSync('./changelog.md', 'utf8'); const changelogText = require('fs').readFileSync('./changelog.md', 'utf8');
//Source page
//Source page String.prototype.replaceAll = function(s,r){return this.split(s).join(r)}
String.prototype.replaceAll = function(s,r){return this.split(s).join(r)} app.get('/source/:id', (req, res)=>{
app.get('/source/:id', (req, res)=>{ HomebrewModel.get({shareId : req.params.id})
HomebrewModel.get({shareId : req.params.id}) .then((brew)=>{
.then((brew)=>{ const text = brew.text.replaceAll('<', '&lt;').replaceAll('>', '&gt;');
const text = brew.text.replaceAll('<', '&lt;').replaceAll('>', '&gt;'); return res.send(`<code><pre>${text}</pre></code>`);
return res.send(`<code><pre>${text}</pre></code>`); })
}) .catch((err)=>{
.catch((err)=>{ console.log(err);
console.log(err); return res.status(404).send('Could not find Homebrew with that id');
return res.status(404).send('Could not find Homebrew with that id'); })
}) });
});
app.get('/user/:username', (req, res, next) => {
app.get('/user/:username', (req, res, next) => { const fullAccess = req.account && (req.account.username == req.params.username);
const fullAccess = req.account && (req.account.username == req.params.username); HomebrewModel.getByUser(req.params.username, fullAccess)
HomebrewModel.getByUser(req.params.username, fullAccess) .then((brews) => {
.then((brews) => { req.brews = brews;
req.brews = brews; return next();
return next(); })
}) .catch((err) => {
.catch((err) => { console.log(err);
console.log(err); })
}) })
})
app.get('/edit/:id', (req, res, next)=>{
app.get('/edit/:id', (req, res, next)=>{ HomebrewModel.get({editId : req.params.id})
HomebrewModel.get({editId : req.params.id}) .then((brew)=>{
.then((brew)=>{ req.brew = brew.sanatize();
req.brew = brew.sanatize(); return next();
return next(); })
}) .catch((err)=>{
.catch((err)=>{ console.log(err);
console.log(err); return res.status(400).send(`Can't get that`);
return res.status(400).send(`Can't get that`); });
}); });
});
//Share Page
//Share Page app.get('/share/:id', (req, res, next)=>{
app.get('/share/:id', (req, res, next)=>{ HomebrewModel.get({shareId : req.params.id})
HomebrewModel.get({shareId : req.params.id}) .then((brew)=>{
.then((brew)=>{ return brew.increaseView();
return brew.increaseView(); })
}) .then((brew)=>{
.then((brew)=>{ req.brew = brew.sanatize(true);
req.brew = brew.sanatize(true); return next();
return next(); })
}) .catch((err)=>{
.catch((err)=>{ console.log(err);
console.log(err); return res.status(400).send(`Can't get that`);
return res.status(400).send(`Can't get that`); });
}); });
});
//Print Page
//Print Page app.get('/print/:id', (req, res, next)=>{
app.get('/print/:id', (req, res, next)=>{ HomebrewModel.get({shareId : req.params.id})
HomebrewModel.get({shareId : req.params.id}) .then((brew)=>{
.then((brew)=>{ req.brew = brew.sanatize(true);
req.brew = brew.sanatize(true); return next();
return next(); })
}) .catch((err)=>{
.catch((err)=>{ console.log(err);
console.log(err); return res.status(400).send(`Can't get that`);
return res.status(400).send(`Can't get that`); });
}); });
});
//Render Page
//Render Page const render = require('vitreum/steps/render');
const render = require('vitreum/steps/render'); const templateFn = require('./client/template.js');
const templateFn = require('./client/template.js'); app.use((req, res) => {
app.use((req, res) => { render('homebrew', templateFn, {
render('homebrew', templateFn, { version : require('./package.json').version,
version : require('./package.json').version, url: req.originalUrl,
url: req.originalUrl, welcomeText : welcomeText,
welcomeText : welcomeText, changelog : changelogText,
changelog : changelogText, brew : req.brew,
brew : req.brew, brews : req.brews,
brews : req.brews, account : req.account
account : req.account })
}) .then((page) => {
.then((page) => { return res.send(page)
return res.send(page) })
}) .catch((err) => {
.catch((err) => { console.log(err);
console.log(err); return res.sendStatus(500);
return res.sendStatus(500); });
}); });
});
const PORT = process.env.PORT || 8000;
const PORT = process.env.PORT || 8000; app.listen(PORT);
app.listen(PORT);
console.log(`server on port:${PORT}`); console.log(`server on port:${PORT}`);

View File

@@ -3,6 +3,8 @@ const React = require('react');
const _ = require('lodash'); const _ = require('lodash');
const cx = require('classnames'); const cx = require('classnames');
const DISMISS_KEY = 'dismiss_render_warning';
const RenderWarnings = React.createClass({ const RenderWarnings = React.createClass({
getInitialState: function() { getInitialState: function() {
return { return {
@@ -40,6 +42,9 @@ const RenderWarnings = React.createClass({
} }
}, },
checkWarnings : function(){ checkWarnings : function(){
const hideDismiss = localStorage.getItem(DISMISS_KEY);
if(hideDismiss) return this.setState({warnings : {}});
this.setState({ this.setState({
warnings : _.reduce(this.warnings, (r, fn, type) => { warnings : _.reduce(this.warnings, (r, fn, type) => {
const element = fn(); const element = fn();
@@ -48,11 +53,16 @@ const RenderWarnings = React.createClass({
}, {}) }, {})
}) })
}, },
dismiss : function(){
localStorage.setItem(DISMISS_KEY, true);
this.checkWarnings();
},
render: function(){ render: function(){
if(_.isEmpty(this.state.warnings)) return null; if(_.isEmpty(this.state.warnings)) return null;
return <div className='renderWarnings'> return <div className='renderWarnings'>
<i className='fa fa-exclamation-triangle' /> <i className='fa fa-times dismiss' onClick={this.dismiss}/>
<i className='fa fa-exclamation-triangle ohno' />
<h3>Render Warnings</h3> <h3>Render Warnings</h3>
<small>If this homebrew is rendering badly if might be because of the following:</small> <small>If this homebrew is rendering badly if might be because of the following:</small>
<ul>{_.values(this.state.warnings)}</ul> <ul>{_.values(this.state.warnings)}</ul>

View File

@@ -11,12 +11,22 @@
padding-left : 85px; padding-left : 85px;
background-color : @yellow; background-color : @yellow;
color : white; color : white;
i{ i.ohno{
position: absolute; position : absolute;
left: 24px; top : 24px;
opacity: 0.8; left : 24px;
font-size: 2.5em; opacity : 0.8;
top: 24px; font-size : 2.5em;
}
i.dismiss{
position : absolute;
top : 10px;
right : 10px;
cursor : pointer;
opacity : 0.6;
&:hover{
opacity : 1;
}
} }
small{ small{
opacity : 0.7; opacity : 0.7;
@@ -32,10 +42,10 @@
list-style-position : outside; list-style-position : outside;
list-style-type : disc; list-style-type : disc;
li{ li{
font-size : 0.8em;
line-height : 1.6em; line-height : 1.6em;
font-size: 0.8em;
em{ em{
font-weight: 800; font-weight : 800;
} }
} }
} }