added groups page to user profile

v1.18.x
Julian Lam 10 years ago
parent c8f87e5d36
commit e4e9020e1f

@ -8,9 +8,9 @@ define('forum/groups/list', function() {
var groupsEl = $('#groups-list'); var groupsEl = $('#groups-list');
groupsEl.on('click', '.list-cover', function() { groupsEl.on('click', '.list-cover', function() {
var groupName = $(this).parents('[data-group]').attr('data-group'); var groupSlug = $(this).parents('[data-slug]').attr('data-slug');
ajaxify.go('groups/' + utils.slugify(groupName)); ajaxify.go('groups/' + groupSlug);
}); });
// Group creation // Group creation

@ -233,6 +233,29 @@ accountsController.getTopics = function(req, res, next) {
getFromUserSet('account/topics', 'topics', topics.getTopicsFromSet, 'topics', req, res, next); getFromUserSet('account/topics', 'topics', topics.getTopicsFromSet, 'topics', req, res, next);
}; };
accountsController.getGroups = function(req, res, next) {
var callerUID = req.user ? parseInt(req.user.uid, 10) : 0;
getBaseUser(req.params.userslug, callerUID, function(err, userData) {
if (err) {
return next(err);
}
if (!userData) {
return helpers.notFound(req, res);
}
groups.getUserGroups([userData.uid], function(err, groups) {
if (err) {
return next(err);
}
userData.groups = groups[0];
res.render('account/groups', userData);
});
});
};
function getFromUserSet(tpl, set, method, type, req, res, next) { function getFromUserSet(tpl, set, method, type, req, res, next) {
var callerUID = req.user ? parseInt(req.user.uid, 10) : 0; var callerUID = req.user ? parseInt(req.user.uid, 10) : 0;

@ -68,6 +68,7 @@ function accountRoutes(app, middleware, controllers) {
setupPageRoute(app, '/user/:userslug/followers', middleware, middlewares, controllers.accounts.getFollowers); setupPageRoute(app, '/user/:userslug/followers', middleware, middlewares, controllers.accounts.getFollowers);
setupPageRoute(app, '/user/:userslug/posts', middleware, middlewares, controllers.accounts.getPosts); setupPageRoute(app, '/user/:userslug/posts', middleware, middlewares, controllers.accounts.getPosts);
setupPageRoute(app, '/user/:userslug/topics', middleware, middlewares, controllers.accounts.getTopics); setupPageRoute(app, '/user/:userslug/topics', middleware, middlewares, controllers.accounts.getTopics);
setupPageRoute(app, '/user/:userslug/groups', middleware, middlewares, controllers.accounts.getGroups);
setupPageRoute(app, '/user/:userslug/favourites', middleware, accountMiddlewares, controllers.accounts.getFavourites); setupPageRoute(app, '/user/:userslug/favourites', middleware, accountMiddlewares, controllers.accounts.getFavourites);
setupPageRoute(app, '/user/:userslug/watched', middleware, accountMiddlewares, controllers.accounts.getWatchedTopics); setupPageRoute(app, '/user/:userslug/watched', middleware, accountMiddlewares, controllers.accounts.getWatchedTopics);

@ -14,6 +14,7 @@
"^user/.*/watched": "account/watched", "^user/.*/watched": "account/watched",
"^user/.*/posts": "account/posts", "^user/.*/posts": "account/posts",
"^user/.*/topics": "account/topics", "^user/.*/topics": "account/topics",
"^user/.*/groups": "account/groups",
"^user/[^\/]+": "account/profile", "^user/[^\/]+": "account/profile",
"^reset/.*": "reset_code", "^reset/.*": "reset_code",
"^tags/.*": "tag", "^tags/.*": "tag",

Loading…
Cancel
Save