diff --git a/ghost/admin/controllers/editor.js b/ghost/admin/controllers/editor.js deleted file mode 100644 index 9d952ae634..0000000000 --- a/ghost/admin/controllers/editor.js +++ /dev/null @@ -1,5 +0,0 @@ -import EditorControllerMixin from 'ghost/mixins/editor-base-controller'; - -var EditorController = Ember.ObjectController.extend(EditorControllerMixin); - -export default EditorController; diff --git a/ghost/admin/controllers/editor/edit.js b/ghost/admin/controllers/editor/edit.js new file mode 100644 index 0000000000..49d36f4a03 --- /dev/null +++ b/ghost/admin/controllers/editor/edit.js @@ -0,0 +1,5 @@ +import EditorControllerMixin from 'ghost/mixins/editor-base-controller'; + +var EditorEditController = Ember.ObjectController.extend(EditorControllerMixin); + +export default EditorEditController; diff --git a/ghost/admin/controllers/editor/new.js b/ghost/admin/controllers/editor/new.js new file mode 100644 index 0000000000..0c5d6a07ca --- /dev/null +++ b/ghost/admin/controllers/editor/new.js @@ -0,0 +1,5 @@ +import EditorControllerMixin from 'ghost/mixins/editor-base-controller'; + +var EditorNewController = Ember.ObjectController.extend(EditorControllerMixin); + +export default EditorNewController; diff --git a/ghost/admin/controllers/new.js b/ghost/admin/controllers/new.js deleted file mode 100644 index 9d952ae634..0000000000 --- a/ghost/admin/controllers/new.js +++ /dev/null @@ -1,5 +0,0 @@ -import EditorControllerMixin from 'ghost/mixins/editor-base-controller'; - -var EditorController = Ember.ObjectController.extend(EditorControllerMixin); - -export default EditorController; diff --git a/ghost/admin/router.js b/ghost/admin/router.js index 6df1c926de..b1fae37578 100644 --- a/ghost/admin/router.js +++ b/ghost/admin/router.js @@ -17,8 +17,10 @@ Router.map(function () { this.resource('posts', { path: '/' }, function () { this.route('post', { path: ':post_id' }); }); - this.resource('editor', { path: '/editor/:post_id' }); - this.route('new', { path: '/editor' }); + this.resource('editor', function () { + this.route('new', { path: '' }); + this.route('edit', { path: ':post_id' }); + }); this.resource('settings', function () { this.route('general'); this.route('user'); diff --git a/ghost/admin/routes/editor.js b/ghost/admin/routes/editor/edit.js similarity index 73% rename from ghost/admin/routes/editor.js rename to ghost/admin/routes/editor/edit.js index 9fec599d82..86d5a0ad5b 100644 --- a/ghost/admin/routes/editor.js +++ b/ghost/admin/routes/editor/edit.js @@ -1,14 +1,13 @@ import styleBody from 'ghost/mixins/style-body'; import AuthenticatedRoute from 'ghost/routes/authenticated'; -var EditorRoute = AuthenticatedRoute.extend(styleBody, { +var EditorEditRoute = AuthenticatedRoute.extend(styleBody, { classNames: ['editor'], model: function (params) { var self = this, post, postId; - postId = Number(params.post_id); if (!Number.isInteger(postId) || !Number.isFinite(postId) || postId <= 0) { @@ -22,7 +21,8 @@ var EditorRoute = AuthenticatedRoute.extend(styleBody, { } return this.store.filter('post', { status: 'all', staticPages: 'all' }, function (post) { - return post.get('id') === postId; + //post.get('id') returns a string, so compare with params.post_id + return post.get('id') === params.post_id; }).then(function (records) { var post = records.get('firstObject'); @@ -32,7 +32,10 @@ var EditorRoute = AuthenticatedRoute.extend(styleBody, { return self.transitionTo('posts.index'); }); + }, + serialize: function (model) { + return {post_id: model.get('id')}; } }); -export default EditorRoute; +export default EditorEditRoute; diff --git a/ghost/admin/routes/editor/index.js b/ghost/admin/routes/editor/index.js new file mode 100644 index 0000000000..20f0e766f2 --- /dev/null +++ b/ghost/admin/routes/editor/index.js @@ -0,0 +1,7 @@ +var EditorRoute = Ember.Route.extend({ + beforeModel: function () { + this.transitionTo('editor.new'); + } +}); + +export default EditorRoute; diff --git a/ghost/admin/routes/new.js b/ghost/admin/routes/editor/new.js similarity index 74% rename from ghost/admin/routes/new.js rename to ghost/admin/routes/editor/new.js index 04bba4e6aa..921bf4ddf5 100644 --- a/ghost/admin/routes/new.js +++ b/ghost/admin/routes/editor/new.js @@ -1,7 +1,7 @@ import AuthenticatedRoute from 'ghost/routes/authenticated'; import styleBody from 'ghost/mixins/style-body'; -var NewRoute = AuthenticatedRoute.extend(styleBody, { +var EditorNewRoute = AuthenticatedRoute.extend(styleBody, { classNames: ['editor'], model: function () { @@ -11,4 +11,4 @@ var NewRoute = AuthenticatedRoute.extend(styleBody, { } }); -export default NewRoute; +export default EditorNewRoute; diff --git a/ghost/admin/templates/-floating-header.hbs b/ghost/admin/templates/-floating-header.hbs index 3198096f58..9b558be23d 100644 --- a/ghost/admin/templates/-floating-header.hbs +++ b/ghost/admin/templates/-floating-header.hbs @@ -11,7 +11,7 @@ {{#if author.name}}{{author.name}}{{else}}{{author.email}}{{/if}}
- {{#link-to "editor" this class="post-edit" title="Edit Post"}} + {{#link-to "editor.edit" this class="post-edit" title="Edit Post"}} {{/link-to}} {{#gh-popover-button popoverName="post-settings-menu" tagName="a" classNames="post-settings" title="Post Settings"}} diff --git a/ghost/admin/templates/-navbar.hbs b/ghost/admin/templates/-navbar.hbs index b296926537..cf71a6e008 100644 --- a/ghost/admin/templates/-navbar.hbs +++ b/ghost/admin/templates/-navbar.hbs @@ -5,7 +5,7 @@