Merge remote-tracking branch 'upstream/master'

v1.18.x
akhoury 11 years ago
commit b89cf6f480

@ -14,7 +14,8 @@ var db = require('./database'),
async = require('async'),
nconf = require('nconf'),
validator = require('validator'),
winston = require('winston');
winston = require('winston'),
gravatar = require('gravatar');
(function(Posts) {
var customUserInfo = {};
@ -202,12 +203,16 @@ var db = require('./database'),
}
postTools.parseSignature(userData.signature, function(err, signature) {
if(err) {
return callback(err);
}
post.username = userData.username || 'anonymous';
post.userslug = userData.userslug || '';
post.user_rep = userData.reputation || 0;
post.user_postcount = userData.postcount || 0;
post.user_banned = parseInt(userData.banned, 10) === 1;
post.picture = userData.picture || require('gravatar').url('', {}, https = nconf.get('https'));
post.picture = userData.picture || gravatar.url('', {}, https = nconf.get('https'));
post.signature = signature;
for (var info in customUserInfo) {
@ -217,11 +222,16 @@ var db = require('./database'),
}
plugins.fireHook('filter:posts.custom_profile_info', {profile: "", uid: post.uid, pid: post.pid}, function(err, profile_info) {
if(err) {
return callback(err);
}
post.additional_profile_info = profile_info.profile;
if (post.editor !== '') {
user.getUserFields(post.editor, ['username', 'userslug'], function(err, editorData) {
if (err) return callback();
if (err) {
return callback(err);
}
post.editorname = editorData.username;
post.editorslug = editorData.userslug;

@ -39,29 +39,22 @@ var path = require('path'),
res.json(200, config);
});
app.get('/home', function (req, res, next) {
app.get('/home', function (req, res) {
var uid = (req.user) ? req.user.uid : 0;
categories.getAllCategories(uid, function (err, data) {
data.categories = data.categories.filter(function (category) {
return (!category.disabled || parseInt(category.disabled, 10) === 0);
});
function getRecentReplies(category, callback) {
function iterator(category, callback) {
categories.getRecentReplies(category.cid, 2, function (err, posts) {
if(err) {
return callback(err);
}
category.posts = posts;
category.post_count = posts.length > 2 ? 2 : posts.length;
callback(null);
});
}
async.each(data.categories, getRecentReplies, function (err) {
if(err) {
return next(err);
}
async.each(data.categories, iterator, function (err) {
data.motd_class = (parseInt(meta.config.show_motd, 10) === 1 || meta.config.show_motd === undefined) ? '' : ' none';
data.motd_class += (meta.config.motd && meta.config.motd.length > 0 ? '' : ' default');
@ -244,10 +237,6 @@ var path = require('path'),
return callback(err, null);
}
if(pids.length > 50) {
pids = pids.splice(0, 50);
}
posts.getPostSummaryByPids(pids, false, function (err, posts) {
if (err){
return callback(err, null);
@ -263,10 +252,6 @@ var path = require('path'),
return callback(err, null);
}
if(tids.length > 50) {
tids = tids.splice(0, 50);
}
topics.getTopicsByTids(tids, 0, function (topics) {
callback(null, topics);
}, 0);
@ -313,7 +298,7 @@ var path = require('path'),
app.get('/500', function(req, res) {
res.json({errorMessage: 'testing'});
})
});
});
}
}(exports));
Loading…
Cancel
Save