mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-30 18:46:01 +01:00
more cleanup and changes to topics
This commit is contained in:
@@ -1,9 +1,15 @@
|
|||||||
|
|
||||||
|
<input type="hidden" template-variable="category_id" value="{cid}" />
|
||||||
|
<input type="hidden" template-variable="category_name" value="{name}" />
|
||||||
|
<input type="hidden" template-variable="currentPage" value="{currentPage}" />
|
||||||
|
<input type="hidden" template-variable="pageCount" value="{pageCount}" />
|
||||||
|
|
||||||
<ol class="breadcrumb">
|
<ol class="breadcrumb">
|
||||||
<li itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
|
<li itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
|
||||||
<a href="{relative_path}/" itemprop="url"><span itemprop="title">[[global:home]]</span></a>
|
<a href="{relative_path}/" itemprop="url"><span itemprop="title">[[global:home]]</span></a>
|
||||||
</li>
|
</li>
|
||||||
<li class="active" itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
|
<li class="active" itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
|
||||||
<span itemprop="title">{category_name} <a target="_blank" href="../{category_id}.rss"><i class="fa fa-rss-square"></i></a></span>
|
<span itemprop="title">{name} <a target="_blank" href="../{cid}.rss"><i class="fa fa-rss-square"></i></a></span>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
@@ -109,7 +115,3 @@
|
|||||||
<!-- ENDIF topics.length -->
|
<!-- ENDIF topics.length -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="hidden" template-variable="category_id" value="{category_id}" />
|
|
||||||
<input type="hidden" template-variable="category_name" value="{category_name}" />
|
|
||||||
<input type="hidden" template-variable="currentPage" value="{currentPage}" />
|
|
||||||
<input type="hidden" template-variable="pageCount" value="{pageCount}" />
|
|
||||||
@@ -3,17 +3,17 @@
|
|||||||
<a href="{relative_path}/" itemprop="url"><span itemprop="title">[[global:home]]</span></a>
|
<a href="{relative_path}/" itemprop="url"><span itemprop="title">[[global:home]]</span></a>
|
||||||
</li>
|
</li>
|
||||||
<li class="active" itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
|
<li class="active" itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
|
||||||
<span itemprop="title">{category_name} <a target="_blank" href="../{category_id}.rss"><i class="fa fa-rss-square"></i></a></span>
|
<span itemprop="title">{name} <a target="_blank" href="../{cid}.rss"><i class="fa fa-rss-square"></i></a></span>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
<ul class="topics" itemscope itemtype="http://www.schema.org/ItemList" data-nextstart="{nextStart}">
|
<ul class="topics" itemscope itemtype="http://www.schema.org/ItemList" data-nextstart="{nextStart}">
|
||||||
<!-- BEGIN topics -->
|
<!-- BEGIN topics -->
|
||||||
<li itemprop="itemListElement">
|
<li itemprop="itemListElement">
|
||||||
<meta itemprop="name" content="{topics.title}">
|
<meta itemprop="name" content="{topics.title}">
|
||||||
<span class="timestamp">{topics.teaser_timestamp}</span>
|
<span class="timestamp">{topics.teaser.timestamp}</span>
|
||||||
<a href="../../topic/{topics.slug}" itemprop="url">{topics.title} ({topics.postcount})</a>
|
<a href="../../topic/{topics.slug}" itemprop="url">{topics.title} ({topics.postcount})</a>
|
||||||
<div class="teaser">
|
<div class="teaser">
|
||||||
<img class="img-thumbnail" src="{topics.teaser_userpicture}" />
|
<img class="img-thumbnail" src="{topics.teaser.picture}" />
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
<a href="{relative_path}/" itemprop="url"><span itemprop="title">[[global:home]]</span></a>
|
<a href="{relative_path}/" itemprop="url"><span itemprop="title">[[global:home]]</span></a>
|
||||||
</li>
|
</li>
|
||||||
<li itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
|
<li itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
|
||||||
<a href="{relative_path}/category/{category_slug}" itemprop="url"><span itemprop="title">{category_name}</span></a>
|
<a href="{relative_path}/category/{category.slug}" itemprop="url"><span itemprop="title">{category.name}</span></a>
|
||||||
</li>
|
</li>
|
||||||
<li class="active" itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
|
<li class="active" itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
|
||||||
<span itemprop="title">{topic_name} <a target="_blank" href="../{topic_id}.rss"><i class="fa fa-rss-square"></i></a></span>
|
<span itemprop="title">{title} <a target="_blank" href="../{tid}.rss"><i class="fa fa-rss-square"></i></a></span>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
<ul class="posts">
|
<ul class="posts">
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<input type="hidden" template-variable="expose_tools" value="{expose_tools}" />
|
<input type="hidden" template-variable="expose_tools" value="{expose_tools}" />
|
||||||
<input type="hidden" template-variable="topic_id" value="{topic_id}" />
|
<input type="hidden" template-variable="topic_id" value="{tid}" />
|
||||||
<input type="hidden" template-variable="currentPage" value="{currentPage}" />
|
<input type="hidden" template-variable="currentPage" value="{currentPage}" />
|
||||||
<input type="hidden" template-variable="pageCount" value="{pageCount}" />
|
<input type="hidden" template-variable="pageCount" value="{pageCount}" />
|
||||||
<input type="hidden" template-variable="locked" value="{locked}" />
|
<input type="hidden" template-variable="locked" value="{locked}" />
|
||||||
<input type="hidden" template-variable="deleted" value="{deleted}" />
|
<input type="hidden" template-variable="deleted" value="{deleted}" />
|
||||||
<input type="hidden" template-variable="pinned" value="{pinned}" />
|
<input type="hidden" template-variable="pinned" value="{pinned}" />
|
||||||
<input type="hidden" template-variable="topic_name" value="{topic_name}" />
|
<input type="hidden" template-variable="topic_name" value="{title}" />
|
||||||
<input type="hidden" template-variable="postcount" value="{postcount}" />
|
<input type="hidden" template-variable="postcount" value="{postcount}" />
|
||||||
|
|
||||||
<div class="topic">
|
<div class="topic">
|
||||||
@@ -14,14 +14,14 @@
|
|||||||
<a href="{relative_path}/" itemprop="url"><span itemprop="title">[[global:home]]</span></a>
|
<a href="{relative_path}/" itemprop="url"><span itemprop="title">[[global:home]]</span></a>
|
||||||
</li>
|
</li>
|
||||||
<li itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
|
<li itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
|
||||||
<a href="{relative_path}/category/{category_slug}" itemprop="url"><span itemprop="title">{category_name}</span></a>
|
<a href="{relative_path}/category/{category.slug}" itemprop="url"><span itemprop="title">{category.name}</span></a>
|
||||||
</li>
|
</li>
|
||||||
<li class="active" itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
|
<li class="active" itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
|
||||||
<span itemprop="title">{topic_name} <a target="_blank" href="../{topic_id}.rss"><i class="fa fa-rss-square"></i></a></span>
|
<span itemprop="title">{title} <a target="_blank" href="../{tid}.rss"><i class="fa fa-rss-square"></i></a></span>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
<ul id="post-container" class="posts" data-tid="{topic_id}">
|
<ul id="post-container" class="posts" data-tid="{tid}">
|
||||||
<!-- BEGIN posts -->
|
<!-- BEGIN posts -->
|
||||||
<li class="post-row infiniteloaded" data-pid="{posts.pid}" data-uid="{posts.uid}" data-username="{posts.username}" data-userslug="{posts.userslug}" data-index="{posts.index}" data-deleted="{posts.deleted}" itemscope itemtype="http://schema.org/Comment">
|
<li class="post-row infiniteloaded" data-pid="{posts.pid}" data-uid="{posts.uid}" data-username="{posts.username}" data-userslug="{posts.userslug}" 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>
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
<img itemprop="image" src="{posts.picture}" align="left" class="img-thumbnail" width=150 height=150 />
|
<img itemprop="image" src="{posts.picture}" align="left" class="img-thumbnail" width=150 height=150 />
|
||||||
</a>
|
</a>
|
||||||
<h3 class="main-post">
|
<h3 class="main-post">
|
||||||
<p id="topic_title_{posts.pid}" class="topic-title" itemprop="name">{topic_name}</p>
|
<p id="topic_title_{posts.pid}" class="topic-title" itemprop="name">{title}</p>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<div class="topic-buttons">
|
<div class="topic-buttons">
|
||||||
|
|||||||
@@ -59,39 +59,27 @@ var db = require('./database'),
|
|||||||
Categories.markAsRead(cid, uid);
|
Categories.markAsRead(cid, uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCategoryData(next) {
|
|
||||||
Categories.getCategoryData(cid, next);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getTopics(next) {
|
|
||||||
Categories.getCategoryTopics(cid, start, end, uid, next);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getPageCount(next) {
|
|
||||||
Categories.getPageCount(cid, uid, next);
|
|
||||||
}
|
|
||||||
|
|
||||||
async.parallel({
|
async.parallel({
|
||||||
'category': getCategoryData,
|
category: function(next) {
|
||||||
'topics': getTopics,
|
Categories.getCategoryData(cid, next);
|
||||||
'pageCount': getPageCount
|
},
|
||||||
|
topics : function(next) {
|
||||||
|
Categories.getCategoryTopics(cid, start, end, uid, next);
|
||||||
|
},
|
||||||
|
pageCount: function(next) {
|
||||||
|
Categories.getPageCount(cid, uid, next);
|
||||||
|
}
|
||||||
}, function(err, results) {
|
}, function(err, results) {
|
||||||
if(err) {
|
if(err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
var category = {
|
var category = results.category;
|
||||||
'category_name': results.category.name,
|
category.topics = results.topics.topics;
|
||||||
'category_description': results.category.description,
|
category.nextStart = results.topics.nextStart;
|
||||||
'link': results.category.link,
|
category.pageCount = results.pageCount;
|
||||||
'disabled': results.category.disabled,
|
category.disableSocialButtons = meta.config.disableSocialButtons !== undefined ? parseInt(meta.config.disableSocialButtons, 10) !== 0 : false;
|
||||||
'topic_row_size': 'col-md-9',
|
category.topic_row_size = 'col-md-9';
|
||||||
'category_id': cid,
|
|
||||||
'topics': results.topics.topics,
|
|
||||||
'nextStart': results.topics.nextStart,
|
|
||||||
'pageCount': results.pageCount,
|
|
||||||
'disableSocialButtons': meta.config.disableSocialButtons !== undefined ? parseInt(meta.config.disableSocialButtons, 10) !== 0 : false,
|
|
||||||
};
|
|
||||||
|
|
||||||
callback(null, category);
|
callback(null, category);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -169,7 +169,8 @@ var path = require('path'),
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.get('/topic/:id/:slug?', function (req, res, next) {
|
app.get('/topic/:id/:slug?', function (req, res, next) {
|
||||||
var uid = (req.user) ? req.user.uid : 0;
|
var uid = req.user? parseInt(req.user.uid, 10) : 0;
|
||||||
|
var tid = req.params.id;
|
||||||
var page = 1;
|
var page = 1;
|
||||||
if(req.query && req.query.page) {
|
if(req.query && req.query.page) {
|
||||||
page = req.query.page;
|
page = req.query.page;
|
||||||
@@ -187,29 +188,41 @@ var path = require('path'),
|
|||||||
var start = (page - 1) * settings.postsPerPage;
|
var start = (page - 1) * settings.postsPerPage;
|
||||||
var end = start + settings.postsPerPage - 1;
|
var end = start + settings.postsPerPage - 1;
|
||||||
|
|
||||||
ThreadTools.privileges(req.params.id, uid, function(err, privileges) {
|
ThreadTools.privileges(tid, uid, function(err, privileges) {
|
||||||
if (privileges.read) {
|
if(err) {
|
||||||
topics.getTopicWithPosts(req.params.id, uid, start, end, false, function (err, data) {
|
return next(err);
|
||||||
if(err) {
|
}
|
||||||
return next(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(page > data.pageCount) {
|
if(!privileges.read) {
|
||||||
return res.send(404);
|
|
||||||
}
|
|
||||||
|
|
||||||
data.currentPage = page;
|
|
||||||
data.privileges = privileges;
|
|
||||||
|
|
||||||
if (parseInt(data.deleted, 10) === 1 && parseInt(data.expose_tools, 10) === 0) {
|
|
||||||
return res.json(404, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
res.json(data);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
res.send(403);
|
res.send(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
topics.getTopicWithPosts(tid, uid, start, end, function (err, data) {
|
||||||
|
if(err) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(page > data.pageCount) {
|
||||||
|
return res.send(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parseInt(data.deleted, 10) === 1 && parseInt(data.expose_tools, 10) === 0) {
|
||||||
|
return res.json(404, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
data.currentPage = page;
|
||||||
|
data.privileges = privileges;
|
||||||
|
|
||||||
|
if (uid) {
|
||||||
|
topics.markAsRead(tid, uid, function(err) {
|
||||||
|
topics.pushUnreadCount(uid);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
topics.increaseViewCount(tid);
|
||||||
|
|
||||||
|
res.json(data);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
function generateForTopic(req, res, next) {
|
function generateForTopic(req, res, next) {
|
||||||
var tid = req.params.topic_id;
|
var tid = req.params.topic_id;
|
||||||
|
|
||||||
topics.getTopicWithPosts(tid, 0, 0, 25, true, function (err, topicData) {
|
topics.getTopicWithPosts(tid, 0, 0, 25, function (err, topicData) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
var author = topicData.posts.length ? topicData.posts[0].username : '';
|
var author = topicData.posts.length ? topicData.posts[0].username : '';
|
||||||
|
|
||||||
var feed = new rss({
|
var feed = new rss({
|
||||||
title: topicData.topic_name,
|
title: topicData.title,
|
||||||
description: description,
|
description: description,
|
||||||
feed_url: nconf.get('url') + '/topic/' + tid + '.rss',
|
feed_url: nconf.get('url') + '/topic/' + tid + '.rss',
|
||||||
site_url: nconf.get('url') + '/topic/' + topicData.slug,
|
site_url: nconf.get('url') + '/topic/' + topicData.slug,
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
dateStamp = new Date(parseInt(parseInt(postData.edited, 10) === 0 ? postData.timestamp : postData.edited, 10)).toUTCString();
|
dateStamp = new Date(parseInt(parseInt(postData.edited, 10) === 0 ? postData.timestamp : postData.edited, 10)).toUTCString();
|
||||||
|
|
||||||
feed.item({
|
feed.item({
|
||||||
title: 'Reply to ' + topicData.topic_name + ' on ' + dateStamp,
|
title: 'Reply to ' + topicData.title + ' on ' + dateStamp,
|
||||||
description: postData.content,
|
description: postData.content,
|
||||||
url: nconf.get('url') + '/topic/' + topicData.slug + '#' + postData.pid,
|
url: nconf.get('url') + '/topic/' + topicData.slug + '#' + postData.pid,
|
||||||
author: postData.username,
|
author: postData.username,
|
||||||
@@ -109,10 +109,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
var feed = new rss({
|
var feed = new rss({
|
||||||
title: categoryData.category_name,
|
title: categoryData.name,
|
||||||
description: categoryData.category_description,
|
description: categoryData.description,
|
||||||
feed_url: nconf.get('url') + '/category/' + cid + '.rss',
|
feed_url: nconf.get('url') + '/category/' + cid + '.rss',
|
||||||
site_url: nconf.get('url') + '/category/' + categoryData.category_id,
|
site_url: nconf.get('url') + '/category/' + categoryData.cid,
|
||||||
ttl: 60
|
ttl: 60
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -217,7 +217,6 @@ SocketPosts.getFavouritedUsers = function(socket, pid, callback) {
|
|||||||
callback(null, "");
|
callback(null, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(data);
|
|
||||||
var max = 5; //hardcoded
|
var max = 5; //hardcoded
|
||||||
var usernames = "";
|
var usernames = "";
|
||||||
|
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ SocketTopics.loadMore = function(socket, data, callback) {
|
|||||||
|
|
||||||
async.parallel({
|
async.parallel({
|
||||||
posts: function(next) {
|
posts: function(next) {
|
||||||
topics.getTopicPosts(data.tid, start, end, socket.uid, next);
|
topics.getTopicPosts(data.tid, start, end, socket.uid, false, next);
|
||||||
},
|
},
|
||||||
privileges: function(next) {
|
privileges: function(next) {
|
||||||
threadTools.privileges(data.tid, socket.uid, next);
|
threadTools.privileges(data.tid, socket.uid, next);
|
||||||
|
|||||||
101
src/topics.js
101
src/topics.js
@@ -634,7 +634,7 @@ var async = require('async'),
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Topics.getTopicsByTids = function(tids, cid, current_user, callback) {
|
Topics.getTopicsByTids = function(tids, cid, uid, callback) {
|
||||||
|
|
||||||
if (!Array.isArray(tids) || tids.length === 0) {
|
if (!Array.isArray(tids) || tids.length === 0) {
|
||||||
return callback(null, []);
|
return callback(null, []);
|
||||||
@@ -643,13 +643,13 @@ var async = require('async'),
|
|||||||
function getTopicInfo(topicData, callback) {
|
function getTopicInfo(topicData, callback) {
|
||||||
async.parallel({
|
async.parallel({
|
||||||
hasread : function (next) {
|
hasread : function (next) {
|
||||||
Topics.hasReadTopic(topicData.tid, current_user, next);
|
Topics.hasReadTopic(topicData.tid, uid, next);
|
||||||
},
|
},
|
||||||
teaser : function (next) {
|
teaser : function (next) {
|
||||||
Topics.getTeaser(topicData.tid, next);
|
Topics.getTeaser(topicData.tid, next);
|
||||||
},
|
},
|
||||||
privileges : function (next) {
|
privileges : function (next) {
|
||||||
categoryTools.privileges(topicData.cid, current_user, next);
|
categoryTools.privileges(topicData.cid, uid, next);
|
||||||
},
|
},
|
||||||
categoryData : function (next) {
|
categoryData : function (next) {
|
||||||
categories.getCategoryFields(topicData.cid, ['name', 'slug', 'icon'], next);
|
categories.getCategoryFields(topicData.cid, ['name', 'slug', 'icon'], next);
|
||||||
@@ -660,7 +660,7 @@ var async = require('async'),
|
|||||||
function isTopicVisible(topicData, topicInfo) {
|
function isTopicVisible(topicData, topicInfo) {
|
||||||
var deleted = parseInt(topicData.deleted, 10) !== 0;
|
var deleted = parseInt(topicData.deleted, 10) !== 0;
|
||||||
|
|
||||||
return !deleted || (deleted && topicInfo.privileges.view_deleted) || parseInt(topicData.uid, 10) === parseInt(current_user, 10);
|
return !deleted || (deleted && topicInfo.privileges.view_deleted) || parseInt(topicData.uid, 10) === parseInt(uid, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadTopic(tid, next) {
|
function loadTopic(tid, next) {
|
||||||
@@ -686,7 +686,7 @@ var async = require('async'),
|
|||||||
topicData.pinned = parseInt(topicData.pinned, 10) === 1;
|
topicData.pinned = parseInt(topicData.pinned, 10) === 1;
|
||||||
topicData.locked = parseInt(topicData.locked, 10) === 1;
|
topicData.locked = parseInt(topicData.locked, 10) === 1;
|
||||||
topicData.deleted = parseInt(topicData.deleted, 10) === 1;
|
topicData.deleted = parseInt(topicData.deleted, 10) === 1;
|
||||||
topicData.unread = !(topicInfo.hasread && parseInt(current_user, 10) !== 0);
|
topicData.unread = !(topicInfo.hasread && parseInt(uid, 10) !== 0);
|
||||||
topicData.unreplied = parseInt(topicData.postcount, 10) === 1;
|
topicData.unreplied = parseInt(topicData.postcount, 10) === 1;
|
||||||
|
|
||||||
topicData.category = topicInfo.categoryData;
|
topicData.category = topicInfo.categoryData;
|
||||||
@@ -710,78 +710,47 @@ var async = require('async'),
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Topics.getTopicWithPosts = function(tid, current_user, start, end, quiet, callback) {
|
Topics.getTopicWithPosts = function(tid, uid, start, end, callback) {
|
||||||
threadTools.exists(tid, function(err, exists) {
|
threadTools.exists(tid, function(err, exists) {
|
||||||
if (err || !exists) {
|
if (err || !exists) {
|
||||||
return callback(err || new Error('Topic tid \'' + tid + '\' not found'));
|
return callback(err || new Error('Topic tid \'' + tid + '\' not found'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// "quiet" is used for things like RSS feed updating, HTML parsing for non-js users, etc
|
async.parallel({
|
||||||
if (!quiet) {
|
topicData : function(next) {
|
||||||
Topics.markAsRead(tid, current_user, function(err) {
|
Topics.getTopicData(tid, next);
|
||||||
Topics.pushUnreadCount(current_user);
|
},
|
||||||
});
|
posts : function(next) {
|
||||||
Topics.increaseViewCount(tid);
|
Topics.getTopicPosts(tid, start, end, uid, false, next);
|
||||||
}
|
},
|
||||||
|
privileges : function(next) {
|
||||||
function getTopicData(next) {
|
threadTools.privileges(tid, uid, next);
|
||||||
Topics.getTopicData(tid, next);
|
},
|
||||||
}
|
category : function(next) {
|
||||||
|
Topics.getCategoryData(tid, next);
|
||||||
function getTopicPosts(next) {
|
},
|
||||||
Topics.getTopicPosts(tid, start, end, current_user, false, next);
|
pageCount : function(next) {
|
||||||
}
|
Topics.getPageCount(tid, uid, next);
|
||||||
|
},
|
||||||
function getPrivileges(next) {
|
threadTools : function(next) {
|
||||||
threadTools.privileges(tid, current_user, next);
|
Plugins.fireHook('filter:topic.thread_tools', [], next);
|
||||||
}
|
}
|
||||||
|
}, function(err, results) {
|
||||||
function getCategoryData(next) {
|
|
||||||
Topics.getCategoryData(tid, next);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getPageCount(next) {
|
|
||||||
Topics.getPageCount(tid, current_user, next);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getThreadTools(next) {
|
|
||||||
Plugins.fireHook('filter:topic.thread_tools', [], function(err, threadTools) {
|
|
||||||
next(err, threadTools);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async.parallel([getTopicData, getTopicPosts, getPrivileges, getCategoryData, getPageCount, getThreadTools], function(err, results) {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
winston.error('[Topics.getTopicWithPosts] Could not retrieve topic data: ', err.message);
|
winston.error('[Topics.getTopicWithPosts] Could not retrieve topic data: ', err.message);
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
var topicData = results[0],
|
var topicData = results.topicData;
|
||||||
privileges = results[2],
|
topicData.category = results.category;
|
||||||
categoryData = results[3],
|
topicData.posts = results.posts;
|
||||||
pageCount = results[4],
|
topicData.thread_tools = results.threadTools;
|
||||||
threadTools = results[5];
|
topicData.pageCount = results.pageCount;
|
||||||
|
topicData.unreplied = parseInt(topicData.postcount, 10) === 1;
|
||||||
|
topicData.expose_tools = results.privileges.editable ? 1 : 0;
|
||||||
|
topicData.disableSocialButtons = meta.config.disableSocialButtons !== undefined ? parseInt(meta.config.disableSocialButtons, 10) !== 0 : false;
|
||||||
|
|
||||||
callback(null, {
|
callback(null, topicData);
|
||||||
'topic_name': topicData.title,
|
|
||||||
'category_name': categoryData.name,
|
|
||||||
'category_slug': categoryData.slug,
|
|
||||||
'locked': topicData.locked,
|
|
||||||
'deleted': topicData.deleted,
|
|
||||||
'pinned': topicData.pinned,
|
|
||||||
'timestamp': topicData.timestamp,
|
|
||||||
'slug': topicData.slug,
|
|
||||||
'thumb': topicData.thumb,
|
|
||||||
'postcount': topicData.postcount,
|
|
||||||
'viewcount': topicData.viewcount,
|
|
||||||
'pageCount': pageCount,
|
|
||||||
'unreplied': parseInt(topicData.postcount, 10) === 1,
|
|
||||||
'topic_id': tid,
|
|
||||||
'expose_tools': privileges.editable ? 1 : 0,
|
|
||||||
'thread_tools': threadTools,
|
|
||||||
'disableSocialButtons': meta.config.disableSocialButtons !== undefined ? parseInt(meta.config.disableSocialButtons, 10) !== 0 : false,
|
|
||||||
'posts': results[1]
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -596,7 +596,7 @@ process.on('uncaughtException', function(err) {
|
|||||||
var start = (page - 1) * settings.topicsPerPage,
|
var start = (page - 1) * settings.topicsPerPage,
|
||||||
end = start + settings.topicsPerPage - 1;
|
end = start + settings.topicsPerPage - 1;
|
||||||
|
|
||||||
topics.getTopicWithPosts(tid, uid, start, end, true, function (err, topicData) {
|
topics.getTopicWithPosts(tid, uid, start, end, function (err, topicData) {
|
||||||
if (topicData) {
|
if (topicData) {
|
||||||
if (parseInt(topicData.deleted, 10) === 1 && parseInt(topicData.expose_tools, 10) === 0) {
|
if (parseInt(topicData.deleted, 10) === 1 && parseInt(topicData.expose_tools, 10) === 0) {
|
||||||
return next(new Error('Topic deleted'), null);
|
return next(new Error('Topic deleted'), null);
|
||||||
@@ -642,7 +642,7 @@ process.on('uncaughtException', function(err) {
|
|||||||
metaTags: [
|
metaTags: [
|
||||||
{
|
{
|
||||||
name: "title",
|
name: "title",
|
||||||
content: topicData.topic_name
|
content: topicData.title
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "description",
|
name: "description",
|
||||||
@@ -650,7 +650,7 @@ process.on('uncaughtException', function(err) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'og:title',
|
property: 'og:title',
|
||||||
content: topicData.topic_name
|
content: topicData.title
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'og:description',
|
property: 'og:description',
|
||||||
@@ -682,7 +682,7 @@ process.on('uncaughtException', function(err) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'article:section',
|
property: 'article:section',
|
||||||
content: topicData.category_name
|
content: topicData.category.name
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
linkTags: [
|
linkTags: [
|
||||||
@@ -693,7 +693,7 @@ process.on('uncaughtException', function(err) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
rel: 'up',
|
rel: 'up',
|
||||||
href: nconf.get('url') + '/category/' + topicData.category_slug
|
href: nconf.get('url') + '/category/' + topicData.category.slug
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}, function (err, header) {
|
}, function (err, header) {
|
||||||
@@ -783,15 +783,15 @@ process.on('uncaughtException', function(err) {
|
|||||||
metaTags: [
|
metaTags: [
|
||||||
{
|
{
|
||||||
name: 'title',
|
name: 'title',
|
||||||
content: categoryData.category_name
|
content: categoryData.name
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'og:title',
|
property: 'og:title',
|
||||||
content: categoryData.category_name
|
content: categoryData.name
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'description',
|
name: 'description',
|
||||||
content: categoryData.category_description
|
content: categoryData.description
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: "og:type",
|
property: "og:type",
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ describe('Categories', function() {
|
|||||||
it('should retrieve a newly created category by its ID', function(done) {
|
it('should retrieve a newly created category by its ID', function(done) {
|
||||||
Categories.getCategoryById(categoryObj.cid, 0, -1, 0, function(err, categoryData) {
|
Categories.getCategoryById(categoryObj.cid, 0, -1, 0, function(err, categoryData) {
|
||||||
assert(categoryData);
|
assert(categoryData);
|
||||||
assert.equal(categoryObj.name, categoryData.category_name);
|
assert.equal(categoryObj.name, categoryData.name);
|
||||||
assert.equal(categoryObj.description, categoryData.category_description);
|
assert.equal(categoryObj.description, categoryData.description);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user