mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Merge pull request #4629 from cobbspur/postpreview
Add view post link on published and updated posts
This commit is contained in:
commit
7946926c93
3 changed files with 28 additions and 7 deletions
|
@ -182,8 +182,12 @@ EditorControllerMixin = Ember.Mixin.create(MarkerManager, {
|
||||||
},
|
},
|
||||||
|
|
||||||
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('url'));
|
||||||
|
|
||||||
|
if (status === 'published') {
|
||||||
|
message += ' <a href="' + path + '">View Post</a>';
|
||||||
|
}
|
||||||
this.notifications.showSuccess(message, {delayed: delay});
|
this.notifications.showSuccess(message, {delayed: delay});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ var Post = DS.Model.extend(NProgressSaveMixin, ValidationEngine, {
|
||||||
published_at: DS.attr('moment-date'),
|
published_at: DS.attr('moment-date'),
|
||||||
published_by: DS.belongsTo('user', {async: true}),
|
published_by: DS.belongsTo('user', {async: true}),
|
||||||
tags: DS.hasMany('tag', {embedded: 'always'}),
|
tags: DS.hasMany('tag', {embedded: 'always'}),
|
||||||
|
url: DS.attr('string'),
|
||||||
|
|
||||||
// Computed post properties
|
// Computed post properties
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,18 @@
|
||||||
var makeRoute = function (root, args) {
|
var makeRoute = function (root, args) {
|
||||||
var parts = Array.prototype.slice.call(args, 0).join('/'),
|
var slashAtStart,
|
||||||
route = [root, parts].join('/');
|
slashAtEnd,
|
||||||
|
parts,
|
||||||
|
route;
|
||||||
|
|
||||||
if (route.slice(-1) !== '/') {
|
slashAtStart = /^\//;
|
||||||
route += '/';
|
slashAtEnd = /\/$/;
|
||||||
}
|
route = root.replace(slashAtEnd, '');
|
||||||
|
parts = Array.prototype.slice.call(args, 0);
|
||||||
|
|
||||||
return route;
|
parts.forEach(function (part) {
|
||||||
|
route = [route, part.replace(slashAtStart, '').replace(slashAtEnd, '')].join('/');
|
||||||
|
});
|
||||||
|
return route += '/';
|
||||||
};
|
};
|
||||||
|
|
||||||
function ghostPaths() {
|
function ghostPaths() {
|
||||||
|
@ -34,6 +40,16 @@ function ghostPaths() {
|
||||||
return makeRoute(apiRoot, arguments);
|
return makeRoute(apiRoot, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
join: function () {
|
||||||
|
if (arguments.length > 1) {
|
||||||
|
return makeRoute(arguments[0], Array.prototype.slice.call(arguments, 1));
|
||||||
|
} else if (arguments.length === 1) {
|
||||||
|
var arg = arguments[0];
|
||||||
|
return arg.slice(-1) === '/' ? arg : arg + '/';
|
||||||
|
}
|
||||||
|
return '/';
|
||||||
|
},
|
||||||
|
|
||||||
asset: assetUrl
|
asset: assetUrl
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue