Merge branch 'master' into private-groups
commit
1868a02bd7
@ -1,4 +1,5 @@
|
||||
{
|
||||
"results_matching": "%1 result(s) matching \"%2\", (%3 seconds)",
|
||||
"no-matches": "No posts found"
|
||||
}
|
||||
"no-matches": "No matches found",
|
||||
"in": "In"
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var searchController = {},
|
||||
validator = require('validator'),
|
||||
plugins = require('../plugins'),
|
||||
search = require('../search'),
|
||||
helpers = require('./helpers');
|
||||
|
||||
|
||||
searchController.search = function(req, res, next) {
|
||||
if (!plugins.hasListeners('filter:search.query')) {
|
||||
return helpers.notFound(req, res);
|
||||
}
|
||||
|
||||
if (!req.params.term) {
|
||||
return res.render('search', {
|
||||
time: 0,
|
||||
search_query: '',
|
||||
posts: [],
|
||||
topics: [],
|
||||
users: [],
|
||||
tags: []
|
||||
});
|
||||
}
|
||||
|
||||
var uid = req.user ? req.user.uid : 0;
|
||||
|
||||
req.params.term = validator.escape(req.params.term);
|
||||
|
||||
search.search(req.params.term, req.query.in, uid, function(err, results) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
res.render('search', results);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
module.exports = searchController;
|
Loading…
Reference in New Issue