Merge pull request #5119 from novaugust/preview_link_subdir

Use absolute url for post preview link
This commit is contained in:
Hannah Wolfe 2015-04-09 10:21:30 +01:00
commit e0369d207f
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.inject('route', 'config', 'ghost:config');
application.inject('model:post', 'config', 'ghost:config');
application.inject('controller', 'config', 'ghost:config');
application.inject('component', 'config', 'ghost:config');
}

View File

@ -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 += '&nbsp;<a href="' + path + '">View ' + this.get('postOrPage') + '</a>';
message += `&nbsp;<a href="${path}">View ${type}</a>`;
}
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'}),
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,

View File

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