Merge branch 'master' into v0.5.x

This commit is contained in:
Julian Lam
2014-09-15 21:39:17 -04:00
13 changed files with 71 additions and 44 deletions

View File

@@ -1,7 +1,7 @@
# <img alt="NodeBB" src="http://i.imgur.com/mYxPPtB.png" />
[![Build Status](https://travis-ci.org/NodeBB/NodeBB.svg?branch=master)](https://travis-ci.org/NodeBB/NodeBB)
[![Dependency Status](https://david-dm.org/nodebb/nodebb.svg)](https://david-dm.org/nodebb/nodebb)
[![Code Climate](https://codeclimate.com/github/designcreateplay/NodeBB.png)](https://codeclimate.com/github/designcreateplay/NodeBB)
[![Code Climate](https://codeclimate.com/github/NodeBB/NodeBB/badges/gpa.svg)](https://codeclimate.com/github/NodeBB/NodeBB)
[![Documentation Status](https://readthedocs.org/projects/nodebb/badge/?version=latest)](https://readthedocs.org/projects/nodebb/?badge=latest)
**NodeBB Forum Software** is powered by Node.js and built on a Redis database. It utilizes web sockets for instant interactions and real-time notifications. NodeBB is compatible down to IE8 and has many modern features out of the box such as social network integration and streaming discussions.

View File

@@ -43,7 +43,7 @@ define('forum/account/profile', ['forum/account/header'], function(header) {
};
function processPage() {
$('.user-recent-posts img').addClass('img-responsive');
$('.user-recent-posts img, .post-signature img').addClass('img-responsive');
}
function updateButtons() {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 KiB

View File

@@ -188,7 +188,7 @@ var db = require('./database'),
});
};
Categories.getVisibleCategories = function(uid, callback) {
Categories.getCategoriesByPrivilege = function(uid, privilege, callback) {
db.getSortedSetRange('categories:cid', 0, -1, function(err, cids) {
if (err) {
return callback(err);
@@ -198,7 +198,7 @@ var db = require('./database'),
return callback(null, []);
}
privileges.categories.filter('find', cids, uid, function(err, cids) {
privileges.categories.filter(privilege, cids, uid, function(err, cids) {
if (err) {
return callback(err);
}

View File

@@ -64,7 +64,7 @@ Controllers.home = function(req, res, next) {
},
categories: function (next) {
var uid = req.user ? req.user.uid : 0;
categories.getVisibleCategories(uid, function (err, categoryData) {
categories.getCategoriesByPrivilege(uid, 'find', function (err, categoryData) {
if (err) {
return next(err);
}

View File

@@ -70,7 +70,7 @@ topicsController.get = function(req, res, next) {
function (topicData, next) {
var description = '';
if(topicData.posts.length) {
if (topicData.posts[0] && topicData.posts[0].content) {
description = S(topicData.posts[0].content).stripTags().decodeHTMLEntities().s;
}
@@ -83,7 +83,7 @@ topicsController.get = function(req, res, next) {
var ogImageUrl = '';
if (topicData.thumb) {
ogImageUrl = topicData.thumb;
} else if(topicData.posts.length && topicData.posts[0].user && topicData.posts[0].user.picture){
} else if(topicData.posts.length && topicData.posts[0] && topicData.posts[0].user && topicData.posts[0].user.picture){
ogImageUrl = topicData.posts[0].user.picture;
} else if(meta.config['brand:logo']) {
ogImageUrl = meta.config['brand:logo'];

View File

@@ -1,6 +1,7 @@
'use strict';
var user = require('../user'),
var winston = require('winston'),
user = require('../user'),
translator = require('../../public/src/translator');
module.exports = function(Meta) {
@@ -14,7 +15,14 @@ module.exports = function(Meta) {
};
Meta.title.build = function (urlFragment, language, callback) {
Meta.title.parseFragment(decodeURIComponent(urlFragment), language, function(err, title) {
var uri = '';
try {
uri = decodeURIComponent(urlFragment);
} catch(e) {
winston.error('Invalid url fragment : ' + urlFragment, e.stack);
return callback(null, Meta.config.browserTitle || 'NodeBB');
}
Meta.title.parseFragment(uri, language, function(err, title) {
if (err) {
title = Meta.config.browserTitle || 'NodeBB';
} else {

View File

@@ -152,7 +152,7 @@ var async = require('async'),
if (!data || !Array.isArray(data.posts)) {
return callback(null, []);
}
data.posts = data.posts.filter(Boolean);
callback(null, data.posts);
});
});
@@ -357,7 +357,7 @@ var async = require('async'),
}
posts = posts.filter(function(post) {
return parseInt(results.topics[post.tid].deleted, 10) !== 1;
return results.topics[post.tid] && parseInt(results.topics[post.tid].deleted, 10) !== 1;
});
async.map(posts, function(post, next) {

View File

@@ -31,7 +31,7 @@ var path = require('path'),
async.parallel([
function(next) {
var categoryUrls = [];
categories.getVisibleCategories(0, function(err, categoriesData) {
categories.getCategoriesByPrivilege(0, 'find', function(err, categoriesData) {
if (err) {
return next(err);
}

View File

@@ -24,7 +24,7 @@ SocketCategories.getRecentReplies = function(socket, cid, callback) {
};
SocketCategories.get = function(socket, data, callback) {
categories.getAllCategories(callback);
categories.getCategoriesByPrivilege(socket.uid, 'find', callback);
};
SocketCategories.loadMore = function(socket, data, callback) {

View File

@@ -71,6 +71,10 @@ SocketModules.composer.push = function(socket, pid, callback) {
return callback(err);
}
if (!results.topic) {
return callback(new Error('[[error:no-topic]]'));
}
callback(null, {
pid: pid,
body: postData.content,

View File

@@ -172,9 +172,9 @@ var async = require('async'),
Topics.getTopicsData(tids, function(err, topics) {
function mapFilter(array, field) {
return array.map(function(topic) {
return topic[field];
return topic && topic[field];
}).filter(function(value, index, array) {
return array.indexOf(value) === index;
return value && array.indexOf(value) === index;
});
}
@@ -225,21 +225,23 @@ var async = require('async'),
});
for (var i=0; i<topics.length; ++i) {
topics[i].category = categories[topics[i].cid];
topics[i].category.disabled = parseInt(topics[i].category.disabled, 10) === 1;
topics[i].user = users[topics[i].uid];
topics[i].teaser = results.teasers[i];
topics[i].tags = results.tags[i];
if (topics[i]) {
topics[i].category = categories[topics[i].cid];
topics[i].category.disabled = parseInt(topics[i].category.disabled, 10) === 1;
topics[i].user = users[topics[i].uid];
topics[i].teaser = results.teasers[i];
topics[i].tags = results.tags[i];
topics[i].pinned = parseInt(topics[i].pinned, 10) === 1;
topics[i].locked = parseInt(topics[i].locked, 10) === 1;
topics[i].deleted = parseInt(topics[i].deleted, 10) === 1;
topics[i].unread = !(results.hasRead[i] && parseInt(uid, 10) !== 0);
topics[i].unreplied = parseInt(topics[i].postcount, 10) <= 1;
topics[i].pinned = parseInt(topics[i].pinned, 10) === 1;
topics[i].locked = parseInt(topics[i].locked, 10) === 1;
topics[i].deleted = parseInt(topics[i].deleted, 10) === 1;
topics[i].unread = !(results.hasRead[i] && parseInt(uid, 10) !== 0);
topics[i].unreplied = parseInt(topics[i].postcount, 10) <= 1;
}
}
topics = topics.filter(function(topic) {
return !topic.category.disabled &&
return topic && !topic.category.disabled &&
(!topic.deleted || (topic.deleted && isAdminOrMod[topic.cid]) ||
parseInt(topic.uid, 10) === parseInt(uid, 10));
});
@@ -272,9 +274,13 @@ var async = require('async'),
}
start = parseInt(start, 10);
for(var i=0; i<posts.length; ++i) {
posts[i].index = start + i;
if (posts[i]) {
posts[i].index = start + i;
}
}
if (posts[0]) {
posts[0].index = 0;
}
posts[0].index = 0;
Topics.addPostData(posts, uid, next);
});
});

View File

@@ -43,9 +43,13 @@ module.exports = function(Topics) {
Topics.addPostData = function(postData, uid, callback) {
var pids = postData.map(function(post) {
return post.pid;
return post && post.pid;
});
if (!Array.isArray(pids) || !pids.length) {
return callback(null, []);
}
async.parallel({
favourites: function(next) {
favourites.getFavouritesByPostIDs(pids, uid, next);
@@ -57,7 +61,7 @@ module.exports = function(Topics) {
var uids = [];
for(var i=0; i<postData.length; ++i) {
if (uids.indexOf(postData[i].uid) === -1) {
if (postData[i] && uids.indexOf(postData[i].uid) === -1) {
uids.push(postData[i].uid);
}
}
@@ -78,7 +82,7 @@ module.exports = function(Topics) {
editors: function(next) {
var editors = [];
for(var i=0; i<postData.length; ++i) {
if (postData[i].editor && editors.indexOf(postData[i].editor) === -1) {
if (postData[i] && postData[i].editor && editors.indexOf(postData[i].editor) === -1) {
editors.push(postData[i].editor);
}
}
@@ -90,7 +94,7 @@ module.exports = function(Topics) {
var editorData = {};
editors.forEach(function(editor) {
editorData[editor.uid] = editor;
})
});
next(null, editorData);
});
},
@@ -103,19 +107,21 @@ module.exports = function(Topics) {
}
for (var i = 0; i < postData.length; ++i) {
postData[i].deleted = parseInt(postData[i].deleted, 10) === 1;
postData[i].user = results.userData[postData[i].uid];
postData[i].editor = postData[i].editor ? results.editors[postData[i].editor] : null;
postData[i].favourited = results.favourites[i];
postData[i].upvoted = results.voteData.upvotes[i];
postData[i].downvoted = results.voteData.downvotes[i];
postData[i].votes = postData[i].votes || 0;
postData[i].display_moderator_tools = results.privileges[i].editable;
postData[i].display_move_tools = results.privileges[i].move && postData[i].index !== 0;
postData[i].selfPost = parseInt(uid, 10) === parseInt(postData[i].uid, 10);
if (postData[i]) {
postData[i].deleted = parseInt(postData[i].deleted, 10) === 1;
postData[i].user = results.userData[postData[i].uid];
postData[i].editor = postData[i].editor ? results.editors[postData[i].editor] : null;
postData[i].favourited = results.favourites[i];
postData[i].upvoted = results.voteData.upvotes[i];
postData[i].downvoted = results.voteData.downvotes[i];
postData[i].votes = postData[i].votes || 0;
postData[i].display_moderator_tools = results.privileges[i].editable;
postData[i].display_move_tools = results.privileges[i].move && postData[i].index !== 0;
postData[i].selfPost = parseInt(uid, 10) === parseInt(postData[i].uid, 10);
if(postData[i].deleted && !results.privileges[i].view_deleted) {
postData[i].content = '[[topic:post_is_deleted]]';
if(postData[i].deleted && !results.privileges[i].view_deleted) {
postData[i].content = '[[topic:post_is_deleted]]';
}
}
}
@@ -242,6 +248,9 @@ module.exports = function(Topics) {
Topics.getTopicDataByPid = function(pid, callback) {
posts.getPostField(pid, 'tid', function(err, tid) {
if (err) {
return callback(err);
}
Topics.getTopicData(tid, callback);
});
};