Vulcan/packages/telescope-search/lib/client/routes.js
Charlie DeTar 981700c5c7 Fix telescope-search route for iron:router 1.0
The ``onBeforeAction`` in ``PostsSearchController`` isn't calling ``this.next()``, and so is never dispatching.
2014-11-24 16:43:41 -07:00

45 lines
916 B
JavaScript

adminNav.push({
route: 'searchLogs',
label: 'Search Logs'
});
Meteor.startup(function () {
PostsSearchController = PostsListController.extend({
view: 'search',
onBeforeAction: function() {
if ("q" in this.params) {
Session.set("searchQuery", this.params.q);
}
this.next();
}
});
Router.onBeforeAction(Router._filters.isAdmin, {only: ['logs']});
// Search
Router.route('/search/:limit?', {
name: 'search',
controller: PostsSearchController
});
// Search Logs
Router.route('/logs/:limit?', {
name: 'searchLogs',
waitOn: function () {
var limit = this.params.limit || 100;
if(Meteor.isClient) {
Session.set('logsLimit', limit);
}
return Meteor.subscribe('searches', limit);
},
data: function () {
return Searches.find({}, {sort: {timestamp: -1}});
},
fastRender: true
});
});