v1.18.x
barisusakli 10 years ago
parent 534b13e089
commit 072d287183

@ -24,5 +24,6 @@
"maximumProfileImageSize": 256,
"profileImageDimension": 128,
"requireEmailConfirmation": 0,
"profile:allowProfileImageUploads": 1
"profile:allowProfileImageUploads": 1,
"teaserPost": "last"
}

@ -5,6 +5,7 @@ var async = require('async'),
winston = require('winston'),
_ = require('underscore'),
meta = require('../meta'),
db = require('../database'),
posts = require('../posts'),
topics = require('../topics'),
@ -48,7 +49,11 @@ module.exports = function(Categories) {
privileges.posts.filter('read', pids, uid, next);
},
function(pids, next) {
posts.getPostSummaryByPids(pids, uid, {stripTags: true}, next);
if (meta.config.teaserPost === 'first') {
getMainPosts(pids, uid, next);
} else {
posts.getPostSummaryByPids(pids, uid, {stripTags: true}, next);
}
},
function(posts, next) {
categoryData.forEach(function(category) {
@ -59,10 +64,33 @@ module.exports = function(Categories) {
], callback);
};
function getMainPosts(pids, uid, callback) {
async.waterfall([
function(next) {
var keys = pids.map(function(pid) {
return 'post:' + pid;
});
db.getObjectsFields(keys, ['tid'], next);
},
function(posts, next) {
var keys = posts.map(function(post) {
return 'topic:' + post.tid;
});
db.getObjectsFields(keys, ['mainPid'], next);
},
function(topics, next) {
var mainPids = topics.map(function(topic) {
return topic.mainPid;
});
posts.getPostSummaryByPids(mainPids, uid, {stripTags: true}, next);
}
], callback);
}
function assignPostsToCategory(category, posts) {
category.posts = posts.filter(function(post) {
return post.category && (parseInt(post.category.cid, 10) === parseInt(category.cid, 10)
|| parseInt(post.category.parentCid, 10) === parseInt(category.cid, 10));
return post.category && (parseInt(post.category.cid, 10) === parseInt(category.cid, 10) ||
parseInt(post.category.parentCid, 10) === parseInt(category.cid, 10));
}).sort(function(a, b) {
return b.timestamp - a.timestamp;
}).slice(0, parseInt(category.numRecentReplies, 10));

@ -125,25 +125,31 @@ var async = require('async'),
};
function togglePin(tid, uid, pin, callback) {
topics.getTopicFields(tid, ['cid', 'lastposttime'], function(err, topicData) {
if (err) {
return callback(err);
}
topics.setTopicField(tid, 'pinned', pin ? 1 : 0);
db.sortedSetAdd('cid:' + topicData.cid + ':tids', pin ? Math.pow(2, 53) : topicData.lastposttime, tid);
var data = {
tid: tid,
isPinned: pin,
uid: uid,
cid: topicData.cid
};
var topicData;
async.waterfall([
function(next) {
topics.getTopicFields(tid, ['cid', 'lastposttime'], next);
},
function(_topicData, next) {
topicData = _topicData;
async.parallel([
async.apply(topics.setTopicField, tid, 'pinned', pin ? 1 : 0),
async.apply(db.sortedSetAdd, 'cid:' + topicData.cid + ':tids', pin ? Math.pow(2, 53) : topicData.lastposttime, tid)
], next);
},
function(results, next) {
var data = {
tid: tid,
isPinned: pin,
uid: uid,
cid: topicData.cid
};
plugins.fireHook('action:topic.pin', data);
plugins.fireHook('action:topic.pin', data);
callback(null, data);
});
next(null, data);
}
], callback);
}
ThreadTools.move = function(tid, cid, uid, callback) {

@ -5,6 +5,7 @@
var async = require('async'),
S = require('string'),
meta = require('../meta'),
db = require('../database'),
user = require('../user'),
posts = require('../posts'),
@ -24,8 +25,12 @@ module.exports = function(Topics) {
topics.forEach(function(topic) {
counts.push(topic && (parseInt(topic.postcount, 10) || 0));
if (topic && topic.teaserPid) {
teaserPids.push(topic.teaserPid);
if (topic) {
if (meta.config.teaserPost === 'first') {
teaserPids.push(topic.mainPid);
} else {
teaserPids.push(topic.teaserPid);
}
}
});
@ -65,7 +70,7 @@ module.exports = function(Topics) {
return null;
}
if (tidToPost[topic.tid]) {
tidToPost[topic.tid].index = counts[index];
tidToPost[topic.tid].index = meta.config.teaserPost === 'first' ? 1 : counts[index];
if (tidToPost[topic.tid].content) {
var s = S(tidToPost[topic.tid].content);
tidToPost[topic.tid].content = s.stripTags.apply(s, utils.stripTags).s;

@ -66,6 +66,22 @@
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">Teaser Settings</div>
<div class="panel-body">
<form>
<div class="form-group">
<label>Teaser Post</label>
<select class="form-control" data-field="teaserPost">
<option value="last">Last</option>
<option value="first">First</option>
</select>
</div>
</form>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">Signature Settings</div>
<div class="panel-body">

Loading…
Cancel
Save