From b429baa02bb4aecd5135ac59263f44473918a098 Mon Sep 17 00:00:00 2001 From: Matt Enlow Date: Wed, 8 Apr 2015 15:29:26 -0600 Subject: [PATCH] Use absolute url for post preview link Closes #5116 - adds new CP `absoluteUrl` to PostModel - use `absoluteUrl` in the two places we link previews - swap out some code for es6 loveliness --- core/client/app/initializers/ghost-config.js | 1 + core/client/app/mixins/editor-base-controller.js | 5 +++-- core/client/app/models/post.js | 6 ++++++ core/client/app/templates/posts/post.hbs | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/core/client/app/initializers/ghost-config.js b/core/client/app/initializers/ghost-config.js index 244f14fe7a..a9fc300a1f 100644 --- a/core/client/app/initializers/ghost-config.js +++ b/core/client/app/initializers/ghost-config.js @@ -8,6 +8,7 @@ var ConfigInitializer = { application.register('ghost:config', config, {instantiate: false}); application.inject('route', 'config', 'ghost:config'); + application.inject('model:post', 'config', 'ghost:config'); application.inject('controller', 'config', 'ghost:config'); application.inject('component', 'config', 'ghost:config'); } diff --git a/core/client/app/mixins/editor-base-controller.js b/core/client/app/mixins/editor-base-controller.js index 84279c91cd..8585b6075e 100644 --- a/core/client/app/mixins/editor-base-controller.js +++ b/core/client/app/mixins/editor-base-controller.js @@ -222,10 +222,11 @@ EditorControllerMixin = Ember.Mixin.create({ showSaveNotification: function (prevStatus, status, delay) { var message = this.messageMap.success.post[prevStatus][status], - path = this.get('ghostPaths.url').join(this.get('config.blogUrl'), this.get('model.url')); + path = this.get('model.absoluteUrl'), + type = this.get('postOrPage'); if (status === 'published') { - message += ' View ' + this.get('postOrPage') + ''; + message += ` View ${type}`; } this.notifications.showSuccess(message.htmlSafe(), {delayed: delay}); }, diff --git a/core/client/app/models/post.js b/core/client/app/models/post.js index cfb08cecfd..d1f9ef5b53 100644 --- a/core/client/app/models/post.js +++ b/core/client/app/models/post.js @@ -29,6 +29,12 @@ var Post = DS.Model.extend(NProgressSaveMixin, ValidationEngine, { tags: DS.hasMany('tag', {embedded: 'always'}), url: DS.attr('string'), + absoluteUrl: Ember.computed('url', 'ghostPaths.url', 'config.blogUrl', function () { + var blogUrl = this.get('config.blogUrl'), + postUrl = this.get('url'); + return this.get('ghostPaths.url').join(blogUrl, postUrl); + }), + scratch: null, titleScratch: null, diff --git a/core/client/app/templates/posts/post.hbs b/core/client/app/templates/posts/post.hbs index 8a097e5ded..d9222dd8ab 100644 --- a/core/client/app/templates/posts/post.hbs +++ b/core/client/app/templates/posts/post.hbs @@ -7,7 +7,7 @@ {{#if isPublished}} - Published + Published {{else}} Written {{/if}}