v1.18.x
barisusakli 8 years ago
parent 0fc0b7e448
commit 5f16205d15

@ -61,9 +61,9 @@
"nodebb-plugin-spam-be-gone": "0.4.10", "nodebb-plugin-spam-be-gone": "0.4.10",
"nodebb-rewards-essentials": "0.0.9", "nodebb-rewards-essentials": "0.0.9",
"nodebb-theme-lavender": "3.0.14", "nodebb-theme-lavender": "3.0.14",
"nodebb-theme-persona": "4.1.58", "nodebb-theme-persona": "4.1.59",
"nodebb-theme-vanilla": "5.1.39", "nodebb-theme-vanilla": "5.1.40",
"nodebb-widget-essentials": "2.0.11", "nodebb-widget-essentials": "2.0.12",
"nodemailer": "2.0.0", "nodemailer": "2.0.0",
"nodemailer-sendmail-transport": "1.0.0", "nodemailer-sendmail-transport": "1.0.0",
"nodemailer-smtp-transport": "^2.4.1", "nodemailer-smtp-transport": "^2.4.1",

@ -50,9 +50,6 @@ module.exports = function(Posts) {
}, },
topicsAndCategories: function(next) { topicsAndCategories: function(next) {
getTopicAndCategories(topicKeys, next); getTopicAndCategories(topicKeys, next);
},
indices: function(next) {
Posts.getPostIndices(posts, uid, next);
} }
}, next); }, next);
}, },
@ -61,13 +58,7 @@ module.exports = function(Posts) {
results.topics = toObject('tid', results.topicsAndCategories.topics); results.topics = toObject('tid', results.topicsAndCategories.topics);
results.categories = toObject('cid', results.topicsAndCategories.categories); results.categories = toObject('cid', results.topicsAndCategories.categories);
posts.forEach(function(post, i) { posts.forEach(function(post) {
post.index = utils.isNumber(results.indices[i]) ? parseInt(results.indices[i], 10) + 1 : 1;
post.isMainPost = post.index - 1 === 0;
post.deleted = parseInt(post.deleted, 10) === 1;
post.upvotes = parseInt(post.upvotes, 10) || 0;
post.downvotes = parseInt(post.downvotes, 10) || 0;
post.votes = post.upvotes - post.downvotes;
// If the post author isn't represented in the retrieved users' data, then it means they were deleted, assume guest. // If the post author isn't represented in the retrieved users' data, then it means they were deleted, assume guest.
if (!results.users.hasOwnProperty(post.uid)) { if (!results.users.hasOwnProperty(post.uid)) {
post.uid = 0; post.uid = 0;
@ -75,6 +66,11 @@ module.exports = function(Posts) {
post.user = results.users[post.uid]; post.user = results.users[post.uid];
post.topic = results.topics[post.tid]; post.topic = results.topics[post.tid];
post.category = results.categories[post.topic.cid]; post.category = results.categories[post.topic.cid];
post.isMainPost = parseInt(post.pid, 10) === parseInt(post.topic.mainPid, 10);
post.deleted = parseInt(post.deleted, 10) === 1;
post.upvotes = parseInt(post.upvotes, 10) || 0;
post.downvotes = parseInt(post.downvotes, 10) || 0;
post.votes = post.upvotes - post.downvotes;
post.timestampISO = utils.toISOString(post.timestamp); post.timestampISO = utils.toISOString(post.timestamp);
}); });
@ -117,7 +113,7 @@ module.exports = function(Posts) {
} }
function getTopicAndCategories(topicKeys, callback) { function getTopicAndCategories(topicKeys, callback) {
db.getObjectsFields(topicKeys, ['uid', 'tid', 'title', 'cid', 'slug', 'deleted', 'postcount'], function(err, topics) { db.getObjectsFields(topicKeys, ['uid', 'tid', 'title', 'cid', 'slug', 'deleted', 'postcount', 'mainPid'], function(err, topics) {
if (err) { if (err) {
return callback(err); return callback(err);
} }

@ -77,7 +77,7 @@ function generateForTopic(req, res, callback) {
feed.item({ feed.item({
title: 'Reply to ' + topicData.title + ' on ' + dateStamp, title: 'Reply to ' + topicData.title + ' on ' + dateStamp,
description: postData.content, description: postData.content,
url: nconf.get('url') + '/topic/' + topicData.slug + (postData.index ? '/' + (postData.index + 1) : ''), url: nconf.get('url') + '/post/' + postData.pid,
author: postData.user ? postData.user.username : '', author: postData.user ? postData.user.username : '',
date: dateStamp date: dateStamp
}); });
@ -350,7 +350,7 @@ function generateForPostsFeed(feedOptions, posts) {
feed.item({ feed.item({
title: postData.topic ? postData.topic.title : '', title: postData.topic ? postData.topic.title : '',
description: postData.content, description: postData.content,
url: nconf.get('url') + '/topic/' + (postData.topic ? postData.topic.slug : '#') + '/'+postData.index, url: nconf.get('url') + '/post/' + postData.pid,
author: postData.user ? postData.user.username : '', author: postData.user ? postData.user.username : '',
date: new Date(parseInt(postData.timestamp, 10)).toUTCString() date: new Date(parseInt(postData.timestamp, 10)).toUTCString()
}); });

@ -98,7 +98,7 @@
<small> <small>
<span class="pull-right"> <span class="pull-right">
Posted in <a href="{config.relative_path}/category/{posts.category.slug}" target="_blank"><i class="fa {posts.category.icon}"></i> {posts.category.name}</a>, <span class="timeago" title="{posts.timestampISO}"></span> &bull; Posted in <a href="{config.relative_path}/category/{posts.category.slug}" target="_blank"><i class="fa {posts.category.icon}"></i> {posts.category.name}</a>, <span class="timeago" title="{posts.timestampISO}"></span> &bull;
<a href="{config.relative_path}/topic/{posts.topic.slug}/{posts.index}" target="_blank">Read More</a> <a href="{config.relative_path}/post/{posts.pid}" target="_blank">Read More</a>
</span> </span>
</small> </small>
</div> </div>

Loading…
Cancel
Save