mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-04 06:40:44 +01:00
changes to templates
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
<ul id="topics-container" itemscope itemtype="http://www.schema.org/ItemList" data-nextstart="{nextStart}">
|
||||
<meta itemprop="itemListOrder" content="descending">
|
||||
<!-- BEGIN topics -->
|
||||
<li class="category-item {topics.deleted-class} {topics.unread-class}" itemprop="itemListElement">
|
||||
<li class="category-item <!-- IF topics.deleted -->deleted<!-- ENDIF topics.deleted --><!-- IF topics.unread -->unread<!-- ENDIF topics.unread -->" itemprop="itemListElement">
|
||||
|
||||
<div class="col-md-12 col-xs-12 panel panel-default topic-row">
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<a href="../../topic/{topics.slug}" itemprop="url">
|
||||
<meta itemprop="name" content="{topics.title}">
|
||||
|
||||
<strong><i class="fa {topics.pin-icon}"></i> <i class="fa {topics.lock-icon}"></i></strong>
|
||||
<strong><!-- IF topics.pinned --><i class="fa fa-thumb-tack"></i><!-- ENDIF topics.pinned --> <!-- IF topics.locked --><i class="fa fa-lock"></i><!-- ENDIF topics.locked --></strong>
|
||||
<span class="topic-title">{topics.title}</span>
|
||||
</a>
|
||||
</h3>
|
||||
@@ -74,13 +74,13 @@
|
||||
<!-- IF topics.unreplied -->
|
||||
[[category:no_replies]]
|
||||
<!-- ELSE -->
|
||||
<a href="../../user/{topics.teaser_userslug}">
|
||||
<img class="teaser-pic" src="{topics.teaser_userpicture}" title="{topics.teaser_username}"/>
|
||||
<a href="../../user/{topics.teaser.userslug}">
|
||||
<img class="teaser-pic" src="{topics.teaser.picture}" title="{topics.teaser.username}"/>
|
||||
</a>
|
||||
<a href="../../topic/{topics.slug}#{topics.teaser_pid}">
|
||||
<a href="../../topic/{topics.slug}#{topics.teaser.pid}">
|
||||
[[category:replied]]
|
||||
</a>
|
||||
<span class="timeago" title="{topics.teaser_timestamp}"></span>
|
||||
<span class="timeago" title="{topics.teaser.timestamp}"></span>
|
||||
<!-- ENDIF topics.unreplied -->
|
||||
</span>
|
||||
</small>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<div class="col-md-12">
|
||||
<ul id="topics-container" data-nextstart="{nextStart}">
|
||||
<!-- BEGIN topics -->
|
||||
<li class="category-item {topics.deleted-class} {topics.unread-class}">
|
||||
<li class="category-item <!-- IF topics.deleted --> deleted<!-- ENDIF topics.deleted --><!-- IF topics.unread --> unread<!-- ENDIF topics.unread -->">
|
||||
<div class="col-md-12 col-xs-12 panel panel-default topic-row">
|
||||
<a href="{relative_path}/user/{topics.userslug}" class="pull-left">
|
||||
<img class="img-rounded user-img" src="{topics.picture}" title="{topics.username}" />
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
<h3>
|
||||
<a href="{relative_path}/topic/{topics.slug}">
|
||||
<strong><i class="fa {topics.pin-icon}"></i><i class="fa {topics.lock-icon}"></i></strong>
|
||||
<strong><!-- IF topics.pinned --><i class="fa fa-thumb-tack"></i><!-- ENDIF topics.pinned --> <!-- IF topics.locked --><i class="fa fa-lock"></i><!-- ENDIF topics.locked --></strong>
|
||||
<span class="topic-title">{topics.title}</span>
|
||||
</a>
|
||||
</h3>
|
||||
@@ -50,8 +50,8 @@
|
||||
|
|
||||
<span>
|
||||
[[category:posted]] [[global:in]]
|
||||
<a href="{relative_path}/category/{topics.categorySlug}">
|
||||
<i class="fa {topics.categoryIcon}"></i> {topics.categoryName}
|
||||
<a href="{relative_path}/category/{topics.category.slug}">
|
||||
<i class="fa {topics.category.icon}"></i> {topics.category.name}
|
||||
</a>
|
||||
<span class="timeago" title="{topics.relativeTime}"></span>
|
||||
</span>
|
||||
@@ -61,13 +61,13 @@
|
||||
<!-- IF topics.unreplied -->
|
||||
[[category:no_replies]]
|
||||
<!-- ELSE -->
|
||||
<a href="{relative_path}/user/{topics.teaser_userslug}">
|
||||
<img class="teaser-pic" src="{topics.teaser_userpicture}" title="{topics.teaser_username}"/>
|
||||
<a href="{relative_path}/user/{topics.teaser.userslug}">
|
||||
<img class="teaser-pic" src="{topics.teaser.picture}" title="{topics.teaser.username}"/>
|
||||
</a>
|
||||
<a href="{relative_path}/topic/{topics.slug}#{topics.teaser_pid}">
|
||||
<a href="{relative_path}/topic/{topics.slug}#{topics.teaser.pid}">
|
||||
[[category:replied]]
|
||||
</a>
|
||||
<span class="timeago" title="{topics.teaser_timestamp}"></span>
|
||||
<span class="timeago" title="{topics.teaser.timestamp}"></span>
|
||||
<!-- ENDIF topics.unreplied -->
|
||||
</span>
|
||||
</small>
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<div class="col-md-12">
|
||||
<ul id="topics-container" data-nextstart="{nextStart}">
|
||||
<!-- BEGIN topics -->
|
||||
<li class="category-item {topics.deleted-class} {topics.unread-class}">
|
||||
<li class="category-item <!-- IF topics.deleted --> deleted<!-- ENDIF topics.deleted --><!-- IF topics.unread --> unread<!-- ENDIF topics.unread -->">
|
||||
<div class="col-md-12 col-xs-12 panel panel-default topic-row">
|
||||
<a href="{relative_path}/user/{topics.userslug}" class="pull-left">
|
||||
<img class="img-rounded user-img" src="{topics.picture}" title="{topics.username}" />
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
<h3>
|
||||
<a href="{relative_path}/topic/{topics.slug}">
|
||||
<strong><i class="fa {topics.pin-icon}"></i><i class="fa {topics.lock-icon}"></i></strong>
|
||||
<strong><!-- IF topics.pinned --><i class="fa fa-thumb-tack"></i><!-- ENDIF topics.pinned --> <!-- IF topics.locked --><i class="fa fa-lock"></i><!-- ENDIF topics.locked --></strong>
|
||||
<span class="topic-title">{topics.title}</span>
|
||||
</a>
|
||||
</h3>
|
||||
@@ -51,9 +51,7 @@
|
||||
|
|
||||
<span>
|
||||
[[category:posted]] [[global:in]]
|
||||
<a href="{relative_path}/category/{topics.categorySlug}">
|
||||
<i class="fa {topics.categoryIcon}"></i> {topics.categoryName}
|
||||
</a>
|
||||
<a href="{relative_path}/category/{topics.category.slug}"><i class="fa {topics.category.icon}"></i> {topics.category.name}</a>
|
||||
<span class="timeago" title="{topics.relativeTime}"></span>
|
||||
</span>
|
||||
</span>
|
||||
@@ -62,13 +60,13 @@
|
||||
<!-- IF topics.unreplied -->
|
||||
[[category:no_replies]]
|
||||
<!-- ELSE -->
|
||||
<a href="{relative_path}/user/{topics.teaser_userslug}">
|
||||
<img class="teaser-pic" src="{topics.teaser_userpicture}" title="{topics.teaser_username}"/>
|
||||
<a href="{relative_path}/user/{topics.teaser.userslug}">
|
||||
<img class="teaser-pic" src="{topics.teaser.picture}" title="{topics.teaser.username}"/>
|
||||
</a>
|
||||
<a href="{relative_path}/topic/{topics.slug}#{topics.teaser_pid}">
|
||||
<a href="{relative_path}/topic/{topics.slug}#{topics.teaser.pid}">
|
||||
[[category:replied]]
|
||||
</a>
|
||||
<span class="timeago" title="{topics.teaser_timestamp}"></span>
|
||||
<span class="timeago" title="{topics.teaser.timestamp}"></span>
|
||||
<!-- ENDIF topics.unreplied -->
|
||||
</span>
|
||||
</small>
|
||||
|
||||
@@ -19,14 +19,14 @@
|
||||
<div class="col-md-12">
|
||||
<ul id="topics-container" data-nextstart="{nextStart}">
|
||||
<!-- BEGIN topics -->
|
||||
<li class="category-item {topics.deleted-class}">
|
||||
<li class="category-item <!-- IF topics.deleted --> deleted<!-- ENDIF topics.deleted -->">
|
||||
<div class="col-md-12 col-xs-12 panel panel-default topic-row">
|
||||
<a href="{relative_path}/user/{topics.userslug}" class="pull-left">
|
||||
<img class="img-rounded user-img" src="{topics.picture}" title="{topics.username}" />
|
||||
</a>
|
||||
<h3>
|
||||
<a href="{relative_path}/topic/{topics.slug}">
|
||||
<strong><i class="fa {topics.pin-icon}"></i><i class="fa {topics.lock-icon}"></i></strong>
|
||||
<strong><!-- IF topics.pinned --><i class="fa fa-thumb-tack"></i><!-- ENDIF topics.pinned --> <!-- IF topics.locked --><i class="fa fa-lock"></i><!-- ENDIF topics.locked --></strong>
|
||||
<span class="topic-title">{topics.title}</span>
|
||||
</a>
|
||||
</h3>
|
||||
@@ -44,9 +44,7 @@
|
||||
|
|
||||
<span>
|
||||
[[category:posted]] [[global:in]]
|
||||
<a href="{relative_path}/category/{topics.categorySlug}">
|
||||
<i class="fa {topics.categoryIcon}"></i> {topics.categoryName}
|
||||
</a>
|
||||
<a href="{relative_path}/category/{topics.category.slug}"><i class="fa {topics.category.icon}"></i> {topics.category.name}</a>
|
||||
<span class="timeago" title="{topics.relativeTime}"></span>
|
||||
</span>
|
||||
</span>
|
||||
@@ -55,13 +53,13 @@
|
||||
<!-- IF topics.unreplied -->
|
||||
[[category:no_replies]]
|
||||
<!-- ELSE -->
|
||||
<a href="{relative_path}/user/{topics.teaser_userslug}">
|
||||
<img class="teaser-pic" src="{topics.teaser_userpicture}" title="{topics.teaser_username}"/>
|
||||
<a href="{relative_path}/user/{topics.teaser.userslug}">
|
||||
<img class="teaser-pic" src="{topics.teaser.picture}" title="{topics.teaser.username}"/>
|
||||
</a>
|
||||
<a href="{relative_path}/topic/{topics.slug}#{topics.teaser_pid}">
|
||||
<a href="{relative_path}/topic/{topics.slug}#{topics.teaser.pid}">
|
||||
[[category:replied]]
|
||||
</a>
|
||||
<span class="timeago" title="{topics.teaser_timestamp}"></span>
|
||||
<span class="timeago" title="{topics.teaser.timestamp}"></span>
|
||||
<!-- ENDIF topics.unreplied -->
|
||||
</span>
|
||||
</small>
|
||||
|
||||
@@ -153,7 +153,11 @@ var winston = require('winston'),
|
||||
|
||||
// Delete the thread if it is the last undeleted post
|
||||
threadTools.getLatestUndeletedPid(postData.tid, function(err, pid) {
|
||||
if (err && err.message === 'no-undeleted-pids-found') {
|
||||
if(err) {
|
||||
return winston.error(err.message);
|
||||
}
|
||||
|
||||
if (!pid) {
|
||||
threadTools.delete(postData.tid, uid, function(err) {
|
||||
if (err) {
|
||||
winston.error('Could not delete topic (tid: ' + postData.tid + ')', err.stack);
|
||||
@@ -166,7 +170,6 @@ var winston = require('winston'),
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
callback(null);
|
||||
});
|
||||
};
|
||||
@@ -182,7 +185,6 @@ var winston = require('winston'),
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
PostTools.restore = function(uid, pid, callback) {
|
||||
|
||||
@@ -53,6 +53,7 @@ SocketTopics.post = function(socket, data, callback) {
|
||||
}
|
||||
|
||||
if (result) {
|
||||
console.log(result.topicData);
|
||||
index.server.sockets.in('category_' + data.category_id).emit('event:new_topic', result.topicData);
|
||||
index.server.sockets.in('recent_posts').emit('event:new_topic', result.topicData);
|
||||
index.server.sockets.in('user/' + socket.uid).emit('event:new_post', {
|
||||
|
||||
@@ -310,8 +310,9 @@ var winston = require('winston'),
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (pids.length === 0) {
|
||||
return callback(new Error('no-undeleted-pids-found'));
|
||||
return callback(null, null);
|
||||
}
|
||||
|
||||
async.detectSeries(pids, function(pid, next) {
|
||||
@@ -322,7 +323,7 @@ var winston = require('winston'),
|
||||
if (pid) {
|
||||
callback(null, pid);
|
||||
} else {
|
||||
callback(new Error('no-undeleted-pids-found'));
|
||||
callback(null, null);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
147
src/topics.js
147
src/topics.js
@@ -134,12 +134,16 @@ var async = require('async'),
|
||||
next(null, postData);
|
||||
},
|
||||
function(postData, next) {
|
||||
Topics.getTopicForCategoryView(postData.tid, uid, function(err, topicData) {
|
||||
Topics.getTopicsByTids([postData.tid], data.cid, uid, function(err, topicData) {
|
||||
if(err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if(!topicData || !topicData.length) {
|
||||
return next(new Error('no-topic'));
|
||||
}
|
||||
topicData = topicData[0];
|
||||
topicData.unreplied = 1;
|
||||
console.log(topicData);
|
||||
next(null, {
|
||||
topicData: topicData,
|
||||
postData: postData
|
||||
@@ -325,18 +329,22 @@ var async = require('async'),
|
||||
|
||||
Topics.getTopicDataWithUser = function(tid, callback) {
|
||||
Topics.getTopicData(tid, function(err, topic) {
|
||||
if(err || !topic) {
|
||||
if (err || !topic) {
|
||||
return callback(err || new Error('topic doesn\'t exist'));
|
||||
}
|
||||
|
||||
user.getUserFields(topic.uid, ['username', 'userslug', 'picture'] , function(err, userData) {
|
||||
if(err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
topic.username = userData.username;
|
||||
topic.userslug = userData.userslug
|
||||
topic.picture = userData.picture;
|
||||
if (!userData) {
|
||||
userData = {};
|
||||
}
|
||||
|
||||
topic.username = userData.username || 'Anonymous';
|
||||
topic.userslug = userData.userslug || '';
|
||||
topic.picture = userData.picture || gravatar.url('', {}, true);
|
||||
callback(null, topic);
|
||||
});
|
||||
});
|
||||
@@ -669,47 +677,21 @@ var async = require('async'),
|
||||
}
|
||||
|
||||
function getTopicInfo(topicData, callback) {
|
||||
|
||||
function getUserInfo(next) {
|
||||
user.getUserFields(topicData.uid, ['username', 'userslug', 'picture'], next);
|
||||
}
|
||||
|
||||
function hasReadTopic(next) {
|
||||
Topics.hasReadTopic(topicData.tid, current_user, next);
|
||||
}
|
||||
|
||||
function getTeaserInfo(next) {
|
||||
Topics.getTeaser(topicData.tid, function(err, teaser) {
|
||||
next(null, teaser || {});
|
||||
});
|
||||
}
|
||||
|
||||
// temporary. I don't think this call should belong here
|
||||
|
||||
function getPrivileges(next) {
|
||||
categoryTools.privileges(cid, current_user, next);
|
||||
}
|
||||
|
||||
function getCategoryInfo(next) {
|
||||
categories.getCategoryFields(topicData.cid, ['name', 'slug', 'icon'], next);
|
||||
}
|
||||
|
||||
async.parallel([getUserInfo, hasReadTopic, getTeaserInfo, getPrivileges, getCategoryInfo], function(err, results) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
async.parallel({
|
||||
hasread : function (next) {
|
||||
Topics.hasReadTopic(topicData.tid, current_user, next);
|
||||
},
|
||||
teaser : function (next) {
|
||||
Topics.getTeaser(topicData.tid, next);
|
||||
},
|
||||
privileges : function (next) {
|
||||
categoryTools.privileges(topicData.cid, current_user, next);
|
||||
},
|
||||
categoryData : function (next) {
|
||||
console.log(topicData.cid);
|
||||
categories.getCategoryFields(topicData.cid, ['name', 'slug', 'icon'], next);
|
||||
}
|
||||
|
||||
callback(null, {
|
||||
username: results[0].username,
|
||||
userslug: results[0].userslug,
|
||||
picture: results[0].picture,
|
||||
userbanned: results[0].banned,
|
||||
hasread: results[1],
|
||||
teaserInfo: results[2],
|
||||
privileges: results[3],
|
||||
categoryData: results[4]
|
||||
});
|
||||
});
|
||||
}, callback);
|
||||
}
|
||||
|
||||
function isTopicVisible(topicData, topicInfo) {
|
||||
@@ -719,7 +701,8 @@ var async = require('async'),
|
||||
}
|
||||
|
||||
function loadTopic(tid, next) {
|
||||
Topics.getTopicData(tid, function(err, topicData) {
|
||||
|
||||
Topics.getTopicDataWithUser(tid, function(err, topicData) {
|
||||
if(err) {
|
||||
return next(err);
|
||||
}
|
||||
@@ -737,25 +720,14 @@ var async = require('async'),
|
||||
return next();
|
||||
}
|
||||
|
||||
topicData['pin-icon'] = parseInt(topicData.pinned, 10) === 1 ? 'fa-thumb-tack' : 'none';
|
||||
topicData['lock-icon'] = parseInt(topicData.locked, 10) === 1 ? 'fa-lock' : 'none';
|
||||
topicData['deleted-class'] = parseInt(topicData.deleted, 10) === 1 ? 'deleted' : '';
|
||||
topicData['unread-class'] = !(topicInfo.hasread && parseInt(current_user, 10) !== 0) ? 'unread' : '';
|
||||
|
||||
topicData.pinned = parseInt(topicData.pinned, 10) === 1;
|
||||
topicData.locked = parseInt(topicData.locked, 10) === 1;
|
||||
topicData.deleted = parseInt(topicData.deleted, 10) === 1;
|
||||
topicData.unread = !(topicInfo.hasread && parseInt(current_user, 10) !== 0);
|
||||
topicData.unreplied = parseInt(topicData.postcount, 10) === 1;
|
||||
topicData.username = topicInfo.username || 'anonymous';
|
||||
topicData.userslug = topicInfo.userslug || '';
|
||||
topicData.picture = topicInfo.picture || gravatar.url('', {}, true);
|
||||
topicData.categoryIcon = topicInfo.categoryData.icon;
|
||||
topicData.categoryName = topicInfo.categoryData.name;
|
||||
topicData.categorySlug = topicInfo.categoryData.slug;
|
||||
|
||||
topicData.teaser_username = topicInfo.teaserInfo.username || '';
|
||||
topicData.teaser_userslug = topicInfo.teaserInfo.userslug || '';
|
||||
topicData.teaser_userpicture = topicInfo.teaserInfo.picture || gravatar.url('', {}, true);
|
||||
topicData.teaser_pid = topicInfo.teaserInfo.pid;
|
||||
topicData.teaser_timestamp = utils.toISOString(topicInfo.teaserInfo.timestamp);
|
||||
topicData.category = topicInfo.categoryData;
|
||||
topicData.teaser = topicInfo.teaser;
|
||||
|
||||
next(null, topicData);
|
||||
});
|
||||
@@ -851,45 +823,6 @@ var async = require('async'),
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Topics.getTopicForCategoryView = function(tid, uid, callback) {
|
||||
|
||||
function getTopicData(next) {
|
||||
Topics.getTopicDataWithUser(tid, next);
|
||||
}
|
||||
|
||||
function getReadStatus(next) {
|
||||
Topics.hasReadTopic(tid, uid, next);
|
||||
}
|
||||
|
||||
function getTeaser(next) {
|
||||
Topics.getTeaser(tid, next);
|
||||
}
|
||||
|
||||
async.parallel([getTopicData, getReadStatus, getTeaser], function(err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var topicData = results[0],
|
||||
hasRead = results[1],
|
||||
teaser = results[2];
|
||||
|
||||
topicData['pin-icon'] = parseInt(topicData.pinned, 10) === 1 ? 'fa-thumb-tack' : 'none';
|
||||
topicData['lock-icon'] = parseInt(topicData.locked, 10) === 1 ? 'fa-lock' : 'none';
|
||||
topicData['unread-class'] = !(hasRead && parseInt(uid, 10) !== 0) ? 'unread' : '';
|
||||
|
||||
topicData.unread = !(hasRead && parseInt(uid, 10) !== 0);
|
||||
topicData.teaser_username = teaser.username || '';
|
||||
topicData.teaser_userslug = teaser.userslug || '';
|
||||
topicData.userslug = teaser.userslug || '';
|
||||
topicData.teaser_timestamp = utils.toISOString(teaser.timestamp);
|
||||
topicData.teaser_userpicture = teaser.picture;
|
||||
|
||||
callback(null, topicData);
|
||||
});
|
||||
};
|
||||
|
||||
Topics.getAllTopics = function(start, end, callback) {
|
||||
db.getSortedSetRevRange('topics:tid', start, end, function(err, tids) {
|
||||
if(err) {
|
||||
@@ -1037,6 +970,10 @@ var async = require('async'),
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (!pid) {
|
||||
return callback(null, null);
|
||||
}
|
||||
|
||||
posts.getPostFields(pid, ['pid', 'uid', 'timestamp'], function(err, postData) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
@@ -1052,9 +989,9 @@ var async = require('async'),
|
||||
callback(null, {
|
||||
pid: postData.pid,
|
||||
username: userData.username || 'anonymous',
|
||||
userslug: userData.userslug,
|
||||
userslug: userData.userslug || '',
|
||||
picture: userData.picture || gravatar.url('', {}, true),
|
||||
timestamp: postData.timestamp
|
||||
timestamp: utils.toISOString(postData.timestamp)
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user