Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Juxtaposeidon/6e7cf62d78320552df9df53398e225b7 to your computer and use it in GitHub Desktop.

Select an option

Save Juxtaposeidon/6e7cf62d78320552df9df53398e225b7 to your computer and use it in GitHub Desktop.
exports.index = function (req, res) {
console.log(req.user)
Events.find({}, function (err, foundEvents) {
if (err) console.error(err)
foundEvents = foundEvents.filter(function (event) {
return event.start >= moment().unix()
}).map(function (event) {
event.startDate = moment.unix(event.start).format('MMM DD')
return event
})
Projects.find({brigade: res.locals.brigade.slug}, function (err, foundProjects) {
if (err) console.error(err)
var allKeywords = []
foundProjects.forEach(function (project) {
project.keywords.forEach(function (keyword) {
if (allKeywords.indexOf(keyword) < 0) {
allKeywords.push(keyword)
}
})
})
res.render(res.locals.brigade.theme.slug + '/views/home', {
view: 'home',
title: 'Home',
brigade: res.locals.brigade,
projects: foundProjects.splice(0, NUM_PROJECTS_SHOWN),
events: foundEvents.slice(0, 3)
})
})
}).sort({start: 1})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment