2015-09-17 14:51:14 +09:00
|
|
|
Posts.getRoute = function () {
|
|
|
|
FlowRouter.watchPathChange()
|
2015-10-07 13:16:40 +09:00
|
|
|
var viewName = this.name;
|
2015-09-17 14:51:14 +09:00
|
|
|
var currentQuery = _.clone(FlowRouter.current().queryParams);
|
|
|
|
var newQuery = _.extend(currentQuery, {view: viewName});
|
|
|
|
return FlowRouter.path("postsDefault", FlowRouter.current().params, newQuery);
|
|
|
|
};
|
|
|
|
|
2015-04-24 10:49:24 +09:00
|
|
|
// array containing items in the views menu
|
2015-10-07 15:04:22 +09:00
|
|
|
var viewsMenuItems = [
|
2015-04-24 10:49:24 +09:00
|
|
|
{
|
2015-09-17 14:51:14 +09:00
|
|
|
route: Posts.getRoute,
|
2015-10-07 13:16:40 +09:00
|
|
|
name: 'top',
|
2015-04-24 10:49:24 +09:00
|
|
|
description: 'most_popular_posts'
|
|
|
|
},
|
|
|
|
{
|
2015-09-17 14:51:14 +09:00
|
|
|
route: Posts.getRoute,
|
2015-10-07 13:16:40 +09:00
|
|
|
name: 'new',
|
2015-04-24 10:49:24 +09:00
|
|
|
description: 'newest_posts'
|
|
|
|
},
|
|
|
|
{
|
2015-09-17 14:51:14 +09:00
|
|
|
route: Posts.getRoute,
|
2015-10-07 13:16:40 +09:00
|
|
|
name: 'best',
|
2015-04-24 10:49:24 +09:00
|
|
|
description: 'highest_ranked_posts_ever'
|
|
|
|
},
|
|
|
|
{
|
2015-09-17 14:51:14 +09:00
|
|
|
route: Posts.getRoute,
|
2015-10-07 13:16:40 +09:00
|
|
|
name: 'pending',
|
2015-04-24 10:49:24 +09:00
|
|
|
description: 'posts_awaiting_moderation',
|
|
|
|
adminOnly: true
|
|
|
|
},
|
2015-09-06 11:37:48 +09:00
|
|
|
{
|
2015-09-17 14:51:14 +09:00
|
|
|
route: Posts.getRoute,
|
2015-10-07 13:16:40 +09:00
|
|
|
name: 'rejected',
|
2015-09-06 11:37:48 +09:00
|
|
|
description: 'rejected_posts',
|
|
|
|
adminOnly: true
|
|
|
|
},
|
2015-04-24 10:49:24 +09:00
|
|
|
{
|
2015-09-17 14:51:14 +09:00
|
|
|
route: Posts.getRoute,
|
2015-10-07 13:16:40 +09:00
|
|
|
name: 'scheduled',
|
2015-04-24 10:49:24 +09:00
|
|
|
description: 'future_scheduled_posts',
|
|
|
|
adminOnly: true
|
|
|
|
},
|
2015-10-07 15:04:22 +09:00
|
|
|
];
|
|
|
|
|
|
|
|
// add label & description i18n functions
|
|
|
|
viewsMenuItems = viewsMenuItems.map(function (item) {
|
|
|
|
item.label = _.partial(i18n.t, item.name);
|
|
|
|
item.description = _.partial(i18n.t, item.description);
|
|
|
|
return item;
|
|
|
|
});
|
|
|
|
|
|
|
|
Telescope.menuItems.add("viewsMenu", viewsMenuItems);
|