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
This commit is contained in:
Matt Enlow 2015-04-08 15:29:26 -06:00
parent 4839b58ff0
commit b429baa02b
4 changed files with 11 additions and 3 deletions

View File

@ -8,6 +8,7 @@ var ConfigInitializer = {
application.register('ghost:config', config, {instantiate: false}); application.register('ghost:config', config, {instantiate: false});
application.inject('route', 'config', 'ghost:config'); application.inject('route', 'config', 'ghost:config');
application.inject('model:post', 'config', 'ghost:config');
application.inject('controller', 'config', 'ghost:config'); application.inject('controller', 'config', 'ghost:config');
application.inject('component', 'config', 'ghost:config'); application.inject('component', 'config', 'ghost:config');
} }

View File

@ -222,10 +222,11 @@ EditorControllerMixin = Ember.Mixin.create({
showSaveNotification: function (prevStatus, status, delay) { showSaveNotification: function (prevStatus, status, delay) {
var message = this.messageMap.success.post[prevStatus][status], 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') { if (status === 'published') {
message += '&nbsp;<a href="' + path + '">View ' + this.get('postOrPage') + '</a>'; message += `&nbsp;<a href="${path}">View ${type}</a>`;
} }
this.notifications.showSuccess(message.htmlSafe(), {delayed: delay}); this.notifications.showSuccess(message.htmlSafe(), {delayed: delay});
}, },

View File

@ -29,6 +29,12 @@ var Post = DS.Model.extend(NProgressSaveMixin, ValidationEngine, {
tags: DS.hasMany('tag', {embedded: 'always'}), tags: DS.hasMany('tag', {embedded: 'always'}),
url: DS.attr('string'), 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, scratch: null,
titleScratch: null, titleScratch: null,

View File

@ -7,7 +7,7 @@
<small class="post-published-by"> <small class="post-published-by">
<span class="status"> <span class="status">
{{#if isPublished}} {{#if isPublished}}
<a title="{{model.title}}" href="{{model.url}}">Published</a> <a title="{{model.title}}" href="{{model.absoluteUrl}}">Published</a>
{{else}} {{else}}
Written Written
{{/if}} {{/if}}