Wire hot, recent, submit, and search views in app and controller, modified button navigation to fetch their routes

This commit is contained in:
Nathan Leniz
2015-03-06 08:11:18 +09:00
parent f1f3258fe3
commit 5440efc729
7 changed files with 140 additions and 25 deletions

View File

@@ -6,7 +6,7 @@ var R = require('ramda'),
moment = require('../public/js/lib/moment/moment.js'),
resources = require('./resources');
exports.json = function(req, res, next) {
exports.hotJSON = function(req, res, next) {
var story = Story.find({}).sort({'rank': -1});
story.exec(function(err, stories) {
if (err) {
@@ -16,13 +16,44 @@ exports.json = function(req, res, next) {
});
};
exports.index = function(req, res, next) {
var story = Story.find({}).sort({'rank': -1});
exports.recentJSON = function(req, res, next) {
var story = Story.find({}).sort({'timePosted': -1});
story.exec(function(err, stories) {
if (err) {
throw err;
}
res.render('stories/index');
res.json(stories);
});
};
exports.hot = function(req, res, next) {
res.render('stories/index', {
page: 'hot'
});
};
exports.submitNew = function(req,res, next) {
res.render('stories/submit-story', {
page: 'submit'
});
};
exports.search = function(req, res, next) {
res.render('stories/search-stories', {
page: 'search'
});
};
exports.recent = function(req, res, next) {
res.render('stories/index', {
page: 'recent'
});
};
exports.specificView = function(req, res, next) {
var whichView = req.params.type;
res.render('stories/index', {
page: whichView
});
};