Merge branch 'master' of github.com:designcreateplay/NodeBB

Conflicts:
	public/src/forum/topic.js
v1.18.x
Julian Lam 11 years ago
commit 0159a43a20

@ -787,7 +787,7 @@ define(function() {
if (scrollTop < 50 && Topic.postCount > 1) {
localStorage.removeItem("topic:" + tid + ":bookmark");
pagination.innerHTML = '0 out of ' + Topic.postCount;
pagination.innerHTML = '1 out of ' + Topic.postCount;
progressBar.width(0);
return;
}
@ -814,9 +814,8 @@ define(function() {
smallestNonNegative = Number.MAX_VALUE;
}
pagination.innerHTML = this.postnumber + ' out of ' + Topic.postCount;
console.log((this.postnumber / Topic.postCount * 100) + '%');
progressBar.width((this.postnumber / Topic.postCount * 100) + '%');
pagination.innerHTML = (this.postnumber-1) + ' out of ' + Topic.postCount;
progressBar.width(((this.postnumber-1) / Topic.postCount * 100) + '%');
}
});
@ -867,8 +866,9 @@ define(function() {
}
function createNewPosts(data, infiniteLoaded) {
if(!data || (data.posts && !data.posts.length))
if(!data || (data.posts && !data.posts.length)) {
return;
}
function removeAlreadyAddedPosts() {
data.posts = data.posts.filter(function(post) {
@ -900,7 +900,7 @@ define(function() {
var insertAfter = findInsertionPoint();
var html = templates.prepare(templates['topic'].blocks['posts']).parse(data);
var regexp = new RegExp("<!--[\\s]*IF @first[\\s]*-->[\\s\\S]*<!--[\\s]*ENDIF @first[\\s]*-->", 'g');
var regexp = new RegExp("<!--[\\s]*IF @first[\\s]*-->([\\s\\S]*?)<!--[\\s]*ENDIF @first[\\s]*-->", 'g');
html = html.replace(regexp, '');
translator.translate(html, function(translatedHTML) {
@ -948,7 +948,7 @@ define(function() {
socket.emit('api:topic.loadMore', {
tid: tid,
after: $('#post-container .post-row.infiniteloaded').length
after: $('#post-container .post-row.infiniteloaded').last().attr('data-index') + 1
}, function (data) {
infiniteLoaderActive = false;
if (data.posts.length) {

@ -26,7 +26,7 @@
<ul id="post-container" class="container posts" data-tid="{topic_id}">
<!-- BEGIN posts -->
<li class="row post-row infiniteloaded" data-pid="{posts.pid}" data-uid="{posts.uid}" data-username="{posts.username}" data-deleted="{posts.deleted}" itemscope itemtype="http://schema.org/Comment">
<li class="row post-row infiniteloaded" data-pid="{posts.pid}" data-uid="{posts.uid}" data-username="{posts.username}" data-index="{posts.index}" data-deleted="{posts.deleted}" itemscope itemtype="http://schema.org/Comment">
<a id="post_anchor_{posts.pid}" name="{posts.pid}"></a>
<meta itemprop="datePublished" content="{posts.relativeTime}">
@ -65,7 +65,7 @@
<div class="btn-group">
<!-- IF @first -->
<button class="btn btn-sm btn-default follow main-post" type="button" title="Be notified of new replies in this topic"><i class="fa fa-eye"></i></button>
<button class="btn btn-sm btn-default follow" type="button" title="Be notified of new replies in this topic"><i class="fa fa-eye"></i></button>
<!-- ENDIF @first -->
<button data-favourited="{posts.favourited}" class="favourite btn btn-sm btn-default <!-- IF posts.favourited --> btn-warning <!-- ENDIF posts.favourited -->" type="button">
<span class="favourite-text">[[topic:favourite]]</span>

@ -187,7 +187,7 @@ var RDB = require('./redis'),
if (pids.length) {
plugins.fireHook('filter:post.getTopic', pids, function(err, posts) {
if (!err & 0 < posts.length) {
if (!err && posts.length > 0) {
Posts.getPostsByPids(pids, function(err, posts) {
plugins.fireHook('action:post.gotTopic', posts);
callback(posts);
@ -370,18 +370,7 @@ var RDB = require('./redis'),
winston.err('invalid time value');
}
if (postData.uploadedImages) {
try {
postData.uploadedImages = JSON.parse(postData.uploadedImages);
} catch(err) {
postData.uploadedImages = [];
winston.err(err);
}
} else {
postData.uploadedImages = [];
}
postTools.parse(postData.content, function(err, content) {
postTools.parse(postData.content, function(err, content) {
postData.content = content;
_callback(null, postData);
});

@ -160,8 +160,17 @@ var RDB = require('./redis'),
Topics.getTopicPosts = function(tid, start, end, current_user, callback) {
posts.getPostsByTid(tid, start, end, function(postData) {
if (Array.isArray(postData) && !postData.length)
if (Array.isArray(postData) && !postData.length) {
return callback([]);
}
for(var i=0; i<postData.length; ++i) {
postData[i].index = start + i;
}
postData = postData.filter(function(post) {
return parseInt(current_user, 10) !== 0 || post.deleted === "0";
});
function getFavouritesData(next) {
var pids = [];
@ -482,8 +491,9 @@ var RDB = require('./redis'),
Topics.getTopicWithPosts = function(tid, current_user, start, end, callback) {
threadTools.exists(tid, function(exists) {
if (!exists)
if (!exists) {
return callback(new Error('Topic tid \'' + tid + '\' not found'));
}
Topics.markAsRead(tid, current_user);
Topics.increaseViewCount(tid);

Loading…
Cancel
Save