mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 03:14:03 +03:00
Add post preview via uuid (/p/:uuid)
Refs #5097 - All drafts will show a preview link (this needs real css) - Published posts will redirect - prev/next post helpers only activate on published posts - Powered by ~10 pints between the two of us (@ErisDS, @novaugust)
This commit is contained in:
parent
e4616f6840
commit
e50a1157fa
@ -35,6 +35,17 @@ var Post = DS.Model.extend(NProgressSaveMixin, ValidationEngine, {
|
||||
return this.get('ghostPaths.url').join(blogUrl, postUrl);
|
||||
}),
|
||||
|
||||
previewUrl: Ember.computed('uuid', 'ghostPaths.url', 'config.blogUrl', 'config.routeKeywords.preview', function () {
|
||||
var blogUrl = this.get('config.blogUrl'),
|
||||
uuid = this.get('uuid'),
|
||||
previewKeyword = this.get('config.routeKeywords.preview');
|
||||
// New posts don't have a preview
|
||||
if (!uuid) {
|
||||
return '';
|
||||
}
|
||||
return this.get('ghostPaths.url').join(blogUrl, previewKeyword, uuid);
|
||||
}),
|
||||
|
||||
scratch: null,
|
||||
titleScratch: null,
|
||||
|
||||
|
@ -692,6 +692,13 @@ body.zen {
|
||||
}
|
||||
}//.post-settings-menu
|
||||
|
||||
.post-preview-link {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
font-size: 1.3rem;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Post Settings Menu meta Data
|
||||
|
@ -11,6 +11,11 @@
|
||||
<form>
|
||||
<div class="form-group">
|
||||
<label for="url">Post URL</label>
|
||||
{{#if model.isDraft}}
|
||||
<a class="post-preview-link" target="_blank" href="{{model.previewUrl}}">
|
||||
Preview<span class="icon-external"></span>
|
||||
</a>
|
||||
{{/if}}
|
||||
<span class="input-icon icon-link">
|
||||
{{gh-input class="post-setting-slug" id="url" value=slugValue name="post-setting-slug" focus-out="updateSlug" selectOnClick="true" stopEnterKeyDownPropagation="true"}}
|
||||
</span>
|
||||
|
@ -11,6 +11,8 @@ var isNumeric = function (num) {
|
||||
return false;
|
||||
} else if (isNumeric(val)) {
|
||||
return +val;
|
||||
} else if (val.indexOf('{') === 0) {
|
||||
return JSON.parse(val);
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user