2014-06-23 11:05:06 +09:00
|
|
|
Meteor.startup(function () {
|
|
|
|
|
2014-08-28 11:10:31 +09:00
|
|
|
PostsSearchController = PostsListController.extend({
|
2014-10-03 15:48:32 -06:00
|
|
|
view: 'search',
|
2015-03-25 12:30:55 +09:00
|
|
|
showViewsNav: false,
|
2015-03-24 16:13:47 -06:00
|
|
|
getTitle: function() {
|
|
|
|
return i18n.t("Search") + ' - ' + getSetting('title', "Telescope");
|
|
|
|
},
|
|
|
|
getDescription: function() {
|
|
|
|
return getSetting('description');
|
|
|
|
},
|
2014-10-03 15:48:32 -06:00
|
|
|
onBeforeAction: function() {
|
2014-11-28 17:26:06 -08:00
|
|
|
var query = this.params.query;
|
|
|
|
if ('q' in query) {
|
2015-03-19 20:49:35 -05:00
|
|
|
// if search box has 'empty' class, that means user just deleted last character in search keyword
|
|
|
|
// but router hasn't updated url, so params.query still has '?q=<LAST CHARACTER>'
|
|
|
|
// if we set searchQuery in this case, user will see last character pops up again unexpectedly
|
|
|
|
// so add this check to fix the bug. issue #825
|
|
|
|
if (!$('.search').hasClass('empty')) {
|
|
|
|
Session.set('searchQuery', query.q);
|
|
|
|
}
|
2014-11-28 17:26:06 -08:00
|
|
|
if (query.q) {
|
|
|
|
Meteor.call('logSearch', query.q)
|
|
|
|
}
|
2014-10-03 15:48:32 -06:00
|
|
|
}
|
2014-11-24 16:43:41 -07:00
|
|
|
this.next();
|
2014-10-03 15:48:32 -06:00
|
|
|
}
|
2014-08-28 11:10:31 +09:00
|
|
|
});
|
|
|
|
|
2014-06-23 11:05:06 +09:00
|
|
|
Router.onBeforeAction(Router._filters.isAdmin, {only: ['logs']});
|
|
|
|
|
2014-11-17 14:53:42 +09:00
|
|
|
// Search
|
2014-06-23 11:05:06 +09:00
|
|
|
|
2014-11-17 14:53:42 +09:00
|
|
|
Router.route('/search/:limit?', {
|
|
|
|
name: 'search',
|
2014-11-28 17:26:06 -08:00
|
|
|
controller: PostsSearchController
|
2014-11-17 14:53:42 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
// Search Logs
|
|
|
|
|
|
|
|
Router.route('/logs/:limit?', {
|
2015-03-23 10:32:56 +09:00
|
|
|
controller: AdminController,
|
2014-11-17 14:53:42 +09:00
|
|
|
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
|
2014-06-23 11:05:06 +09:00
|
|
|
});
|
|
|
|
|
2014-10-03 15:48:32 -06:00
|
|
|
});
|