2014-08-15 11:51:30 +09:00
|
|
|
// push "search" template to primaryNav
|
2014-12-30 17:44:33 +09:00
|
|
|
primaryNav.push({
|
|
|
|
template: 'search',
|
|
|
|
order: 100
|
|
|
|
});
|
2014-06-23 11:40:21 +09:00
|
|
|
|
2014-12-15 09:46:51 +09:00
|
|
|
adminNav.push({
|
|
|
|
route: 'searchLogs',
|
|
|
|
label: 'search_logs',
|
|
|
|
description: 'see_what_people_are_searching_for'
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2014-06-22 10:55:31 +09:00
|
|
|
Searches = new Meteor.Collection("searches", {
|
|
|
|
schema: new SimpleSchema({
|
|
|
|
_id: {
|
|
|
|
type: String,
|
|
|
|
optional: true
|
|
|
|
},
|
|
|
|
timestamp: {
|
|
|
|
type: Date
|
|
|
|
},
|
|
|
|
keyword: {
|
|
|
|
type: String
|
|
|
|
}
|
|
|
|
})
|
|
|
|
});
|
2013-11-22 14:20:47 +09:00
|
|
|
|
2014-10-03 16:21:06 -06:00
|
|
|
Meteor.startup(function() {
|
|
|
|
Searches.allow({
|
|
|
|
update: isAdminById
|
|
|
|
, remove: isAdminById
|
|
|
|
});
|
2013-11-22 14:20:47 +09:00
|
|
|
});
|
|
|
|
|
2014-06-23 12:08:01 +09:00
|
|
|
// search post list parameters
|
2014-06-23 12:28:40 +09:00
|
|
|
viewParameters.search = function (terms, baseParameters) {
|
|
|
|
// if query is empty, just return parameters that will result in an empty collection
|
2014-11-28 17:26:06 -08:00
|
|
|
if(typeof terms.query === 'undefined' || !terms.query)
|
2014-06-23 12:28:40 +09:00
|
|
|
return {find:{_id: 0}}
|
2014-06-23 12:08:01 +09:00
|
|
|
|
2014-06-23 12:28:40 +09:00
|
|
|
var parameters = deepExtend(true, baseParameters, {
|
|
|
|
find: {
|
|
|
|
$or: [
|
|
|
|
{title: {$regex: terms.query, $options: 'i'}},
|
|
|
|
{url: {$regex: terms.query, $options: 'i'}},
|
|
|
|
{body: {$regex: terms.query, $options: 'i'}}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return parameters;
|
2014-10-03 16:21:06 -06:00
|
|
|
}
|