mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 22:15:48 +01:00
Merge branch 'master' of github.com:designcreateplay/NodeBB
Conflicts: public/src/forum/topic.js
This commit is contained in:
@@ -787,7 +787,7 @@ define(function() {
|
|||||||
|
|
||||||
if (scrollTop < 50 && Topic.postCount > 1) {
|
if (scrollTop < 50 && Topic.postCount > 1) {
|
||||||
localStorage.removeItem("topic:" + tid + ":bookmark");
|
localStorage.removeItem("topic:" + tid + ":bookmark");
|
||||||
pagination.innerHTML = '0 out of ' + Topic.postCount;
|
pagination.innerHTML = '1 out of ' + Topic.postCount;
|
||||||
progressBar.width(0);
|
progressBar.width(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -814,9 +814,8 @@ define(function() {
|
|||||||
smallestNonNegative = Number.MAX_VALUE;
|
smallestNonNegative = Number.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
pagination.innerHTML = this.postnumber + ' out of ' + Topic.postCount;
|
pagination.innerHTML = (this.postnumber-1) + ' out of ' + Topic.postCount;
|
||||||
console.log((this.postnumber / Topic.postCount * 100) + '%');
|
progressBar.width(((this.postnumber-1) / Topic.postCount * 100) + '%');
|
||||||
progressBar.width((this.postnumber / Topic.postCount * 100) + '%');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -867,8 +866,9 @@ define(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createNewPosts(data, infiniteLoaded) {
|
function createNewPosts(data, infiniteLoaded) {
|
||||||
if(!data || (data.posts && !data.posts.length))
|
if(!data || (data.posts && !data.posts.length)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
function removeAlreadyAddedPosts() {
|
function removeAlreadyAddedPosts() {
|
||||||
data.posts = data.posts.filter(function(post) {
|
data.posts = data.posts.filter(function(post) {
|
||||||
@@ -900,7 +900,7 @@ define(function() {
|
|||||||
var insertAfter = findInsertionPoint();
|
var insertAfter = findInsertionPoint();
|
||||||
|
|
||||||
var html = templates.prepare(templates['topic'].blocks['posts']).parse(data);
|
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, '');
|
html = html.replace(regexp, '');
|
||||||
|
|
||||||
translator.translate(html, function(translatedHTML) {
|
translator.translate(html, function(translatedHTML) {
|
||||||
@@ -948,7 +948,7 @@ define(function() {
|
|||||||
|
|
||||||
socket.emit('api:topic.loadMore', {
|
socket.emit('api:topic.loadMore', {
|
||||||
tid: tid,
|
tid: tid,
|
||||||
after: $('#post-container .post-row.infiniteloaded').length
|
after: $('#post-container .post-row.infiniteloaded').last().attr('data-index') + 1
|
||||||
}, function (data) {
|
}, function (data) {
|
||||||
infiniteLoaderActive = false;
|
infiniteLoaderActive = false;
|
||||||
if (data.posts.length) {
|
if (data.posts.length) {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
<ul id="post-container" class="container posts" data-tid="{topic_id}">
|
<ul id="post-container" class="container posts" data-tid="{topic_id}">
|
||||||
<!-- BEGIN posts -->
|
<!-- 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>
|
<a id="post_anchor_{posts.pid}" name="{posts.pid}"></a>
|
||||||
|
|
||||||
<meta itemprop="datePublished" content="{posts.relativeTime}">
|
<meta itemprop="datePublished" content="{posts.relativeTime}">
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
|
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<!-- IF @first -->
|
<!-- 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 -->
|
<!-- ENDIF @first -->
|
||||||
<button data-favourited="{posts.favourited}" class="favourite btn btn-sm btn-default <!-- IF posts.favourited --> btn-warning <!-- ENDIF posts.favourited -->" type="button">
|
<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>
|
<span class="favourite-text">[[topic:favourite]]</span>
|
||||||
|
|||||||
13
src/posts.js
13
src/posts.js
@@ -187,7 +187,7 @@ var RDB = require('./redis'),
|
|||||||
|
|
||||||
if (pids.length) {
|
if (pids.length) {
|
||||||
plugins.fireHook('filter:post.getTopic', pids, function(err, posts) {
|
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) {
|
Posts.getPostsByPids(pids, function(err, posts) {
|
||||||
plugins.fireHook('action:post.gotTopic', posts);
|
plugins.fireHook('action:post.gotTopic', posts);
|
||||||
callback(posts);
|
callback(posts);
|
||||||
@@ -370,17 +370,6 @@ var RDB = require('./redis'),
|
|||||||
winston.err('invalid time value');
|
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;
|
postData.content = content;
|
||||||
_callback(null, postData);
|
_callback(null, postData);
|
||||||
|
|||||||
@@ -160,8 +160,17 @@ var RDB = require('./redis'),
|
|||||||
|
|
||||||
Topics.getTopicPosts = function(tid, start, end, current_user, callback) {
|
Topics.getTopicPosts = function(tid, start, end, current_user, callback) {
|
||||||
posts.getPostsByTid(tid, start, end, function(postData) {
|
posts.getPostsByTid(tid, start, end, function(postData) {
|
||||||
if (Array.isArray(postData) && !postData.length)
|
if (Array.isArray(postData) && !postData.length) {
|
||||||
return callback([]);
|
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) {
|
function getFavouritesData(next) {
|
||||||
var pids = [];
|
var pids = [];
|
||||||
@@ -482,8 +491,9 @@ var RDB = require('./redis'),
|
|||||||
|
|
||||||
Topics.getTopicWithPosts = function(tid, current_user, start, end, callback) {
|
Topics.getTopicWithPosts = function(tid, current_user, start, end, callback) {
|
||||||
threadTools.exists(tid, function(exists) {
|
threadTools.exists(tid, function(exists) {
|
||||||
if (!exists)
|
if (!exists) {
|
||||||
return callback(new Error('Topic tid \'' + tid + '\' not found'));
|
return callback(new Error('Topic tid \'' + tid + '\' not found'));
|
||||||
|
}
|
||||||
|
|
||||||
Topics.markAsRead(tid, current_user);
|
Topics.markAsRead(tid, current_user);
|
||||||
Topics.increaseViewCount(tid);
|
Topics.increaseViewCount(tid);
|
||||||
|
|||||||
Reference in New Issue
Block a user