You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
871 B
JavaScript

11 years ago
"use strict";
var groups = require('../groups'),
async = require('async'),
11 years ago
nconf = require('nconf'),
11 years ago
groupsController = {};
10 years ago
groupsController.list = function(req, res, next) {
11 years ago
groups.list({
truncateUserList: true,
expand: true
}, function(err, groups) {
10 years ago
if (err) {
return next(err);
}
11 years ago
res.render('groups/list', {
groups: groups
});
});
};
groupsController.details = function(req, res) {
var uid = req.user ? parseInt(req.user.uid, 10) : 0;
async.parallel({
group: function(next) {
groups.get(req.params.name, {
expand: true
}, next);
},
posts: function(next) {
groups.getLatestMemberPosts(req.params.name, 10, uid, next);
}
}, function(err, results) {
if (!err) {
res.render('groups/details', results);
} else {
11 years ago
res.redirect(nconf.get('relative_path') + '/404');
}
});
};
11 years ago
module.exports = groupsController;