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:
Matt Enlow 2015-04-16 13:40:32 -06:00
parent e4616f6840
commit e50a1157fa
4 changed files with 25 additions and 0 deletions

View File

@ -35,6 +35,17 @@ var Post = DS.Model.extend(NProgressSaveMixin, ValidationEngine, {
return this.get('ghostPaths.url').join(blogUrl, postUrl); 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, scratch: null,
titleScratch: null, titleScratch: null,

View File

@ -692,6 +692,13 @@ body.zen {
} }
}//.post-settings-menu }//.post-settings-menu
.post-preview-link {
position: absolute;
top: 0;
right: 0;
font-size: 1.3rem;
}
// //
// Post Settings Menu meta Data // Post Settings Menu meta Data

View File

@ -11,6 +11,11 @@
<form> <form>
<div class="form-group"> <div class="form-group">
<label for="url">Post URL</label> <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"> <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"}} {{gh-input class="post-setting-slug" id="url" value=slugValue name="post-setting-slug" focus-out="updateSlug" selectOnClick="true" stopEnterKeyDownPropagation="true"}}
</span> </span>

View File

@ -11,6 +11,8 @@ var isNumeric = function (num) {
return false; return false;
} else if (isNumeric(val)) { } else if (isNumeric(val)) {
return +val; return +val;
} else if (val.indexOf('{') === 0) {
return JSON.parse(val);
} else { } else {
return val; return val;
} }