changed post links to "topic/<topic_id>/<topic_slug>/<post_id>"
This commit is contained in:
barisusakli
2014-06-02 17:31:09 -04:00
parent 46028e49f7
commit 55dbc5c823
10 changed files with 122 additions and 84 deletions

View File

@@ -20,7 +20,7 @@ topicsController.get = function(req, res, next) {
userPrivileges;
async.waterfall([
function(next) {
function (next) {
privileges.topics.get(tid, uid, function(err, privileges) {
if (err) {
return next(err);
@@ -40,8 +40,16 @@ topicsController.get = function(req, res, next) {
return next(err);
}
var start = (page - 1) * settings.postsPerPage,
end = start + settings.postsPerPage - 1;
var postIndex = 0;
if (!settings.usePagination) {
postIndex = Math.max((req.params.post_index || 1) - (settings.postsPerPage), 0);
} else if (!req.query.page) {
var index = Math.max(parseInt((req.params.post_index || 0), 10), 0);
page = Math.ceil((index + 1) / settings.postsPerPage);
}
var start = (page - 1) * settings.postsPerPage + postIndex,
end = start + settings.postsPerPage - 1 + postIndex;
topics.getTopicWithPosts(tid, uid, start, end, function (err, topicData) {
if (topicData) {