|
|
|
@ -97,56 +97,63 @@ postsController.getTopics = function (req, res, next) {
|
|
|
|
|
getFromUserSet(data, req, res, next);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function getFromUserSet(data, req, res, next) {
|
|
|
|
|
async.parallel({
|
|
|
|
|
settings: function (next) {
|
|
|
|
|
user.getSettings(req.uid, next);
|
|
|
|
|
function getFromUserSet(data, req, res, callback) {
|
|
|
|
|
var userData;
|
|
|
|
|
var itemsPerPage;
|
|
|
|
|
var page = Math.max(1, parseInt(req.query.page, 10) || 1);
|
|
|
|
|
async.waterfall([
|
|
|
|
|
function (next) {
|
|
|
|
|
async.parallel({
|
|
|
|
|
settings: function (next) {
|
|
|
|
|
user.getSettings(req.uid, next);
|
|
|
|
|
},
|
|
|
|
|
userData: function (next) {
|
|
|
|
|
accountHelpers.getUserDataByUserSlug(req.params.userslug, req.uid, next);
|
|
|
|
|
}
|
|
|
|
|
}, next);
|
|
|
|
|
},
|
|
|
|
|
userData: function (next) {
|
|
|
|
|
accountHelpers.getUserDataByUserSlug(req.params.userslug, req.uid, next);
|
|
|
|
|
}
|
|
|
|
|
}, function (err, results) {
|
|
|
|
|
if (err || !results.userData) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
function (results, next) {
|
|
|
|
|
if (!results.userData) {
|
|
|
|
|
return callback();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var userData = results.userData;
|
|
|
|
|
userData = results.userData;
|
|
|
|
|
|
|
|
|
|
var setName = 'uid:' + userData.uid + ':' + data.set;
|
|
|
|
|
var setName = 'uid:' + userData.uid + ':' + data.set;
|
|
|
|
|
|
|
|
|
|
var page = Math.max(1, parseInt(req.query.page, 10) || 1);
|
|
|
|
|
var itemsPerPage = (data.template === 'account/topics' || data.template === 'account/watched') ? results.settings.topicsPerPage : results.settings.postsPerPage;
|
|
|
|
|
itemsPerPage = (data.template === 'account/topics' || data.template === 'account/watched') ? results.settings.topicsPerPage : results.settings.postsPerPage;
|
|
|
|
|
|
|
|
|
|
async.parallel({
|
|
|
|
|
itemCount: function (next) {
|
|
|
|
|
if (results.settings.usePagination) {
|
|
|
|
|
db.sortedSetCard(setName, next);
|
|
|
|
|
} else {
|
|
|
|
|
next(null, 0);
|
|
|
|
|
async.parallel({
|
|
|
|
|
itemCount: function (next) {
|
|
|
|
|
if (results.settings.usePagination) {
|
|
|
|
|
db.sortedSetCard(setName, next);
|
|
|
|
|
} else {
|
|
|
|
|
next(null, 0);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
data: function (next) {
|
|
|
|
|
var start = (page - 1) * itemsPerPage;
|
|
|
|
|
var stop = start + itemsPerPage - 1;
|
|
|
|
|
data.method(setName, req.uid, start, stop, next);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
data: function (next) {
|
|
|
|
|
var start = (page - 1) * itemsPerPage;
|
|
|
|
|
var stop = start + itemsPerPage - 1;
|
|
|
|
|
data.method(setName, req.uid, start, stop, next);
|
|
|
|
|
}
|
|
|
|
|
}, function (err, results) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
}, next);
|
|
|
|
|
}
|
|
|
|
|
], function (err, results) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return callback(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
userData[data.type] = results.data[data.type];
|
|
|
|
|
userData.nextStart = results.data.nextStart;
|
|
|
|
|
userData[data.type] = results.data[data.type];
|
|
|
|
|
userData.nextStart = results.data.nextStart;
|
|
|
|
|
|
|
|
|
|
var pageCount = Math.ceil(results.itemCount / itemsPerPage);
|
|
|
|
|
userData.pagination = pagination.create(page, pageCount);
|
|
|
|
|
var pageCount = Math.ceil(results.itemCount / itemsPerPage);
|
|
|
|
|
userData.pagination = pagination.create(page, pageCount);
|
|
|
|
|
|
|
|
|
|
userData.noItemsFoundKey = data.noItemsFoundKey;
|
|
|
|
|
userData.title = '[[pages:' + data.template + ', ' + userData.username + ']]';
|
|
|
|
|
userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: data.crumb}]);
|
|
|
|
|
userData.noItemsFoundKey = data.noItemsFoundKey;
|
|
|
|
|
userData.title = '[[pages:' + data.template + ', ' + userData.username + ']]';
|
|
|
|
|
userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: data.crumb}]);
|
|
|
|
|
|
|
|
|
|
res.render(data.template, userData);
|
|
|
|
|
});
|
|
|
|
|
res.render(data.template, userData);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|