diff --git a/public/templates/noscript/category.tpl b/public/templates/noscript/category.tpl index d36f621aed..d88fd17c95 100644 --- a/public/templates/noscript/category.tpl +++ b/public/templates/noscript/category.tpl @@ -9,9 +9,6 @@ {topics.title} ({topics.postcount})
-

- {topics.teaser_text} -

diff --git a/src/database/mongo.js b/src/database/mongo.js index 83e6eb8dec..9890604cf2 100644 --- a/src/database/mongo.js +++ b/src/database/mongo.js @@ -124,9 +124,8 @@ }); } - module.search = function(key, term, callback) { - - db.command({text:"search" , search: term, filter: {key:key} }, function(err, result) { + module.search = function(key, term, limit, callback) { + db.command({text:"search" , search: term, filter: {key:key}, limit: limit }, function(err, result) { if(err) { return callback(err); } diff --git a/src/database/redis.js b/src/database/redis.js index 7490f6c87c..8a5578e439 100644 --- a/src/database/redis.js +++ b/src/database/redis.js @@ -97,10 +97,12 @@ } } - module.search = function(key, term, callback) { + module.search = function(key, term, limit, callback) { function search(searchObj, callback) { searchObj - .query(term).type('or') + .query(term) + .between(0, limit - 1) + .type('or') .end(callback); } diff --git a/src/routes/api.js b/src/routes/api.js index 2bfd66a8de..d0da395d54 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -251,17 +251,14 @@ var path = require('path'), }); app.get('/search/:term', function (req, res, next) { + var limit = 50; function searchPosts(callback) { - db.search('post', req.params.term, function(err, pids) { + db.search('post', req.params.term, limit, function(err, pids) { if (err) { 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); @@ -272,15 +269,11 @@ var path = require('path'), } function searchTopics(callback) { - db.search('topic', req.params.term, function(err, tids) { + db.search('topic', req.params.term, limit, function(err, tids) { if (err) { return callback(err, null); } - if(tids.length > 50) { - tids = tids.splice(0, 50); - } - topics.getTopicsByTids(tids, 0, function (topics) { callback(null, topics); }, 0); @@ -290,7 +283,7 @@ var path = require('path'), if ((req.user && req.user.uid) || meta.config.allowGuestSearching === '1') { async.parallel([searchPosts, searchTopics], function (err, results) { if (err) { - return next(); + return next(err); } return res.json({ diff --git a/src/socket.io/index.js b/src/socket.io/index.js index e17c3acd34..c4e8085232 100644 --- a/src/socket.io/index.js +++ b/src/socket.io/index.js @@ -28,6 +28,7 @@ var users = {}, io; Sockets.init = function() { + io = socketioWildcard(SocketIO).listen(global.server, { log: false, transports: ['websocket', 'xhr-polling', 'jsonp-polling', 'flashsocket'], diff --git a/src/topics.js b/src/topics.js index 7f76f181ac..f2e245d72a 100644 --- a/src/topics.js +++ b/src/topics.js @@ -709,7 +709,6 @@ var async = require('async'), topicData.categoryName = topicInfo.categoryData.name; topicData.categorySlug = topicInfo.categoryData.slug; 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_userslug = topicInfo.teaserInfo.userslug || ''; 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.badgeclass = hasRead ? '' : 'badge-important'; - topicData.teaser_text = teaser.text || ''; topicData.teaser_username = teaser.username || ''; topicData.teaser_userslug = teaser.userslug || ''; topicData.userslug = teaser.userslug || ''; diff --git a/src/user.js b/src/user.js index 96e8244eb0..91c901c5a6 100644 --- a/src/user.js +++ b/src/user.js @@ -493,11 +493,12 @@ var bcrypt = require('bcrypt'), return callback([]); } - db.search('user', username, function(err, uids) { + db.search('user', username, 50, function(err, uids) { if (err) { console.log(err); return; } + if (uids && uids.length) { User.getDataForUsers(uids, function(userdata) { callback(userdata);