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