|
|
@ -56,12 +56,8 @@ topicsController.get = function(req, res, next) {
|
|
|
|
var postCount = parseInt(results.topic.postcount, 10);
|
|
|
|
var postCount = parseInt(results.topic.postcount, 10);
|
|
|
|
var pageCount = Math.max(1, Math.ceil((postCount - 1) / settings.postsPerPage));
|
|
|
|
var pageCount = Math.max(1, Math.ceil((postCount - 1) / settings.postsPerPage));
|
|
|
|
|
|
|
|
|
|
|
|
if (utils.isNumber(req.params.post_index)) {
|
|
|
|
if (utils.isNumber(req.params.post_index) && (req.params.post_index < 1 || req.params.post_index > postCount)) {
|
|
|
|
var url = '';
|
|
|
|
return helpers.redirect(res, '/topic/' + req.params.topic_id + '/' + req.params.slug + (req.params.post_index > postCount ? '/' + postCount : ''));
|
|
|
|
if (req.params.post_index < 1 || req.params.post_index > postCount) {
|
|
|
|
|
|
|
|
url = '/topic/' + req.params.topic_id + '/' + req.params.slug + (req.params.post_index > postCount ? '/' + postCount : '');
|
|
|
|
|
|
|
|
return res.locals.isAPI ? res.status(302).json(url) : res.redirect(url);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (settings.usePagination && (req.query.page < 1 || req.query.page > pageCount)) {
|
|
|
|
if (settings.usePagination && (req.query.page < 1 || req.query.page > pageCount)) {
|
|
|
@ -266,7 +262,7 @@ topicsController.get = function(req, res, next) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
topics.increaseViewCount(tid);
|
|
|
|
topics.increaseViewCount(tid);
|
|
|
|
|
|
|
|
|
|
|
|
plugins.fireHook('filter:topic.build', {req: req, res: res, templateData: data}, function(err, data) {
|
|
|
|
plugins.fireHook('filter:topic.build', {req: req, res: res, templateData: data}, function(err, data) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
return next(err);
|
|
|
|
return next(err);
|
|
|
|