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

v1.18.x
Julian Lam 11 years ago
commit 7de540dc74

@ -9,9 +9,6 @@
<a href="../../topic/{topics.slug}">{topics.title} ({topics.postcount})</a> <a href="../../topic/{topics.slug}">{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_userpicture}" />
<p>
{topics.teaser_text}
</p>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
</li> </li>

@ -124,9 +124,8 @@
}); });
} }
module.search = function(key, term, callback) { module.search = function(key, term, limit, callback) {
db.command({text:"search" , search: term, filter: {key:key}, limit: limit }, function(err, result) {
db.command({text:"search" , search: term, filter: {key:key} }, function(err, result) {
if(err) { if(err) {
return callback(err); return callback(err);
} }

@ -97,10 +97,12 @@
} }
} }
module.search = function(key, term, callback) { module.search = function(key, term, limit, callback) {
function search(searchObj, callback) { function search(searchObj, callback) {
searchObj searchObj
.query(term).type('or') .query(term)
.between(0, limit - 1)
.type('or')
.end(callback); .end(callback);
} }

@ -251,17 +251,14 @@ var path = require('path'),
}); });
app.get('/search/:term', function (req, res, next) { app.get('/search/:term', function (req, res, next) {
var limit = 50;
function searchPosts(callback) { function searchPosts(callback) {
db.search('post', req.params.term, function(err, pids) { db.search('post', req.params.term, limit, function(err, pids) {
if (err) { if (err) {
return callback(err, null); return callback(err, null);
} }
if(pids.length > 50) {
pids = pids.splice(0, 50);
}
posts.getPostSummaryByPids(pids, false, function (err, posts) { posts.getPostSummaryByPids(pids, false, function (err, posts) {
if (err){ if (err){
return callback(err, null); return callback(err, null);
@ -272,15 +269,11 @@ var path = require('path'),
} }
function searchTopics(callback) { function searchTopics(callback) {
db.search('topic', req.params.term, function(err, tids) { db.search('topic', req.params.term, limit, function(err, tids) {
if (err) { if (err) {
return callback(err, null); return callback(err, null);
} }
if(tids.length > 50) {
tids = tids.splice(0, 50);
}
topics.getTopicsByTids(tids, 0, function (topics) { topics.getTopicsByTids(tids, 0, function (topics) {
callback(null, topics); callback(null, topics);
}, 0); }, 0);
@ -290,7 +283,7 @@ var path = require('path'),
if ((req.user && req.user.uid) || meta.config.allowGuestSearching === '1') { if ((req.user && req.user.uid) || meta.config.allowGuestSearching === '1') {
async.parallel([searchPosts, searchTopics], function (err, results) { async.parallel([searchPosts, searchTopics], function (err, results) {
if (err) { if (err) {
return next(); return next(err);
} }
return res.json({ return res.json({

@ -28,6 +28,7 @@ var users = {},
io; io;
Sockets.init = function() { Sockets.init = function() {
io = socketioWildcard(SocketIO).listen(global.server, { io = socketioWildcard(SocketIO).listen(global.server, {
log: false, log: false,
transports: ['websocket', 'xhr-polling', 'jsonp-polling', 'flashsocket'], transports: ['websocket', 'xhr-polling', 'jsonp-polling', 'flashsocket'],

@ -709,7 +709,6 @@ var async = require('async'),
topicData.categoryName = topicInfo.categoryData.name; topicData.categoryName = topicInfo.categoryData.name;
topicData.categorySlug = topicInfo.categoryData.slug; topicData.categorySlug = topicInfo.categoryData.slug;
topicData.badgeclass = (topicInfo.hasread && parseInt(current_user, 10) !== 0) ? '' : 'badge-important'; topicData.badgeclass = (topicInfo.hasread && parseInt(current_user, 10) !== 0) ? '' : 'badge-important';
topicData.teaser_text = topicInfo.teaserInfo.text || '',
topicData.teaser_username = topicInfo.teaserInfo.username || ''; topicData.teaser_username = topicInfo.teaserInfo.username || '';
topicData.teaser_userslug = topicInfo.teaserInfo.userslug || ''; topicData.teaser_userslug = topicInfo.teaserInfo.userslug || '';
topicData.teaser_userpicture = topicInfo.teaserInfo.picture || gravatar.url('', {}, https = nconf.get('https')); topicData.teaser_userpicture = topicInfo.teaserInfo.picture || gravatar.url('', {}, https = nconf.get('https'));
@ -830,7 +829,6 @@ var async = require('async'),
topicData['lock-icon'] = parseInt(topicData.locked, 10) === 1 ? 'fa-lock' : 'none'; topicData['lock-icon'] = parseInt(topicData.locked, 10) === 1 ? 'fa-lock' : 'none';
topicData.badgeclass = hasRead ? '' : 'badge-important'; topicData.badgeclass = hasRead ? '' : 'badge-important';
topicData.teaser_text = teaser.text || '';
topicData.teaser_username = teaser.username || ''; topicData.teaser_username = teaser.username || '';
topicData.teaser_userslug = teaser.userslug || ''; topicData.teaser_userslug = teaser.userslug || '';
topicData.userslug = teaser.userslug || ''; topicData.userslug = teaser.userslug || '';

@ -493,11 +493,12 @@ var bcrypt = require('bcrypt'),
return callback([]); return callback([]);
} }
db.search('user', username, function(err, uids) { db.search('user', username, 50, function(err, uids) {
if (err) { if (err) {
console.log(err); console.log(err);
return; return;
} }
if (uids && uids.length) { if (uids && uids.length) {
User.getDataForUsers(uids, function(userdata) { User.getDataForUsers(uids, function(userdata) {
callback(userdata); callback(userdata);

Loading…
Cancel
Save