mirror of
https://github.com/vale981/Vulcan
synced 2025-03-09 20:16:39 -04:00
42 lines
945 B
JavaScript
42 lines
945 B
JavaScript
// push "search" template to primaryNav
|
|
primaryNav.push('search');
|
|
|
|
Searches = new Meteor.Collection("searches", {
|
|
schema: new SimpleSchema({
|
|
_id: {
|
|
type: String,
|
|
optional: true
|
|
},
|
|
timestamp: {
|
|
type: Date
|
|
},
|
|
keyword: {
|
|
type: String
|
|
}
|
|
})
|
|
});
|
|
|
|
Meteor.startup(function() {
|
|
Searches.allow({
|
|
update: isAdminById
|
|
, remove: isAdminById
|
|
});
|
|
});
|
|
|
|
// search post list parameters
|
|
viewParameters.search = function (terms, baseParameters) {
|
|
// if query is empty, just return parameters that will result in an empty collection
|
|
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;
|
|
}
|