Vulcan/packages/telescope-search/lib/search.js

59 lines
1.2 KiB
JavaScript
Raw Normal View History

// push "search" template to primaryNav
primaryNav.push({
template: 'search',
order: 100
});
2014-06-23 11:40:21 +09:00
2015-03-24 17:03:37 +09:00
mobileNav.push({
template: 'search',
order: 1
});
adminMenu.push({
route: 'searchLogs',
label: 'search_logs',
description: 'see_what_people_are_searching_for'
});
2015-03-25 12:02:29 +09:00
registerElementColor('.search-field', 'secondaryContrastColor');
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
Meteor.startup(function() {
Searches.allow({
update: isAdminById
, remove: isAdminById
});
2013-11-22 14:20:47 +09:00
});
// search post list parameters
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)
return {find:{_id: 0}}
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;
}