Lay client out a bit better

This commit is contained in:
Jonathan Cremin 2014-12-15 12:49:17 +00:00
parent 08e0aa7665
commit 0b00b190fc
5 changed files with 191 additions and 26 deletions

19
routes/index.js Normal file
View file

@ -0,0 +1,19 @@
"use strict";
var React = require('react');
var nodejsx = require('node-jsx').install({extension: '.jsx'});
var Home = React.createFactory(require('../client/index.jsx').Home);
module.exports = function(req, res, next) {
req.db.matches.find().sort({created_at:-1}).limit(6).toArray().then(function(docs){
var recent = [];
docs.forEach(function(doc) {
recent.push(doc.services[doc._id.split("$$")[0]]);
})
var home = Home({recent: recent});
res.send('<!doctype html>\n' + React.renderToString(home).replace("</body></html>", "<script>var recent = " + JSON.stringify(recent) + "</script></body></html>"));
//res.render('index', { page: "home", recent: docs, error: req.flash('search-error') });
});
}