2014-06-04 22:18:23 -05:00
|
|
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
2014-06-13 14:35:22 -05:00
|
|
|
|
2014-06-30 07:58:10 -05:00
|
|
|
var PostsIndexRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin, loadingIndicator, {
|
2014-06-25 09:39:57 -05:00
|
|
|
// redirect to first post subroute unless no posts exist
|
2014-06-17 14:17:08 -05:00
|
|
|
beforeModel: function () {
|
|
|
|
var self = this;
|
2014-03-02 09:30:35 -05:00
|
|
|
|
2014-06-17 14:17:08 -05:00
|
|
|
return this.store.find('post', {
|
|
|
|
status: 'all',
|
2014-06-26 21:35:25 -05:00
|
|
|
staticPages: 'all',
|
2014-06-17 14:17:08 -05:00
|
|
|
}).then(function (records) {
|
|
|
|
var post = records.get('firstObject');
|
2014-06-25 09:39:57 -05:00
|
|
|
|
|
|
|
if (post) {
|
|
|
|
return self.transitionTo('posts.post', post);
|
|
|
|
}
|
2014-06-17 14:17:08 -05:00
|
|
|
});
|
2014-03-02 09:30:35 -05:00
|
|
|
}
|
2014-03-03 15:18:10 -05:00
|
|
|
});
|
|
|
|
|
2014-06-13 14:35:22 -05:00
|
|
|
export default PostsIndexRoute;
|