Created
May 10, 2016 20:31
-
-
Save Juxtaposeidon/6e7cf62d78320552df9df53398e225b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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