2016-05-24 15:06:59 +03:00
|
|
|
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
2014-11-25 23:56:08 +03:00
|
|
|
|
2018-01-17 16:27:37 +03:00
|
|
|
export default AuthenticatedRoute.extend({
|
2019-03-07 20:31:03 +03:00
|
|
|
model(params, transition) {
|
|
|
|
let {type: modelName} = params;
|
|
|
|
|
|
|
|
if (!['post','page'].includes(modelName)) {
|
|
|
|
let path = transition.intent.url.replace(/^\//, '');
|
|
|
|
return this.replaceWith('error404', {path, status: 404});
|
|
|
|
}
|
|
|
|
|
2018-01-05 18:38:23 +03:00
|
|
|
return this.get('session.user').then(user => (
|
2019-03-07 20:31:03 +03:00
|
|
|
this.store.createRecord(modelName, {authors: [user]})
|
2018-01-05 18:38:23 +03:00
|
|
|
));
|
2014-06-06 05:18:03 +04:00
|
|
|
},
|
|
|
|
|
2018-01-17 16:27:37 +03:00
|
|
|
// there's no specific controller for this route, instead all editor
|
|
|
|
// handling is done on the editor route/controler
|
|
|
|
setupController(controller, newPost) {
|
|
|
|
let editor = this.controllerFor('editor');
|
|
|
|
editor.setPost(newPost);
|
2014-03-10 07:44:08 +04:00
|
|
|
}
|
|
|
|
});
|