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.

48 lines
932 B
JavaScript

11 years ago
"use strict";
var groups = require('../groups'),
async = require('async'),
11 years ago
nconf = require('nconf'),
10 years ago
helpers = require('./helpers'),
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
});
});
};
10 years ago
groupsController.details = function(req, res, next) {
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) {
10 years ago
if (err) {
return next(err);
}
10 years ago
if (!results.group) {
return helpers.notFound(req, res);
}
res.render('groups/details', results);
});
};
11 years ago
module.exports = groupsController;