mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-24 01:13:15 +00:00
Compare commits
13 Commits
v3
...
newRendere
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
570d86448d | ||
|
|
18d0b68eb0 | ||
|
|
74d17f32a5 | ||
|
|
469fa957aa | ||
|
|
4d0ebcb1d8 | ||
|
|
10f9ac14c7 | ||
|
|
705adbe2c6 | ||
|
|
7e7428504e | ||
|
|
c28647726a | ||
|
|
a30bd79399 | ||
|
|
87a9c46202 | ||
|
|
380bbd661f | ||
|
|
fa203047da |
@@ -60,7 +60,7 @@ const Homebrew = React.createClass({
|
||||
'/test_old' : <SharePage />,
|
||||
|
||||
|
||||
'*' : <HomePage />,
|
||||
'*' : <HomePage brews={this.props.brews}/>,
|
||||
});
|
||||
},
|
||||
render : function(){
|
||||
|
||||
@@ -48,10 +48,10 @@ const SmartNav = Store.createSmartComponent(React.createClass({
|
||||
<Nav.section>
|
||||
<Items.ContinousSave />
|
||||
<Items.Issue />
|
||||
<Nav.item newTab={true} href={'/share/' + Store.getBrew().shareId} color='teal' icon='fa-share-alt'>
|
||||
<Nav.item newTab={true} href={'/share/' + this.props.brew.shareId} color='teal' icon='fa-share-alt'>
|
||||
Share
|
||||
</Nav.item>
|
||||
<Items.Print />
|
||||
<Items.Print shareId={this.props.brew.shareId} />
|
||||
<Items.Account />
|
||||
</Nav.section>
|
||||
</Navbar>
|
||||
|
||||
BIN
client/homebrew/pages/homePage/dmg_bg.jpg
Normal file
BIN
client/homebrew/pages/homePage/dmg_bg.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 187 KiB |
BIN
client/homebrew/pages/homePage/fantasy_background.jpg
Normal file
BIN
client/homebrew/pages/homePage/fantasy_background.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 822 KiB |
@@ -4,33 +4,31 @@ const cx = require('classnames');
|
||||
|
||||
const Nav = require('naturalcrit/nav/nav.jsx');
|
||||
const Navbar = require('../../navbar/navbar.jsx');
|
||||
const PatreonNavItem = require('../../navbar/patreon.navitem.jsx');
|
||||
const IssueNavItem = require('../../navbar/issue.navitem.jsx');
|
||||
const RecentNavItem = require('../../navbar/recent.navitem.jsx');
|
||||
const AccountNavItem = require('../../navbar/account.navitem.jsx');
|
||||
const NavItem = require('../../navbar/navitems.js');
|
||||
|
||||
|
||||
const BrewInterface = require('homebrewery/brewInterface/brewInterface.jsx');
|
||||
//const BrewInterface = require('homebrewery/brewInterface/brewInterface.jsx');
|
||||
const BrewCard = require('homebrewery/brewCard/brewCard.jsx');
|
||||
|
||||
|
||||
const Actions = require('homebrewery/brew.actions.js');
|
||||
//
|
||||
//const Actions = require('homebrewery/brew.actions.js');
|
||||
|
||||
const HomePage = React.createClass({
|
||||
handleSave : function(){
|
||||
Actions.saveNew();
|
||||
getDefaultProps: function() {
|
||||
return {
|
||||
topBrews : []
|
||||
};
|
||||
},
|
||||
|
||||
renderNavbar : function(){
|
||||
return <Navbar>
|
||||
<Nav.section>
|
||||
<PatreonNavItem collaspe={true} />
|
||||
<IssueNavItem collaspe={true} />
|
||||
<NavItem.Patreon collaspe={true} />
|
||||
<NavItem.Issue collaspe={true} />
|
||||
<Nav.item newTab={true} href='/changelog' color='purple' icon='fa-star' collaspe={true}>
|
||||
What's new
|
||||
</Nav.item>
|
||||
<RecentNavItem.both />
|
||||
<AccountNavItem />
|
||||
<NavItem.Recent.both />
|
||||
<NavItem.Account />
|
||||
{/*}
|
||||
<Nav.item href='/new' color='green' icon='fa-external-link'>
|
||||
New Brew
|
||||
@@ -40,22 +38,58 @@ const HomePage = React.createClass({
|
||||
</Navbar>
|
||||
},
|
||||
|
||||
renderNavigation : function(){
|
||||
return <div className='navigation'>
|
||||
<p>
|
||||
Effortlessly create Authnetic looking D&D homebrews with just text
|
||||
</p>
|
||||
<div>
|
||||
<a className='button new' target='_blank' href='/new'>
|
||||
<i className='fa fa-magic' />
|
||||
<h3>New</h3>
|
||||
<p>This is some sample text</p>
|
||||
</a>
|
||||
|
||||
<a className='button search' target='_blank' href='/search'>
|
||||
<i className='fa fa-search' />
|
||||
<h3>Search</h3>
|
||||
<p>This is some sample text</p>
|
||||
</a>
|
||||
</div>
|
||||
<div>
|
||||
<a className='button docs' target='_blank' href='/docs'>
|
||||
<i className='fa fa-book' />
|
||||
<h3>Docs</h3>
|
||||
<p>This is some sample text</p>
|
||||
</a>
|
||||
<a className='button account' target='_blank' href='/account'>
|
||||
<i className='fa fa-user' />
|
||||
<h3>Account</h3>
|
||||
<p>This is some sample text</p>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
},
|
||||
|
||||
renderTopBrews : function(){
|
||||
return <div className='topBrews'>
|
||||
{_.map(this.props.brews, (brew)=><BrewCard brew={brew} key={brew._id}/>)}
|
||||
</div>
|
||||
},
|
||||
|
||||
render : function(){
|
||||
return <div className='homePage page'>
|
||||
{this.renderNavbar()}
|
||||
<div className='content'>
|
||||
<BrewInterface />
|
||||
</div>
|
||||
<div className='hero'>
|
||||
hero
|
||||
<h1>The Homebrewery</h1>
|
||||
|
||||
<div className={cx('floatingSaveButton', {
|
||||
//show : Store.getBrewText() !== this.props.welcomeText
|
||||
})} onClick={this.handleSave}>
|
||||
Save current <i className='fa fa-save' />
|
||||
</div>
|
||||
{this.renderNavigation()}
|
||||
{this.renderTopBrews()}
|
||||
</div>
|
||||
|
||||
<a href='/new' className='floatingNewButton'>
|
||||
Create your own <i className='fa fa-magic' />
|
||||
</a>
|
||||
</div>
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,43 +1,109 @@
|
||||
|
||||
@import 'homebrewery/phb_style/phb.fonts.less';
|
||||
.homePage{
|
||||
position : relative;
|
||||
a.floatingNewButton{
|
||||
.animate(background-color);
|
||||
position : absolute;
|
||||
display : block;
|
||||
right : 70px;
|
||||
bottom : 70px;
|
||||
z-index : 100;
|
||||
z-index : 5001;
|
||||
padding : 1em;
|
||||
background-color : @orange;
|
||||
font-size : 1.5em;
|
||||
color : white;
|
||||
text-decoration : none;
|
||||
box-shadow : 3px 3px 15px black;
|
||||
&:hover{
|
||||
background-color : darken(@orange, 20%);
|
||||
.hero{
|
||||
// .backgroundScrollAnimation();
|
||||
height : 400px;
|
||||
background-image : url('/assets/homebrew/pages/homePage/fantasy_background.jpg');
|
||||
background-position : 1% 15%;
|
||||
h1{
|
||||
margin-top : 15%;
|
||||
font-family : BookInsanity;
|
||||
font-size : 3em;
|
||||
font-weight : 800;
|
||||
letter-spacing : 0.3em;
|
||||
text-align : center;
|
||||
}
|
||||
}
|
||||
.floatingSaveButton{
|
||||
.animateAll();
|
||||
position : absolute;
|
||||
display : block;
|
||||
right : 200px;
|
||||
bottom : 90px;
|
||||
z-index : 100;
|
||||
z-index : 5000;
|
||||
padding : 0.8em;
|
||||
cursor : pointer;
|
||||
background-color : @blue;
|
||||
font-size : 0.8em;
|
||||
color : white;
|
||||
text-decoration : none;
|
||||
box-shadow : 3px 3px 15px black;
|
||||
&:hover{
|
||||
background-color : darken(@blue, 20%);
|
||||
.navigation{
|
||||
padding : 30px;
|
||||
background-image : url('/assets/homebrew/pages/homePage/dmg_bg.jpg');
|
||||
text-align : center;
|
||||
&>div{
|
||||
//display : flex;
|
||||
margin : 0 auto;
|
||||
// justify-content : center;
|
||||
}
|
||||
&.show{
|
||||
right : 350px;
|
||||
p{
|
||||
margin-bottom : 20px;
|
||||
font-size : 0.8em;
|
||||
}
|
||||
a.button{
|
||||
.animate(background-color);
|
||||
position : relative;
|
||||
display : block;
|
||||
height : 60px;
|
||||
max-width : 280px;
|
||||
width : 100%;
|
||||
margin : 15px;
|
||||
padding : 20px 30px;
|
||||
padding-left : 80px;
|
||||
cursor : pointer;
|
||||
background-color : fade(@red, 30%);
|
||||
color : black;
|
||||
text-align : left;
|
||||
text-decoration : none;
|
||||
//flex-grow : 0;
|
||||
display: inline-block;
|
||||
i{
|
||||
position : absolute;
|
||||
top : 15px;
|
||||
left : 25px;
|
||||
font-size : 2em;
|
||||
//transform-style: preserve-3d;
|
||||
transform: rotateY(0deg);
|
||||
}
|
||||
h3{
|
||||
display : block;
|
||||
margin-bottom : 3px;
|
||||
font-size : 1.2em;
|
||||
font-weight : 600;
|
||||
letter-spacing : 0.2em;
|
||||
}
|
||||
p{
|
||||
.fadeOutLeft();
|
||||
.keep();
|
||||
opacity : 0;
|
||||
font-size : 0.8em;
|
||||
}
|
||||
&:hover{
|
||||
background-color : fade(@red, 50%);
|
||||
p{
|
||||
.fadeInRight();
|
||||
}
|
||||
i{
|
||||
transform: rotateY(360deg);
|
||||
.animateAll(0.5s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.topBrews{
|
||||
background-image : url('/assets/homebrew/pages/homePage/phb_bg.jpg');
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// .vendor(@property, @value) {
|
||||
// -webkit-@{property}: @value;
|
||||
// -khtml-@{property}: @value;
|
||||
// -moz-@{property}: @value;
|
||||
// @{property}: @value;
|
||||
// }
|
||||
// .backgroundScrollAnimation(){
|
||||
// @top : -100px;
|
||||
// .vendor(animation-iteration-count, infinite);
|
||||
// .createAnimation(backgroundScroll, 60s, linear);
|
||||
// .backgroundScrollKeyFrames(){
|
||||
// 0% { background-position: 0 @top}
|
||||
// 100% { background-position: -1200px @top}
|
||||
// }
|
||||
// @-webkit-keyframes backgroundScroll {.backgroundScrollKeyFrames();}
|
||||
// @-moz-keyframes backgroundScroll {.backgroundScrollKeyFrames();}
|
||||
// @-ms-keyframes backgroundScroll {.backgroundScrollKeyFrames();}
|
||||
// @-o-keyframes backgroundScroll {.backgroundScrollKeyFrames();}
|
||||
// @keyframes backgroundScroll {.backgroundScrollKeyFrames();}
|
||||
// }
|
||||
BIN
client/homebrew/pages/homePage/phb_bg.jpg
Normal file
BIN
client/homebrew/pages/homePage/phb_bg.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 171 KiB |
@@ -1,6 +1,10 @@
|
||||
const React = require('react');
|
||||
const _ = require('lodash');
|
||||
const cx = require('classnames');
|
||||
|
||||
|
||||
const BrewRenderer = require('homebrewery/brewRenderer/brewRenderer.jsx');
|
||||
|
||||
const Markdown = require('homebrewery/markdown.js');
|
||||
|
||||
const Headtags = require('vitreum/headtags');
|
||||
@@ -30,7 +34,7 @@ const PrintPage = React.createClass({
|
||||
});
|
||||
}catch(e){}
|
||||
}
|
||||
if(this.props.query.dialog) window.print();
|
||||
//if(this.props.query.dialog) window.print();
|
||||
},
|
||||
//TODO: Print page shouldn't replicate functionality in brew renderer
|
||||
renderStyle : function(){
|
||||
@@ -58,8 +62,9 @@ const PrintPage = React.createClass({
|
||||
return <div className='printPage'>
|
||||
<Headtags.title>{this.state.brew.title}</Headtags.title>
|
||||
{this.renderPrintInstructions()}
|
||||
{this.renderStyle()}
|
||||
{this.renderPages()}
|
||||
|
||||
<BrewRenderer text={this.state.brew.text} style={this.state.brew.style} />
|
||||
|
||||
</div>
|
||||
}
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ const ReportIssue = require('../../navbar/issue.navitem.jsx');
|
||||
//const RecentlyViewed = require('../../navbar/recent.navitem.jsx').viewed;
|
||||
const Account = require('../../navbar/account.navitem.jsx');
|
||||
|
||||
const BrewRenderer = require('homebrewery/brewRenderer/brewRenderer.jsx');
|
||||
const BrewView = require('homebrewery/BrewView/BrewView.jsx');
|
||||
const Utils = require('homebrewery/utils.js');
|
||||
|
||||
const Actions = require('homebrewery/brew.actions.js');
|
||||
@@ -56,7 +56,7 @@ const SharePage = React.createClass({
|
||||
</Nav.section>
|
||||
|
||||
<Nav.section>
|
||||
<ReportIssue />
|
||||
<ReportIssue collaspe={true} />
|
||||
<PrintLink shareId={brew.shareId} />
|
||||
<Nav.item href={'/source/' + brew.shareId} color='teal' icon='fa-code'>
|
||||
source
|
||||
@@ -65,7 +65,7 @@ const SharePage = React.createClass({
|
||||
</Nav.section>
|
||||
</Navbar>
|
||||
<div className='content'>
|
||||
<BrewRenderer brew={brew} />
|
||||
<BrewView brew={brew}/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ const _ = require('lodash');
|
||||
const cx = require('classnames');
|
||||
const moment = require('moment');
|
||||
|
||||
//TODO: Depriacte
|
||||
|
||||
const BrewItem = React.createClass({
|
||||
getDefaultProps: function() {
|
||||
return {
|
||||
@@ -24,6 +26,7 @@ const BrewItem = React.createClass({
|
||||
},
|
||||
|
||||
render : function(){
|
||||
console.log('Brew Item should be depricated');
|
||||
const brew = this.props.brew;
|
||||
return <div className='brewItem'>
|
||||
<h2>{brew.title}</h2>
|
||||
|
||||
@@ -9,12 +9,12 @@ const RecentNavItem = require('../../navbar/recent.navitem.jsx');
|
||||
const Account = require('../../navbar/account.navitem.jsx');
|
||||
const BrewItem = require('./brewItem/brewItem.jsx');
|
||||
|
||||
const brew = {
|
||||
title : 'SUPER Long title woah now',
|
||||
authors : []
|
||||
}
|
||||
// const brew = {
|
||||
// title : 'SUPER Long title woah now',
|
||||
// authors : []
|
||||
// }
|
||||
|
||||
const BREWS = _.times(25, ()=>{ return brew});
|
||||
// const BREWS = _.times(25, ()=>{ return brew});
|
||||
|
||||
|
||||
const UserPage = React.createClass({
|
||||
@@ -29,7 +29,6 @@ const UserPage = React.createClass({
|
||||
if(!brews || !brews.length) return <div className='noBrews'>No Brews.</div>;
|
||||
|
||||
const sortedBrews = _.sortBy(brews, (brew)=>{ return brew.title; });
|
||||
|
||||
return _.map(sortedBrews, (brew, idx) => {
|
||||
return <BrewItem brew={brew} key={idx}/>
|
||||
});
|
||||
@@ -52,8 +51,6 @@ const UserPage = React.createClass({
|
||||
|
||||
render : function(){
|
||||
const brews = this.getSortedBrews();
|
||||
console.log('user brews', brews);
|
||||
|
||||
return <div className='userPage page'>
|
||||
<Navbar>
|
||||
<Nav.section>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"description": "Create authentic looking D&D homebrews using only markdown",
|
||||
"version": "3.0.0",
|
||||
"scripts": {
|
||||
"logs": "heroku logs -t --app=homebrewery",
|
||||
"dev": "node scripts/dev.js",
|
||||
"quick": "node scripts/quick.js",
|
||||
"build": "node scripts/build.js",
|
||||
@@ -29,7 +30,6 @@
|
||||
"jwt-simple": "^0.5.1",
|
||||
"lodash": "^4.17.3",
|
||||
"loglevel": "^1.4.1",
|
||||
"marked": "^0.3.5",
|
||||
"moment": "^2.11.0",
|
||||
"mongoose": "^4.3.3",
|
||||
"nconf": "^0.8.4",
|
||||
|
||||
@@ -3,18 +3,22 @@ const _ = require('lodash');
|
||||
|
||||
const DB = require('../server/db.js');
|
||||
const BrewData = require('../server/brew.data.js');
|
||||
const BrewGen = require('../test/brew.gen.js');
|
||||
//const BrewGen = require('../tests/brew.gen.js');
|
||||
|
||||
const BrewGen = require('../shared/homebrewery/snippets/brew/brew.snippet.js');
|
||||
|
||||
const BREW_COUNT = 50;
|
||||
|
||||
return Promise.resolve()
|
||||
.then(DB.connect)
|
||||
.then(BrewData.removeAll)
|
||||
.then(() => {
|
||||
console.log('Adding random brews...');
|
||||
return BrewGen.populateDB(BrewGen.random(50));
|
||||
return _.reduce(_.times(BREW_COUNT, BrewGen.brewModel), (flow, model)=>{
|
||||
return flow.then(()=>BrewData.create(model))
|
||||
}, Promise.resolve());
|
||||
})
|
||||
.then(() => {
|
||||
console.log('Adding specific brews...');
|
||||
return BrewGen.populateDB(BrewGen.static());
|
||||
console.log(`Added ${BREW_COUNT} brews`);
|
||||
})
|
||||
.then(() => {
|
||||
return DB.close();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const _ = require('lodash');
|
||||
|
||||
module.exports = (Brew) => {
|
||||
module.exports = (BrewModel) => {
|
||||
const cmds = {
|
||||
termSearch : (terms='', opts, fullAccess) => {
|
||||
let query = {};
|
||||
@@ -34,7 +34,8 @@ module.exports = (Brew) => {
|
||||
opts.page = _.toNumber(opts.page);
|
||||
|
||||
let filter = {
|
||||
text : 0
|
||||
text : 0,
|
||||
style : 0
|
||||
};
|
||||
|
||||
if(!fullAccess){
|
||||
@@ -42,7 +43,7 @@ module.exports = (Brew) => {
|
||||
queryObj.published = true;
|
||||
}
|
||||
|
||||
const searchQuery = Brew
|
||||
const searchQuery = BrewModel
|
||||
.find(queryObj)
|
||||
.sort(opts.sort)
|
||||
.select(filter)
|
||||
@@ -51,7 +52,7 @@ module.exports = (Brew) => {
|
||||
.lean()
|
||||
.exec();
|
||||
|
||||
const countQuery = Brew.count(queryObj).exec();
|
||||
const countQuery = BrewModel.count(queryObj).exec();
|
||||
|
||||
return Promise.all([searchQuery, countQuery])
|
||||
.then((result) => {
|
||||
|
||||
@@ -16,6 +16,20 @@ const statics = {
|
||||
oldTest : fs.readFileSync('./statics/oldTest.brew.md', 'utf8'),
|
||||
};
|
||||
|
||||
let topBrews = [];
|
||||
const getTopBrews = ()=>{
|
||||
//Add in filter of last 2 weeks
|
||||
return BrewData.search({}, {
|
||||
limit : 4,
|
||||
sort : {views : -1}
|
||||
}, false).then(({brews, total})=>brews);
|
||||
};
|
||||
|
||||
getTopBrews().then((brews)=>{
|
||||
topBrews=brews;
|
||||
});
|
||||
|
||||
|
||||
|
||||
const vitreumRender = require('vitreum/steps/render');
|
||||
const templateFn = require('../client/template.js');
|
||||
@@ -30,9 +44,7 @@ const renderPage = (req, res, next) => {
|
||||
brews : req.brews,
|
||||
brew : req.brew
|
||||
})
|
||||
.then((page) => {
|
||||
return res.send(page)
|
||||
})
|
||||
.then((page)=>res.send(page))
|
||||
.catch(next);
|
||||
};
|
||||
|
||||
@@ -54,9 +66,18 @@ router.get('/source/:sharedId', mw.viewBrew, (req, res, next)=>{
|
||||
});
|
||||
|
||||
//User Page
|
||||
router.get('/account', (req, res, next)=>{
|
||||
if(req.account && req.account.username){
|
||||
return res.redirect(`/user/${req.account.username}`);
|
||||
}else{
|
||||
return res.redirect(`${config.get('login_path')}?redirect=${encodeURIComponent(req.headers.referer)}`);
|
||||
}
|
||||
});
|
||||
router.get('/user/:username', (req, res, next) => {
|
||||
BrewData.search({ user : req.params.username })
|
||||
.then((brews) => {
|
||||
const isSelf = req.account && req.params.username == req.account.username;
|
||||
|
||||
BrewData.userSearch(req.params.username, isSelf)
|
||||
.then(({brews, total}) => {
|
||||
req.brews = brews;
|
||||
return next();
|
||||
})
|
||||
@@ -99,7 +120,8 @@ router.get('/new', renderPage);
|
||||
|
||||
//Home Page
|
||||
router.get('/', (req, res, next) => {
|
||||
req.brew = { text : statics.welcomeBrew };
|
||||
req.brews = topBrews;
|
||||
console.log(topBrews);
|
||||
return next();
|
||||
}, renderPage);
|
||||
|
||||
|
||||
30
shared/homebrewery/brewCard/brewCard.jsx
Normal file
30
shared/homebrewery/brewCard/brewCard.jsx
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
const React = require('react');
|
||||
const _ = require('lodash');
|
||||
const cx = require('classnames');
|
||||
|
||||
const BrewCard = React.createClass({
|
||||
getDefaultProps: function() {
|
||||
return {
|
||||
brew : {
|
||||
shareId : '',
|
||||
title : '',
|
||||
description : '',
|
||||
|
||||
views : 0,
|
||||
|
||||
editId : false
|
||||
}
|
||||
};
|
||||
},
|
||||
render: function(){
|
||||
const brew = this.props.brew;
|
||||
return <div className='brewCard'>
|
||||
<h3>{brew.title}</h3>
|
||||
<p>{brew.description}</p>
|
||||
|
||||
</div>
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = BrewCard;
|
||||
10
shared/homebrewery/brewCard/brewCard.less
Normal file
10
shared/homebrewery/brewCard/brewCard.less
Normal file
@@ -0,0 +1,10 @@
|
||||
.brewCard{
|
||||
width : 300px;
|
||||
height : 100px;
|
||||
|
||||
//border : 1px solid black;
|
||||
background-image : url('/assets/homebrewery/brewCard/monster_bg.jpg');
|
||||
|
||||
position : relative;
|
||||
|
||||
}
|
||||
BIN
shared/homebrewery/brewCard/monster_bg.jpg
Normal file
BIN
shared/homebrewery/brewCard/monster_bg.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 339 KiB |
BIN
shared/homebrewery/brewCard/note_border.png
Normal file
BIN
shared/homebrewery/brewCard/note_border.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 530 B |
BIN
shared/homebrewery/brewCard/note_border_shadow.png
Normal file
BIN
shared/homebrewery/brewCard/note_border_shadow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
@@ -2,31 +2,27 @@ const React = require('react');
|
||||
const _ = require('lodash');
|
||||
const cx = require('classnames');
|
||||
|
||||
//TODO: Convert old renderer to just be the old markdown parser
|
||||
const OldBrewRenderer = require('depricated/brewRendererOld/brewRendererOld.jsx');
|
||||
|
||||
const Markdown = require('homebrewery/markdown.js');
|
||||
const ErrorBar = require('./errorBar/errorBar.jsx');
|
||||
|
||||
const RenderWarnings = require('homebrewery/renderWarnings/renderWarnings.jsx')
|
||||
const Store = require('homebrewery/brew.store.js');
|
||||
|
||||
|
||||
const PAGE_HEIGHT = 1056;
|
||||
const PPR_THRESHOLD = 50;
|
||||
const PPR_RANGE = 0;
|
||||
|
||||
const BrewRenderer = React.createClass({
|
||||
getDefaultProps: function() {
|
||||
return {
|
||||
brew : {
|
||||
text : '',
|
||||
style : ''
|
||||
},
|
||||
text : '',
|
||||
style : '',
|
||||
|
||||
version : 2,
|
||||
|
||||
//TODO: maybe remove?
|
||||
errors : []
|
||||
//usePPR : false // TODO: maybe make this into an page index to render
|
||||
|
||||
pprPage : false
|
||||
};
|
||||
},
|
||||
/*
|
||||
getInitialState: function() {
|
||||
const pages = this.props.brew.text.split('\\page');
|
||||
|
||||
@@ -40,8 +36,12 @@ const BrewRenderer = React.createClass({
|
||||
},
|
||||
height : 0,
|
||||
pageHeight : PAGE_HEIGHT,
|
||||
|
||||
*/
|
||||
lastRender : <div></div>,
|
||||
|
||||
/*
|
||||
|
||||
componentDidMount: function() {
|
||||
this.updateSize();
|
||||
window.addEventListener('resize', this.updateSize);
|
||||
@@ -72,16 +72,14 @@ const BrewRenderer = React.createClass({
|
||||
});
|
||||
},
|
||||
|
||||
handleScroll : function(e){
|
||||
this.setState({
|
||||
viewablePageNumber : Math.floor(e.target.scrollTop / this.pageHeight)
|
||||
});
|
||||
},
|
||||
|
||||
*/
|
||||
|
||||
shouldRender : function(pageText, index){
|
||||
if(!this.state.isMounted) return false;
|
||||
|
||||
var viewIndex = this.state.viewablePageNumber;
|
||||
//TODO: increase range, make into a simple function with lodash
|
||||
if(index == viewIndex - 1) return true;
|
||||
if(index == viewIndex) return true;
|
||||
if(index == viewIndex + 1) return true;
|
||||
@@ -92,12 +90,8 @@ const BrewRenderer = React.createClass({
|
||||
return false;
|
||||
},
|
||||
|
||||
renderPageInfo : function(){
|
||||
return <div className='pageInfo'>
|
||||
{this.state.viewablePageNumber + 1} / {this.state.pages.length}
|
||||
</div>
|
||||
},
|
||||
|
||||
/*
|
||||
renderPPRmsg : function(){
|
||||
if(!this.state.usePPR) return;
|
||||
|
||||
@@ -105,18 +99,25 @@ const BrewRenderer = React.createClass({
|
||||
Partial Page Renderer enabled, because your brew is so large. May effect rendering.
|
||||
</div>
|
||||
},
|
||||
*/
|
||||
|
||||
renderDummyPage : function(index){
|
||||
return <div className='phb v2' id={`p${index + 1}`} key={index}>
|
||||
<i className='fa fa-spinner fa-spin' />
|
||||
</div>
|
||||
},
|
||||
|
||||
renderPage : function(pageText, index){
|
||||
return <div className='phb v2' id={`p${index + 1}`} dangerouslySetInnerHTML={{__html:Markdown.render(pageText)}} key={index} />
|
||||
const html = Markdown.render(pageText);
|
||||
return <div className='phb v2' id={`p${index + 1}`} dangerouslySetInnerHTML={{__html:html}} key={index} />
|
||||
},
|
||||
|
||||
renderPPR : function(pages, pprPageIndex){
|
||||
return _.map(pages, (page, index)=>{
|
||||
if(_.inRange(index, pprPageIndex - PPR_RANGE, pprPageIndex + PPR_RANGE +1)){
|
||||
this.renderPage(page, index);
|
||||
}
|
||||
return <div className='phb v2' id={`p${index + 1}`} key={index} />;
|
||||
});
|
||||
},
|
||||
|
||||
renderPages : function(){
|
||||
/*
|
||||
if(this.state.usePPR){
|
||||
return _.map(this.state.pages, (page, index)=>{
|
||||
if(this.shouldRender(page, index)){
|
||||
@@ -126,38 +127,33 @@ const BrewRenderer = React.createClass({
|
||||
}
|
||||
});
|
||||
}
|
||||
if(this.props.errors && this.props.errors.length) return this.lastRender;
|
||||
this.lastRender = _.map(this.state.pages, (page, index)=>{
|
||||
return this.renderPage(page, index);
|
||||
});
|
||||
return this.lastRender;
|
||||
*/
|
||||
const pages = this.props.text.split('\\page');
|
||||
|
||||
console.log(this.props.pprPage);
|
||||
|
||||
if(this.props.pprPage !== false) return this.renderPPR(pages, this.props.pprPage);
|
||||
|
||||
return _.map(pages, (page, index)=>this.renderPage(page, index));
|
||||
|
||||
//TODO: See if you need error handling?
|
||||
//if(this.props.errors && this.props.errors.length) return this.lastRender;
|
||||
|
||||
},
|
||||
|
||||
//TODO: This is pretty bad
|
||||
renderStyle : function(){
|
||||
return <style>{this.props.brew.style.replace(/;/g, ' !important;')}</style>
|
||||
return <style>{this.props.style.replace(/;/g, ' !important;')}</style>
|
||||
},
|
||||
|
||||
render : function(){
|
||||
if(this.props.brew.version == 1) return <OldBrewRenderer value={this.props.brew.text} />;
|
||||
|
||||
|
||||
return <div className='brewRenderer'
|
||||
onScroll={this.handleScroll}
|
||||
ref='main'
|
||||
style={{height : this.state.height}}>
|
||||
|
||||
<ErrorBar errors={this.props.errors} />
|
||||
<RenderWarnings />
|
||||
//TODO: Add in the brew version check
|
||||
//if(this.props.brew.version == 1) return <OldBrewRenderer value={this.props.brew.text} />;
|
||||
|
||||
|
||||
return <div className='brewRenderer'>
|
||||
{this.renderStyle()}
|
||||
|
||||
<div className='pages' ref='pages'>
|
||||
{this.renderPages()}
|
||||
</div>
|
||||
{this.renderPageInfo()}
|
||||
{this.renderPPRmsg()}
|
||||
{this.renderPages()}
|
||||
</div>
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,39 +1,2 @@
|
||||
|
||||
@import (less) './shared/homebrewery/phb_style/phb.less';
|
||||
.pane{
|
||||
position : relative;
|
||||
}
|
||||
.brewRenderer{
|
||||
overflow-y : scroll;
|
||||
.pageInfo{
|
||||
position : absolute;
|
||||
right : 17px;
|
||||
bottom : 0;
|
||||
z-index : 1000;
|
||||
padding : 8px 10px;
|
||||
background-color : #333;
|
||||
font-size : 10px;
|
||||
font-weight : 800;
|
||||
color : white;
|
||||
}
|
||||
.ppr_msg{
|
||||
position : absolute;
|
||||
left : 0px;
|
||||
bottom : 0;
|
||||
z-index : 1000;
|
||||
padding : 8px 10px;
|
||||
background-color : #333;
|
||||
font-size : 10px;
|
||||
font-weight : 800;
|
||||
color : white;
|
||||
}
|
||||
.pages{
|
||||
margin : 30px 0px;
|
||||
&>.phb{
|
||||
margin-right : auto;
|
||||
margin-bottom : 30px;
|
||||
margin-left : auto;
|
||||
box-shadow : 1px 4px 14px #000;
|
||||
}
|
||||
}
|
||||
}
|
||||
84
shared/homebrewery/brewView/brewView.jsx
Normal file
84
shared/homebrewery/brewView/brewView.jsx
Normal file
@@ -0,0 +1,84 @@
|
||||
|
||||
const React = require('react');
|
||||
const _ = require('lodash');
|
||||
const cx = require('classnames');
|
||||
|
||||
|
||||
//const ErrorBar = require('./errorBar/errorBar.jsx');
|
||||
|
||||
const RenderWarnings = require('homebrewery/renderWarnings/renderWarnings.jsx');
|
||||
//const Store = require('homebrewery/brew.store.js');
|
||||
|
||||
const PAGE_HEIGHT = 1056;
|
||||
|
||||
|
||||
const BrewRenderer = require('../brewRenderer/brewRenderer.jsx');
|
||||
|
||||
|
||||
const BrewView = React.createClass({
|
||||
getDefaultProps: function() {
|
||||
return {
|
||||
brew : {
|
||||
text : '',
|
||||
style : ''
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
},
|
||||
getInitialState: function() {
|
||||
const pages = this.props.brew.text.split('\\page');
|
||||
|
||||
return {
|
||||
viewablePageNumber: 0,
|
||||
//height : 0,
|
||||
//isMounted : false,
|
||||
//TODO: Change to page count ?
|
||||
pages : pages,
|
||||
};
|
||||
},
|
||||
|
||||
//height : 0,
|
||||
pageHeight : PAGE_HEIGHT,
|
||||
|
||||
componentWillReceiveProps: function(nextProps) {
|
||||
//if(this.refs.pages && this.refs.pages.firstChild) this.pageHeight = this.refs.pages.firstChild.clientHeight;
|
||||
|
||||
const pages = nextProps.brew.text.split('\\page');
|
||||
this.setState({
|
||||
pages : pages,
|
||||
//usePPR : pages.length >= PPR_THRESHOLD
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
handleScroll : function(e){
|
||||
this.setState({
|
||||
viewablePageNumber : Math.floor(e.target.scrollTop / PAGE_HEIGHT) //this.pageHeight)
|
||||
});
|
||||
},
|
||||
|
||||
renderPageInfo : function(){
|
||||
return <div className='pageInfo'>
|
||||
{this.state.viewablePageNumber + 1} / {this.state.pages.length}
|
||||
</div>
|
||||
},
|
||||
|
||||
|
||||
render: function(){
|
||||
return <div className='brewView' onScroll={this.handleScroll}>
|
||||
|
||||
<BrewRenderer
|
||||
text={this.props.brew.text}
|
||||
style={this.props.brew.style}
|
||||
version={this.props.brew.version}
|
||||
pprPage={2}
|
||||
/>
|
||||
|
||||
|
||||
{this.renderPageInfo()}
|
||||
</div>
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = BrewView;
|
||||
42
shared/homebrewery/brewView/brewView.less
Normal file
42
shared/homebrewery/brewView/brewView.less
Normal file
@@ -0,0 +1,42 @@
|
||||
.pane{
|
||||
position : relative;
|
||||
}
|
||||
|
||||
.brewView{
|
||||
overflow-y : scroll;
|
||||
height : 100%;
|
||||
|
||||
.pageInfo{
|
||||
position : absolute;
|
||||
right : 17px;
|
||||
bottom : 0;
|
||||
z-index : 1000;
|
||||
padding : 8px 10px;
|
||||
background-color : #333;
|
||||
font-size : 10px;
|
||||
font-weight : 800;
|
||||
color : white;
|
||||
}
|
||||
/*
|
||||
.ppr_msg{
|
||||
position : absolute;
|
||||
left : 0px;
|
||||
bottom : 0;
|
||||
z-index : 1000;
|
||||
padding : 8px 10px;
|
||||
background-color : #333;
|
||||
font-size : 10px;
|
||||
font-weight : 800;
|
||||
color : white;
|
||||
}
|
||||
*/
|
||||
.brewRenderer{
|
||||
margin : 30px 0px;
|
||||
&>.phb{
|
||||
margin-right : auto;
|
||||
margin-bottom : 30px;
|
||||
margin-left : auto;
|
||||
box-shadow : 1px 4px 14px #000;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
shared/homebrewery/brewView/brewView.smart.jsx
Normal file
11
shared/homebrewery/brewView/brewView.smart.jsx
Normal file
@@ -0,0 +1,11 @@
|
||||
//const Actions = require('homebrewery/brew.actions.js');
|
||||
const Store = require('homebrewery/brew.store.js');
|
||||
|
||||
const BrewView = require('./brewView.jsx')
|
||||
|
||||
module.exports = Store.createSmartComponent(BrewView, ()=>{
|
||||
return {
|
||||
brew : Store.getBrew()
|
||||
|
||||
};
|
||||
});
|
||||
@@ -1,5 +1,6 @@
|
||||
const _ = require('lodash');
|
||||
const Markdown = require('marked');
|
||||
//const Markdown = require('marked');
|
||||
const Markdown = require('./marked.lib.js');
|
||||
|
||||
|
||||
const renderer = new Markdown.Renderer();
|
||||
@@ -10,7 +11,9 @@ renderer.paragraph = function(text){
|
||||
if(!matches) return `\n<p>${text}</p>\n`;
|
||||
let matchIndex = 0;
|
||||
const res = _.reduce(text.split(blockReg), (r, text) => {
|
||||
//if(text) r.push(text);
|
||||
if(text) r.push(Markdown(text, {renderer : renderer, sanitize: true}));
|
||||
|
||||
const block = matches[matchIndex];
|
||||
if(block && block[0] == '{'){
|
||||
r.push(`\n\n<div class="block ${block.substring(2).split(',').join(' ')}">`);
|
||||
@@ -25,10 +28,14 @@ renderer.paragraph = function(text){
|
||||
}, []).join('\n');
|
||||
return res;
|
||||
};
|
||||
|
||||
renderer.image = function(href, title, text){
|
||||
return `<img src="${href}" class="${text.split(',').join(' ')}"></img>`;
|
||||
};
|
||||
renderer.list = function(list, isOrdered, isDef){
|
||||
if(isDef) return `<ul class='alt'>${list}</ul>`;
|
||||
if(isOrdered) return `<ol>${list}</ol>`;
|
||||
return `<ul>${list}</ul>`;
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
@@ -36,9 +43,12 @@ module.exports = {
|
||||
render : (rawBrewText)=>{
|
||||
blockCount = 0;
|
||||
|
||||
rawBrewText = rawBrewText.replace(/\\column/g, '{{columnSplit }}')
|
||||
rawBrewText = rawBrewText.replace(/\\column/g, '{{columnSplit }}');
|
||||
|
||||
|
||||
let html = Markdown(rawBrewText,{renderer : renderer, sanitize: true});
|
||||
|
||||
|
||||
let html = Markdown(rawBrewText, {renderer : renderer, sanitize: true});
|
||||
//Close all hanging block tags
|
||||
html += _.times(blockCount, ()=>{return '</div>'}).join('\n');
|
||||
return html;
|
||||
|
||||
1288
shared/homebrewery/marked.lib.js
Normal file
1288
shared/homebrewery/marked.lib.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,7 @@
|
||||
|
||||
///////////////////
|
||||
.spell{
|
||||
ul:first-of-type{
|
||||
margin-top : -0.5em;
|
||||
margin-bottom : 0.5em;
|
||||
|
||||
list-style-type : none;
|
||||
&+p{
|
||||
text-indent : 0em;
|
||||
}
|
||||
}
|
||||
}
|
||||
.monster{
|
||||
.breakAvoid();
|
||||
@@ -23,10 +15,6 @@
|
||||
tbody tr { background-color: transparent };
|
||||
}
|
||||
ul:nth-of-type(1),ul:nth-of-type(2){
|
||||
list-style: none;
|
||||
padding-left : 1em;
|
||||
text-indent : -1em;
|
||||
margin-bottom : 0.5em;
|
||||
strong{
|
||||
color : @crimson;
|
||||
}
|
||||
@@ -36,6 +24,7 @@
|
||||
right : 7px;
|
||||
bottom : 19px;
|
||||
left : 7px;
|
||||
//TODO: Swap out to variable color
|
||||
background-color : #FDF1DC;
|
||||
border-image-slice : 8;
|
||||
border-image-source : @monsterBorder;
|
||||
@@ -43,6 +32,7 @@
|
||||
}
|
||||
&.wide{
|
||||
column-count : 2;
|
||||
column-fill:auto;
|
||||
}
|
||||
}
|
||||
.note{
|
||||
@@ -104,7 +94,7 @@
|
||||
z-index : 150;
|
||||
width : 200px;
|
||||
font-size : 0.9em;
|
||||
color : @gold;
|
||||
color : @brown;
|
||||
text-align : right;
|
||||
}
|
||||
//*****************************
|
||||
@@ -161,38 +151,44 @@
|
||||
}
|
||||
.wide{
|
||||
column-span : all;
|
||||
-webkit-column-span : all;
|
||||
-moz-column-span : all;
|
||||
}
|
||||
.fullPage, .full{
|
||||
column-span : all;
|
||||
height: 100%;
|
||||
}
|
||||
.oneColumn{
|
||||
column-count : 1;
|
||||
column-fill:auto;
|
||||
// column-gap : 1cm;
|
||||
}
|
||||
.twoColumn{
|
||||
column-count : 2;
|
||||
column-fill:auto;
|
||||
//column-fill: auto;
|
||||
////column-gap : 1cm;
|
||||
}
|
||||
.threeColumn{
|
||||
column-count : 3;
|
||||
column-fill:auto;
|
||||
//column-gap : 1cm;
|
||||
}
|
||||
.fourColumn{
|
||||
column-count : 4;
|
||||
//column-gap : 1cm;
|
||||
column-fill:auto;
|
||||
}
|
||||
.columnSplit{
|
||||
visibility : hidden;
|
||||
-webkit-column-break-bfore : always;
|
||||
break-before : column;
|
||||
}
|
||||
.brushed{
|
||||
border-image-outset : 25px 17px;
|
||||
border-image-repeat : round;
|
||||
border-image-slice : 1250 1250 1250 1250;
|
||||
border-image-width : 1250px;
|
||||
border-image-source : url('http : //i.imgur.com/nzPYZyD.png');
|
||||
}
|
||||
// .brushed{
|
||||
// border-image-outset : 25px 17px;
|
||||
// border-image-repeat : round;
|
||||
// border-image-slice : 1250 1250 1250 1250;
|
||||
// border-image-width : 1250px;
|
||||
// border-image-source : url('http://i.imgur.com/nzPYZyD.png');
|
||||
// }
|
||||
//basics
|
||||
.left{
|
||||
text-align : left;
|
||||
@@ -208,4 +204,13 @@
|
||||
}
|
||||
.sansSerif{
|
||||
.useSansSerif();
|
||||
}
|
||||
.dropcap{
|
||||
p::first-letter{
|
||||
float : left;
|
||||
font-family : Solbera;
|
||||
font-size : 10em;
|
||||
color : #222;
|
||||
line-height : 0.8em;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,13 @@
|
||||
//TODO: come up with fun color names
|
||||
|
||||
@crimson : #58180D;
|
||||
@red : #9c2b1b;
|
||||
@brown : #c9ad6a; //brown?
|
||||
@green : #e0e5c1;
|
||||
@yellow : #faf7ea; //same as background?
|
||||
@teal : blue;
|
||||
@blue : blue;
|
||||
|
||||
@background : #EEE5CE;
|
||||
@noteGreen : #e0e5c1;
|
||||
@headerUnderline : #c9ad6a;
|
||||
@@ -20,13 +28,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@crimson : #58180D;
|
||||
@red : #9c2b1b;
|
||||
@gold : #c9ad6a; //brown?
|
||||
@green : #e0e5c1;
|
||||
@yellow : #faf7ea; //same as background?
|
||||
@teal : blue;
|
||||
@blue : blue;
|
||||
|
||||
|
||||
|
||||
//TODO make a color mixin generator
|
||||
@@ -34,5 +36,6 @@
|
||||
.blue{ .colorElements(@blue); }
|
||||
.green{ .colorElements(@green); }
|
||||
.yellow{ .colorElements(@yellow); }
|
||||
.gold{ .colorElements(@gold); }
|
||||
.red{ .colorElements(@red); }
|
||||
.brown{ .colorElements(fade(@brown, 50%)); }
|
||||
.red{ .colorElements(fade(@red, 25%)); }
|
||||
.crimson{ .colorElements(fade(@crimson, 20%)); }
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
|
||||
pre{
|
||||
font-family : monospace;
|
||||
background-color : @yellow;
|
||||
padding : 12px;
|
||||
border: 1px solid #bfbfbf;
|
||||
white-space: pre-wrap;
|
||||
color : #333;
|
||||
padding : 12px;
|
||||
background-color : @yellow;
|
||||
font-family : monospace;
|
||||
color : #333;
|
||||
border : 1px solid #bfbfbf;
|
||||
white-space : pre-wrap;
|
||||
-webkit-column-break-inside : avoid;
|
||||
column-break-inside : avoid;
|
||||
}
|
||||
|
||||
|
||||
hr{
|
||||
visibility : visible;
|
||||
height : 6px;
|
||||
@@ -18,8 +17,6 @@ hr{
|
||||
background-size : 100% 100%;
|
||||
border : none;
|
||||
}
|
||||
|
||||
|
||||
p{
|
||||
padding-bottom : 0.8em;
|
||||
line-height : 1.3em;
|
||||
@@ -27,35 +24,42 @@ p{
|
||||
margin-top : -0.8em;
|
||||
}
|
||||
}
|
||||
|
||||
blockquote{
|
||||
font-style : italic;
|
||||
&>p{
|
||||
line-height: 1.8em;
|
||||
line-height : 1.8em;
|
||||
//Why did I do this?
|
||||
&:first-child::first-line{
|
||||
|
||||
font-family : ScalySansSmallCaps;
|
||||
//TODO: Find the right font for block quotes
|
||||
font-style: normal;
|
||||
font-family: ScalySansSmallCaps;
|
||||
|
||||
|
||||
font-style : normal;
|
||||
}
|
||||
}
|
||||
.cite{
|
||||
font-style: normal;
|
||||
text-align: right;
|
||||
font-style : normal;
|
||||
text-align : right;
|
||||
}
|
||||
}
|
||||
// IMAGE
|
||||
img{
|
||||
display : block;
|
||||
z-index : -1;
|
||||
mix-blend-mode : multiply;
|
||||
&.center{
|
||||
margin-right : auto;
|
||||
margin-left : auto;
|
||||
}
|
||||
&.noBlend{
|
||||
mix-blend-mode : normal;
|
||||
}
|
||||
&.bg, &.background{
|
||||
position : absolute;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Indents after p or lists
|
||||
p+p, ul+p, ol+p{
|
||||
text-indent : 1em;
|
||||
}
|
||||
img{
|
||||
z-index : -1;
|
||||
}
|
||||
strong{
|
||||
font-weight : bold;
|
||||
letter-spacing : 0.03em;
|
||||
@@ -88,13 +92,6 @@ h1{
|
||||
font-size : 0.987cm;
|
||||
-webkit-column-span : all;
|
||||
-moz-column-span : all;
|
||||
&+p::first-letter{
|
||||
float : left;
|
||||
font-family : Solbera;
|
||||
font-size : 10em;
|
||||
color : #222;
|
||||
line-height : 0.8em;
|
||||
}
|
||||
}
|
||||
h2{
|
||||
font-size : 0.705cm;
|
||||
@@ -113,8 +110,6 @@ h5{
|
||||
font-size : 0.423cm;
|
||||
font-weight : 900;
|
||||
}
|
||||
|
||||
|
||||
//******************************
|
||||
// LISTS
|
||||
//******************************
|
||||
@@ -141,7 +136,19 @@ ol{
|
||||
list-style-type : decimal;
|
||||
}
|
||||
|
||||
|
||||
p+ul.alt{
|
||||
margin-top : -0.5em;
|
||||
}
|
||||
ul.alt{
|
||||
margin-bottom : 0.5em;
|
||||
padding-left : 0em;
|
||||
list-style-position : outside;
|
||||
list-style-type : none;
|
||||
list-style-type : none;
|
||||
&+p{
|
||||
text-indent : 0em;
|
||||
}
|
||||
}
|
||||
//*****************************
|
||||
// * TABLE
|
||||
// *****************************/
|
||||
@@ -150,6 +157,7 @@ table{
|
||||
width : 100%;
|
||||
margin-bottom : 1em;
|
||||
font-size : 10pt;
|
||||
break-inside : avoid-column;
|
||||
thead{
|
||||
font-weight : 800;
|
||||
th{
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
background-size : cover;
|
||||
padding: 28px 63px;
|
||||
box-sizing: border-box;
|
||||
color : lighten(@gold, 0%);
|
||||
color : lighten(@brown, 0%);
|
||||
font-size: 0.7em;
|
||||
}
|
||||
&:nth-child(even){
|
||||
@@ -81,7 +81,7 @@
|
||||
bottom : 22px;
|
||||
width : 50px;
|
||||
font-size : 0.9em;
|
||||
color : @gold;
|
||||
color : @brown;
|
||||
text-align : center;
|
||||
}
|
||||
|
||||
|
||||
74
shared/homebrewery/snippets/brew/brew.snippet.js
Normal file
74
shared/homebrewery/snippets/brew/brew.snippet.js
Normal file
@@ -0,0 +1,74 @@
|
||||
const _ = require('lodash');
|
||||
const Data = require('./random.data.js');
|
||||
|
||||
|
||||
const Snips = _.merge(
|
||||
require('./spell.snippet.js'),
|
||||
require('./table.snippet.js'),
|
||||
require('./class.snippet.js'),
|
||||
require('./note.snippet.js'),
|
||||
require('./monster.snippet.js')
|
||||
);
|
||||
|
||||
const BrewSnippets = {
|
||||
brewModel : ()=>{
|
||||
return {
|
||||
title : Data.rand(Data.titles),
|
||||
description : Data.rand(Data.subtitles),
|
||||
text : BrewSnippets.brew(),
|
||||
|
||||
authors : _.sampleSize(['userA','userB','userC','userD'], _.random(0, 3)),
|
||||
systems : _.sampleSize(['5e', '4e', '3.5e', 'Pathfinder'], _.random(0,2)),
|
||||
views : _.random(0,1000),
|
||||
published : !!_.random(0,1)
|
||||
}
|
||||
},
|
||||
brew : ()=>{
|
||||
return _.times(_.random(1,10), ()=>_.sample([
|
||||
BrewSnippets.page1,
|
||||
BrewSnippets.page2
|
||||
])()).join('\n\n\\page\n\n');
|
||||
},
|
||||
|
||||
page1 : ()=>{
|
||||
return BrewSnippets.filler(_.random(10, 15), [Snips.monster, Snips.table]);
|
||||
},
|
||||
|
||||
page2 : ()=>{
|
||||
const title = '# ' + Data.rand('titles');
|
||||
let table = Snips.noncasterTable();
|
||||
|
||||
if(Data.chance(3)){
|
||||
table = Snips.casterTable();
|
||||
if(Data.chance(2)) table = Snips.halfcasterTable();
|
||||
return `${title}\n\n${table}\n\n${BrewSnippets.paragraph(true)}\n\n${BrewSnippets.filler(3)}`;
|
||||
}
|
||||
return `${title}\n\n${table}\n\n${BrewSnippets.paragraph(true)}\n\n${BrewSnippets.filler(5)}`;
|
||||
},
|
||||
|
||||
filler : (count = 1, additional = [])=>{
|
||||
const base = _.concat([
|
||||
BrewSnippets.paragraph, BrewSnippets.paragraph, BrewSnippets.paragraph, BrewSnippets.paragraph,
|
||||
BrewSnippets.paragraph, BrewSnippets.paragraph, BrewSnippets.paragraph, BrewSnippets.paragraph,
|
||||
Snips.table,
|
||||
Snips.note, Snips.note, Snips.altnote
|
||||
], additional);
|
||||
return _.times(count, ()=>{
|
||||
let res = _.sample(base)();
|
||||
if(Data.chance(8)) res = BrewSnippets.title() + '\n\n' + res;
|
||||
return res;
|
||||
}).join('\n\n');
|
||||
},
|
||||
|
||||
paragraph : (dropcap = false)=>{
|
||||
let res = Data.rand(Data.sentences, 6, 3).join(' ');
|
||||
if(dropcap || Data.chance(20)) res = `{{dropcap\n${res}\n}}`;
|
||||
return res;
|
||||
},
|
||||
|
||||
title : ()=>{
|
||||
return _.sample(['##', '###', '##', '###','####', '#####']) + ' ' + Data.rand('titles');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BrewSnippets;
|
||||
@@ -11,6 +11,52 @@ const getFeature = (level)=>{
|
||||
return res.join(', ');
|
||||
};
|
||||
|
||||
const spellLevels = [
|
||||
[2,'―','―','―','―','―','―','―','―'],
|
||||
[3,'―','―','―','―','―','―','―','―'],
|
||||
[4, 2 ,'―','―','―','―','―','―','―'],
|
||||
[4, 3 ,'―','―','―','―','―','―','―'],
|
||||
[4, 3 , 2 ,'―','―','―','―','―','―'],
|
||||
[4, 3 , 3 ,'―','―','―','―','―','―'],
|
||||
[4, 3 , 3 , 1 ,'―','―','―','―','―'],
|
||||
[4, 3 , 3 , 2 ,'―','―','―','―','―'],
|
||||
[4, 3 , 3 , 3 , 1 ,'―','―','―','―'],
|
||||
[4, 3 , 3 , 3 , 2 ,'―','―','―','―'],
|
||||
[4, 3 , 3 , 3 , 2 , 1 ,'―','―','―'],
|
||||
[4, 3 , 3 , 3 , 2 , 1 ,'―','―','―'],
|
||||
[4, 3 , 3 , 3 , 2 , 1 , 1 ,'―','―'],
|
||||
[4, 3 , 3 , 3 , 2 , 1 , 1 ,'―','―'],
|
||||
[4, 3 , 3 , 3 , 2 , 1 , 1 , 1 ,'―'],
|
||||
[4, 3 , 3 , 3 , 2 , 1 , 1 , 1 ,'―'],
|
||||
[4, 3 , 3 , 3 , 2 , 1 , 1 , 1 , 1 ],
|
||||
[4, 3 , 3 , 3 , 3 , 1 , 1 , 1 , 1 ],
|
||||
[4, 3 , 3 , 3 , 3 , 2 , 1 , 1 , 1 ],
|
||||
[4, 3 , 3 , 3 , 3 , 2 , 2 , 1 , 1 ]
|
||||
];
|
||||
|
||||
const halfspellLevels = [
|
||||
['―','―','―','―','―'],
|
||||
[ 2 ,'―','―','―','―'],
|
||||
[ 3 ,'―','―','―','―'],
|
||||
[ 3 ,'―','―','―','―'],
|
||||
[ 4 , 2 ,'―','―','―'],
|
||||
[ 4 , 2 ,'―','―','―'],
|
||||
[ 4 , 3 ,'―','―','―'],
|
||||
[ 4 , 3 ,'―','―','―'],
|
||||
[ 4 , 3 , 2 ,'―','―'],
|
||||
[ 4 , 3 , 2 ,'―','―'],
|
||||
[ 4 , 3 , 3 ,'―','―'],
|
||||
[ 4 , 3 , 3 ,'―','―'],
|
||||
[ 4 , 3 , 3 , 1 ,'―'],
|
||||
[ 4 , 3 , 3 , 1 ,'―'],
|
||||
[ 4 , 3 , 3 , 2 ,'―'],
|
||||
[ 4 , 3 , 3 , 2 ,'―'],
|
||||
[ 4 , 3 , 3 , 3 , 1 ],
|
||||
[ 4 , 3 , 3 , 3 , 1 ],
|
||||
[ 4 , 3 , 3 , 3 , 2 ],
|
||||
[ 4 , 3 , 3 , 3 , 2 ]
|
||||
];
|
||||
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -23,13 +69,15 @@ module.exports = {
|
||||
lvlText,
|
||||
'+'+Math.floor(level/4 + 2),
|
||||
getFeature(level),
|
||||
'+'+featureScore
|
||||
].join(' | ') + ' |';
|
||||
'??'
|
||||
].join(' | ') + ' | ' +
|
||||
spellLevels[level].join(' | ')
|
||||
+ ' |';
|
||||
}).join('\n');
|
||||
|
||||
return `{{frame,wide
|
||||
##### ${Data.rand('classes')}
|
||||
| Level | Proficiency Bonus | Features | Cantrips Known | Spells Known | 1st | 2nd | 3rd | 4th | 5th | 6th | 7th | 8th | 9th |
|
||||
| Level | Proficiency Bonus | Features | Spells Known | 1st | 2nd | 3rd | 4th | 5th | 6th | 7th | 8th | 9th |
|
||||
|:---:|:---:|:---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
|
||||
${rows}
|
||||
}}`;
|
||||
@@ -43,9 +91,10 @@ ${rows}
|
||||
return '| ' + [
|
||||
lvlText,
|
||||
'+'+Math.floor(level/4 + 2),
|
||||
getFeature(level),
|
||||
'+'+featureScore
|
||||
].join(' | ') + ' |';
|
||||
getFeature(level)
|
||||
].join(' | ') + ' | ' +
|
||||
halfspellLevels[level].join(' | ')
|
||||
+ ' |'
|
||||
}).join('\n');
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,11 @@ module.exports = _.merge(
|
||||
require('./class.snippet.js'),
|
||||
require('./note.snippet.js'),
|
||||
require('./monster.snippet.js'),
|
||||
require('./toc.snippet.js')
|
||||
require('./toc.snippet.js'),
|
||||
|
||||
//require('./random.brew.js')
|
||||
require('./brew.snippet.js')
|
||||
|
||||
|
||||
|
||||
//wide
|
||||
|
||||
@@ -12,13 +12,10 @@ const getStats = function(){
|
||||
|
||||
const getAttributes = ()=>{
|
||||
|
||||
|
||||
|
||||
|
||||
return `
|
||||
- **Saving Throws**
|
||||
- **Condition Immunities** " + genList(["groggy", "swagged", "weak-kneed", "buzzed", "groovy", "melancholy", "drunk"], 3),
|
||||
- **Senses** passive Perception " + _.random(3, 20),
|
||||
- **Condition Immunities** ${Data.rand(["groggy", "swagged", "weak-kneed", "buzzed", "groovy", "melancholy", "drunk"], 3).join(', ')},
|
||||
- **Senses** passive Perception " ${_.random(3, 20)},
|
||||
- **Languages** ${Data.rand(["Common", "Pottymouth", "Gibberish", "Latin", "Jive"], 2).join(', ')}
|
||||
- **Challenge** ${_.random(0, 15)} (${_.random(10,10000)} XP)
|
||||
`;
|
||||
@@ -45,23 +42,16 @@ module.exports = {
|
||||
*${Data.rand('sizes')}, ${Data.rand('alignments')}*
|
||||
|
||||
---
|
||||
|
||||
- **Armor Class** ${_.random(10,20)}
|
||||
- **Hit Points** ${_.random(1, 150)} (1d4 + 5)
|
||||
- **Speed** ${ _.random(0,50)} ft
|
||||
|
||||
---
|
||||
|
||||
|STR|DEX|CON|INT|WIS|CHA|
|
||||
|:---:|:---:|:---:|:---:|:---:|:---:|
|
||||
${getStats()}
|
||||
|
||||
---
|
||||
|
||||
${getAttributes()}
|
||||
|
||||
---
|
||||
|
||||
Abilities
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ const Data = require('./random.data.js');
|
||||
|
||||
module.exports = {
|
||||
note : ()=>{
|
||||
return `{{note
|
||||
return `{{note,red
|
||||
##### ${Data.rand('abilities')}
|
||||
${Data.rand('sentences', 6, 4).join(' ')}
|
||||
}}`
|
||||
|
||||
11
shared/homebrewery/snippets/brew/random.brew.js
Normal file
11
shared/homebrewery/snippets/brew/random.brew.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const _ = require('lodash');
|
||||
const Data = require('./random.data.js');
|
||||
|
||||
|
||||
module.exports = {
|
||||
brew : ()=>{
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,9 @@ const Data = {
|
||||
const data = (Data[name] ? Data[name] : name);
|
||||
return _.sampleSize(data, _.random(min, max));
|
||||
},
|
||||
|
||||
//Boolean of 1 in n chance
|
||||
chance : (max = 20)=>_.random(1,max)== 1,
|
||||
mix : (list, max = 1, min = 1)=>_.times(_.random(min, max), ()=>_.sample(list)),
|
||||
titles : [
|
||||
`The Burning Gallows`,
|
||||
`The Ring of Nenlast`,
|
||||
|
||||
@@ -26,7 +26,7 @@ module.exports = {
|
||||
const description = Data.rand('effects', 2).concat(Data.rand('effects2')).join(' ');
|
||||
|
||||
|
||||
return `{{spell
|
||||
return `
|
||||
#### ${_.sample(Data.spellNames)}
|
||||
*${_.sample(levels)}-level ${_.sample(schools)}*
|
||||
- **Casting Time:** ${_.sample(['1 action', 'Reaction', '10 minutes', '1 hour'])}
|
||||
@@ -34,8 +34,18 @@ module.exports = {
|
||||
- **Components:** ${components}
|
||||
- **Duration:** ${duration}
|
||||
|
||||
${description}
|
||||
}}`;
|
||||
${description}`;
|
||||
|
||||
},
|
||||
|
||||
spellList : ()=>{
|
||||
const levels = ['Cantrips (0 Level)', '2nd Level', '3rd Level', '4th Level', '5th Level', '6th Level', '7th Level', '8th Level', '9th Level'];
|
||||
|
||||
const content = _.map(levels, (level)=>{
|
||||
const spells = _.map(Data.rand('spellNames', 15, 5), (spell)=>`- ${spell}`).join('\n');
|
||||
return `##### ${level} \n${spells} \n`;
|
||||
}).join('\n');
|
||||
|
||||
return `{{fourColumn,fullPage,sansSerif\n${content}\n}}`;
|
||||
}
|
||||
}
|
||||
@@ -43,15 +43,26 @@ const columns = {
|
||||
|
||||
module.exports = {
|
||||
table : () => {
|
||||
let title = '';
|
||||
|
||||
if(Data.chance(5)) title = `##### ${Data.rand(Data.abilities)}\n`;
|
||||
|
||||
|
||||
const rows = _.sample([4,6,8,10]);
|
||||
|
||||
const cols = [
|
||||
columns.roll(rows),
|
||||
columns.level(rows),
|
||||
columns.gear(rows)
|
||||
];
|
||||
let fns = [];
|
||||
if(Data.chance(3)) fns.push(columns.roll);
|
||||
|
||||
return _.times(rows + 2, (i)=>{
|
||||
fns = _.concat(fns, Data.rand([
|
||||
columns.level,
|
||||
columns.spell,
|
||||
columns.cost,
|
||||
columns.gear
|
||||
], 3, 2 - fns.length))
|
||||
|
||||
const cols = _.map(fns, (fn)=>fn(rows));
|
||||
|
||||
return title + _.times(rows + 2, (i)=>{
|
||||
if(i==1){
|
||||
return '|' + _.map(cols, (col)=>col[i]).join('|') + '|';
|
||||
}else{
|
||||
|
||||
@@ -7,7 +7,7 @@ const config = require('nconf');
|
||||
const app = require('app.js');
|
||||
const DB = require('db.js');
|
||||
const BrewData = require('brew.data.js');
|
||||
const BrewGen = require('./brew.gen.js');
|
||||
const SampleBrews = require('./sample_brews.js');
|
||||
const Error = require('error.js');
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ describe('Brew API', () => {
|
||||
before('Connect DB', DB.connect);
|
||||
before('Clear DB', BrewData.removeAll);
|
||||
before('Populate brews', ()=>{
|
||||
return BrewGen.populateDB(BrewGen.static());
|
||||
return SampleBrews.populateDB(SampleBrews.static());
|
||||
});
|
||||
describe('Create', () => {
|
||||
it('creates a new brew', () => {
|
||||
@@ -57,7 +57,7 @@ describe('Brew API', () => {
|
||||
|
||||
describe('Update', () => {
|
||||
it('updates an existing brew', () => {
|
||||
const storedBrew = BrewGen.get('BrewA');
|
||||
const storedBrew = SampleBrews.get('BrewA');
|
||||
return request(app)
|
||||
.put(`/api/brew/${storedBrew.editId}`)
|
||||
.send({ text : 'New Text' })
|
||||
@@ -72,7 +72,7 @@ describe('Brew API', () => {
|
||||
});
|
||||
|
||||
it('adds the user as author', () => {
|
||||
const storedBrew = BrewGen.get('BrewA');
|
||||
const storedBrew = SampleBrews.get('BrewA');
|
||||
return request(app)
|
||||
.put(`/api/brew/${storedBrew.editId}`)
|
||||
.set('Cookie', `nc_session=${UserXToken}`)
|
||||
@@ -85,7 +85,7 @@ describe('Brew API', () => {
|
||||
});
|
||||
});
|
||||
it('should throw error on bad edit id', ()=>{
|
||||
const storedBrew = BrewGen.get('BrewA');
|
||||
const storedBrew = SampleBrews.get('BrewA');
|
||||
return request(app)
|
||||
.put(`/api/brew/BADEDITID`)
|
||||
.send({ text : 'New Text' })
|
||||
@@ -95,7 +95,7 @@ describe('Brew API', () => {
|
||||
|
||||
describe('Remove', () => {
|
||||
it('should removes a brew', ()=>{
|
||||
const storedBrew = BrewGen.get('BrewA');
|
||||
const storedBrew = SampleBrews.get('BrewA');
|
||||
return request(app)
|
||||
.del(`/api/brew/${storedBrew.editId}`)
|
||||
.send()
|
||||
@@ -116,7 +116,7 @@ describe('Brew API', () => {
|
||||
before('Connect DB', DB.connect);
|
||||
before('Clear DB', BrewData.removeAll);
|
||||
before('Populate brews', ()=>{
|
||||
return BrewGen.populateDB(BrewGen.static());
|
||||
return SampleBrews.populateDB(SampleBrews.static());
|
||||
});
|
||||
|
||||
it('should be able to search for all published brews', ()=>{
|
||||
@@ -187,7 +187,7 @@ describe('Brew API', () => {
|
||||
.expect(200)
|
||||
.then((res) => {
|
||||
const result = res.body;
|
||||
const brewCount = _.size(BrewGen.static());
|
||||
const brewCount = _.size(SampleBrews.static());
|
||||
result.total.should.be.equal(brewCount);
|
||||
result.brews.length.should.be.equal(brewCount);
|
||||
result.brews[0].should.have.property('editId');
|
||||
@@ -199,7 +199,7 @@ describe('Brew API', () => {
|
||||
before('Connect DB', DB.connect);
|
||||
before('Clear DB', BrewData.removeAll);
|
||||
before('Populate brews', ()=>{
|
||||
return BrewGen.populateDB(BrewGen.static());
|
||||
return SampleBrews.populateDB(SampleBrews.static());
|
||||
});
|
||||
|
||||
it('should be able to query brews for a specific user', ()=>{
|
||||
|
||||
@@ -6,20 +6,20 @@ let PopulatedBrews = {};
|
||||
module.exports = {
|
||||
//TODO: Add in a generator for old brews to test the old rendering code
|
||||
|
||||
random : (num = 20)=>{
|
||||
return _.times(num, ()=>{
|
||||
//TODO: Build better generator, use new snippets?
|
||||
return {
|
||||
title : 'BrewA',
|
||||
description : '',
|
||||
text : '',
|
||||
authors : _.sampleSize(['userA','userB','userC','userD'], _.random(0, 3)),
|
||||
systems : _.sampleSize(['5e', '4e', '3.5e', 'Pathfinder'], _.random(0,2)),
|
||||
views : _.random(0,1000),
|
||||
published : !!_.random(0,1)
|
||||
};
|
||||
});
|
||||
},
|
||||
// random : (num = 20)=>{
|
||||
// return _.times(num, ()=>{
|
||||
// //TODO: Build better generator, use new snippets?
|
||||
// return {
|
||||
// title : 'BrewA',
|
||||
// description : '',
|
||||
// text : '',
|
||||
// authors : _.sampleSize(['userA','userB','userC','userD'], _.random(0, 3)),
|
||||
// systems : _.sampleSize(['5e', '4e', '3.5e', 'Pathfinder'], _.random(0,2)),
|
||||
// views : _.random(0,1000),
|
||||
// published : !!_.random(0,1)
|
||||
// };
|
||||
// });
|
||||
// },
|
||||
old : () => {
|
||||
return [
|
||||
{
|
||||
@@ -3,7 +3,7 @@ const _ = require('lodash');
|
||||
|
||||
const DB = require('db.js');
|
||||
const BrewData = require('brew.data.js');
|
||||
const BrewGen = require('./brew.gen.js');
|
||||
const SampleBrews = require('./sample_brews.js');
|
||||
//const Error = require('error.js');
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ describe('Brew Search', () => {
|
||||
before('Connect DB', DB.connect);
|
||||
before('Clear DB', BrewData.removeAll);
|
||||
before('Populate brews', ()=>{
|
||||
return BrewGen.populateDB(BrewGen.static());
|
||||
return SampleBrews.populateDB(SampleBrews.static());
|
||||
});
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ describe('Brew Search', () => {
|
||||
it('should be able to search for all brews', ()=>{
|
||||
return BrewData.search()
|
||||
.then((result) => {
|
||||
const brewCount = _.size(BrewGen.static());
|
||||
const brewCount = _.size(SampleBrews.static());
|
||||
result.total.should.be.equal(brewCount);
|
||||
result.brews.length.should.be.equal(brewCount);
|
||||
})
|
||||
@@ -41,7 +41,7 @@ describe('Brew Search', () => {
|
||||
limit : 2
|
||||
})
|
||||
.then((result) => {
|
||||
result.total.should.be.equal(_.size(BrewGen.static()));
|
||||
result.total.should.be.equal(_.size(SampleBrews.static()));
|
||||
result.brews.length.should.be.equal(2);
|
||||
})
|
||||
});
|
||||
|
||||
@@ -10,7 +10,7 @@ const config = require('nconf')
|
||||
const Chai = require('chai')
|
||||
.use(require('chai-as-promised'))
|
||||
.use(require('chai-subset'))
|
||||
.use(require('./brew.gen.js').chaiPlugin);
|
||||
.use(require('./sample_brews.js').chaiPlugin);
|
||||
|
||||
const log = require('loglevel');
|
||||
log.setLevel(config.get('log_level'));
|
||||
|
||||
Reference in New Issue
Block a user