,
});
},
render : function(){
diff --git a/client/homebrew/pages/homePage/homePage.jsx b/client/homebrew/pages/homePage/homePage.jsx
index 230f64e..37d9508 100644
--- a/client/homebrew/pages/homePage/homePage.jsx
+++ b/client/homebrew/pages/homePage/homePage.jsx
@@ -7,8 +7,8 @@ const Navbar = require('../../navbar/navbar.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');
@@ -38,6 +38,46 @@ const HomePage = React.createClass({
},
+ renderNavigation : function(){
+ return
+
+ Effortlessly create Authnetic looking D&D homebrews with just text
+
+
+
+
+
+ },
+
+ renderTopBrews : function(){
+ return
+ {_.map(this.props.brews, (brew)=>)}
+
+ },
+
render : function(){
return
{this.renderNavbar()}
@@ -47,40 +87,8 @@ const HomePage = React.createClass({
The Homebrewery
-
-
- Effortlessly create Authnetic looking D&D homebrews with just text
-
-
-
-
-
- topBrews
-
-
+ {this.renderNavigation()}
+ {this.renderTopBrews()}
}
diff --git a/client/homebrew/pages/homePage/homePage.less b/client/homebrew/pages/homePage/homePage.less
index d5ac26c..4d605d0 100644
--- a/client/homebrew/pages/homePage/homePage.less
+++ b/client/homebrew/pages/homePage/homePage.less
@@ -16,7 +16,7 @@
text-align : center;
}
}
- .buttons{
+ .navigation{
padding : 30px;
background-image : url('/assets/homebrew/pages/homePage/dmg_bg.jpg');
text-align : center;
diff --git a/scripts/populate.js b/scripts/populate.js
index b7233db..da5418b 100644
--- a/scripts/populate.js
+++ b/scripts/populate.js
@@ -3,7 +3,7 @@ const _ = require('lodash');
const DB = require('../server/db.js');
const BrewData = require('../server/brew.data.js');
-const BrewGen = require('../tests/brew.gen.js');
+//const BrewGen = require('../tests/brew.gen.js');
return Promise.resolve()
.then(DB.connect)
diff --git a/server/brew.search.js b/server/brew.search.js
index 9bdab97..0b0bbe2 100644
--- a/server/brew.search.js
+++ b/server/brew.search.js
@@ -34,7 +34,8 @@ module.exports = (BrewModel) => {
opts.page = _.toNumber(opts.page);
let filter = {
- text : 0
+ text : 0,
+ style : 0
};
if(!fullAccess){
diff --git a/server/interface.routes.js b/server/interface.routes.js
index 27e9236..8ee0a1a 100644
--- a/server/interface.routes.js
+++ b/server/interface.routes.js
@@ -21,11 +21,10 @@ const getTopBrews = ()=>{
return BrewData.search({}, {
limit : 4,
sort : {views : -1}
- }).then(({brews, total})=>brews);
+ }, false).then(({brews, total})=>brews);
};
getTopBrews().then((brews)=>{
- console.log('top brews', brews);
topBrews=brews;
});
@@ -44,9 +43,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);
};
@@ -72,7 +69,7 @@ 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'));
+ return res.redirect(`${config.get('login_path')}?redirect=${encodeURIComponent(req.headers.referer)}`);
}
});
router.get('/user/:username', (req, res, next) => {
@@ -122,8 +119,8 @@ router.get('/new', renderPage);
//Home Page
router.get('/', (req, res, next) => {
- req.brew = { text : statics.welcomeBrew };
- //TODO add in top brews
+ req.brews = topBrews;
+ console.log(topBrews);
return next();
}, renderPage);
diff --git a/shared/homebrewery/brewCard/brewCard.jsx b/shared/homebrewery/brewCard/brewCard.jsx
new file mode 100644
index 0000000..e4fa830
--- /dev/null
+++ b/shared/homebrewery/brewCard/brewCard.jsx
@@ -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
+
{brew.title}
+
{brew.description}
+
+
+ }
+});
+
+module.exports = BrewCard;
diff --git a/shared/homebrewery/brewCard/brewCard.less b/shared/homebrewery/brewCard/brewCard.less
new file mode 100644
index 0000000..0d3836b
--- /dev/null
+++ b/shared/homebrewery/brewCard/brewCard.less
@@ -0,0 +1,10 @@
+.brewCard{
+ width : 300px;
+ height : 100px;
+
+ //border : 1px solid black;
+ background-image : url('/assets/homebrewery/brewCard/monster_bg.jpg');
+
+ position : relative;
+
+}
\ No newline at end of file
diff --git a/shared/homebrewery/brewCard/monster_bg.jpg b/shared/homebrewery/brewCard/monster_bg.jpg
new file mode 100644
index 0000000..d22f839
Binary files /dev/null and b/shared/homebrewery/brewCard/monster_bg.jpg differ
diff --git a/shared/homebrewery/brewCard/note_border.png b/shared/homebrewery/brewCard/note_border.png
new file mode 100644
index 0000000..bf7b301
Binary files /dev/null and b/shared/homebrewery/brewCard/note_border.png differ
diff --git a/shared/homebrewery/brewCard/note_border_shadow.png b/shared/homebrewery/brewCard/note_border_shadow.png
new file mode 100644
index 0000000..87dd2bb
Binary files /dev/null and b/shared/homebrewery/brewCard/note_border_shadow.png differ
diff --git a/shared/homebrewery/snippets/brew/index.js b/shared/homebrewery/snippets/brew/index.js
index 0cb4d4f..4671d6d 100644
--- a/shared/homebrewery/snippets/brew/index.js
+++ b/shared/homebrewery/snippets/brew/index.js
@@ -6,7 +6,10 @@ 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')
+
//wide
diff --git a/shared/homebrewery/snippets/brew/random.brew.js b/shared/homebrewery/snippets/brew/random.brew.js
new file mode 100644
index 0000000..3778189
--- /dev/null
+++ b/shared/homebrewery/snippets/brew/random.brew.js
@@ -0,0 +1,11 @@
+const _ = require('lodash');
+const Data = require('./random.data.js');
+
+
+module.exports = {
+ brew : ()=>{
+
+
+
+ }
+}
\ No newline at end of file
diff --git a/tests/api.test.js b/tests/api.test.js
index 0ba5fdb..c233af6 100644
--- a/tests/api.test.js
+++ b/tests/api.test.js
@@ -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', ()=>{
diff --git a/tests/brew.gen.js b/tests/sample_brews.js
similarity index 84%
rename from tests/brew.gen.js
rename to tests/sample_brews.js
index 4965826..fbc7f7b 100644
--- a/tests/brew.gen.js
+++ b/tests/sample_brews.js
@@ -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 [
{
diff --git a/tests/search.test.js b/tests/search.test.js
index 6649500..a03907c 100644
--- a/tests/search.test.js
+++ b/tests/search.test.js
@@ -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);
})
});
diff --git a/tests/test.init.js b/tests/test.init.js
index ab1567a..74d2436 100644
--- a/tests/test.init.js
+++ b/tests/test.init.js
@@ -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'));