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

This commit is contained in:
Julian Lam
2013-11-28 17:37:41 -05:00
9 changed files with 84 additions and 64 deletions

View File

@@ -29,7 +29,9 @@
Feed.updateTopic = function (tid, callback) {
topics.getTopicWithPosts(tid, 0, 0, -1, function (err, topicData) {
if (err) return callback(new Error('topic-invalid'));
if (err) {
return callback(new Error('topic-invalid'));
}
var feed = new rss({
title: topicData.topic_name,
@@ -40,13 +42,14 @@
author: topicData.posts[0].username,
ttl: Feed.defaults.ttl
}),
topic_posts = topicData.posts.concat(topicData.posts),
dateStamp;
// Add pubDate if topic contains posts
if (topicData.posts.length > 0) feed.pubDate = new Date(parseInt(topicData.posts[0].timestamp, 10)).toUTCString();
if (topicData.posts.length > 0) {
feed.pubDate = new Date(parseInt(topicData.posts[0].timestamp, 10)).toUTCString();
}
async.each(topic_posts, function(postData, next) {
async.each(topicData.posts, function(postData, next) {
if (postData.deleted === '0') {
dateStamp = new Date(parseInt(postData.edited === '0' ? postData.timestamp : postData.edited, 10)).toUTCString();
@@ -65,7 +68,9 @@
winston.info('[rss] Re-generated RSS Feed for tid ' + tid + '.');
}
if (callback) callback();
if (callback) {
callback();
}
});
});

View File

@@ -54,18 +54,25 @@ var RDB = require('./redis'),
'reputation': 0,
'editor': '',
'edited': 0,
'deleted': 0,
'fav_button_class': '',
'fav_star_class': 'fa-star-o',
'show_banned': 'hide',
'relativeTime': new Date(timestamp).toISOString(),
'post_rep': '0',
'edited-class': 'none',
'relativeEditTime': ''
'deleted': 0
//TODO : write upgrade script to remove these fields from the database -barisu
//'fav_button_class': '',
//'fav_star_class': 'fa-star-o',
//'show_banned': 'hide',
//'relativeTime': new Date(timestamp).toISOString(),
//'post_rep': '0',
//'edited-class': 'none',
//'relativeEditTime': ''
};
RDB.hmset('post:' + pid, postData);
postData.favourited = false;
postData.display_moderator_tools = true;
postData.relativeTime = new Date(timestamp).toISOString();
//TODO : remove this once template bug is fixed -barisu (https://github.com/designcreateplay/NodeBB/issues/574)
postData.fav_star_class = 'fa-star-o';
topics.addPostToTopic(tid, pid);
topics.increasePostCount(tid);
topics.updateTimestamp(tid, timestamp);
@@ -178,7 +185,6 @@ var RDB = require('./redis'),
if(err) {
return callback(err, null);
}
callback(null, postData);
});
});
@@ -217,7 +223,7 @@ var RDB = require('./redis'),
post.userslug = userData.userslug || '';
post.user_rep = userData.reputation || 0;
post.user_postcount = userData.postcount || 0;
post.user_banned = userData.banned || '0';
post.user_banned = userData.banned === '1';
post.picture = userData.picture || require('gravatar').url('', {}, https = nconf.get('https'));
post.signature = signature;
@@ -367,8 +373,6 @@ var RDB = require('./redis'),
async.map(replies, function(postData, _callback) {
if (postData) {
postData.post_rep = postData.reputation;
postData['edited-class'] = postData.editor !== '' ? '' : 'none';
try {
postData.relativeTime = new Date(parseInt(postData.timestamp,10)).toISOString();
postData.relativeEditTime = postData.edited !== '0' ? (new Date(parseInt(postData.edited,10)).toISOString()) : '';

View File

@@ -535,18 +535,18 @@ var user = require('./../user.js'),
return callerUID == uid || (data.email && (data.showemail && data.showemail === "1"));
}
if (!canSeeEmail())
if (!canSeeEmail()) {
data.email = "";
}
if (callerUID == uid && (!data.showemail || data.showemail === "0"))
if (callerUID == uid && (!data.showemail || data.showemail === "0")) {
data.emailClass = "";
else
} else {
data.emailClass = "hide";
}
data.websiteName = data.website.replace('http://', '').replace('https://', '');
data.show_banned = data.banned === '1' ? '' : 'hide';
data.banned = data.banned === '1';
data.uid = uid;
data.yourid = callerUID;
data.theirid = uid;

View File

@@ -196,11 +196,10 @@ var RDB = require('./redis'),
privileges = results[2];
for (var i = 0; i < postData.length; ++i) {
postData[i].favourited = fav_data[postData[i].pid] === 1;
postData[i].fav_button_class = fav_data[postData[i].pid] ? 'btn-warning' : '';
postData[i].fav_star_class = fav_data[postData[i].pid] ? 'fa-star' : 'fa-star-o';
postData[i]['display_moderator_tools'] = ((current_user != 0) && (postData[i].uid == current_user || privileges.editable)) ? 'show' : 'none';
postData[i].show_banned = postData[i].user_banned === '1' ? 'show' : 'hide';
postData[i].display_moderator_tools = ((current_user != 0) && (postData[i].uid == current_user || privileges.editable));
}
callback(postData);