mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Merge pull request #2972 from halfdan/2748-featured-post
Implement featured post / page
This commit is contained in:
commit
f11a81067a
3 changed files with 24 additions and 3 deletions
|
@ -1,11 +1,19 @@
|
|||
var PostController = Ember.ObjectController.extend({
|
||||
isPublished: Ember.computed.equal('status', 'published'),
|
||||
classNameBindings: ['featured'],
|
||||
|
||||
actions: {
|
||||
toggleFeatured: function () {
|
||||
this.set('featured', !this.get('featured'));
|
||||
var featured = !this.get('featured'),
|
||||
self = this;
|
||||
|
||||
this.get('model').save();
|
||||
this.set('featured', featured);
|
||||
|
||||
this.get('model').save().then(function () {
|
||||
self.notifications.showSuccess('Post successfully marked as ' + (featured ? 'featured' : 'not featured') + '.');
|
||||
}, function () {
|
||||
self.notifications.showError('An error occured while saving the post.');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
{{#view "content-list-content-view" tagName="section"}}
|
||||
<ol class="posts-list">
|
||||
{{#each itemController="posts/post" itemView="post-item-view" itemTagName="li"}}
|
||||
{{!-- @TODO: Restore functionality where 'featured' and 'page' classes are added for proper posts --}}
|
||||
{{#link-to "posts.post" this class="permalink" title="Edit this post"}}
|
||||
<h3 class="entry-title">{{title}}</h3>
|
||||
<section class="entry-meta">
|
||||
|
|
|
@ -1,6 +1,20 @@
|
|||
import itemView from 'ghost/views/item-view';
|
||||
|
||||
var PostItemView = itemView.extend({
|
||||
classNameBindings: ['isFeatured', 'isPage'],
|
||||
|
||||
isFeatured: function () {
|
||||
if (this.get('controller.model.featured')) {
|
||||
return 'featured';
|
||||
}
|
||||
}.property('controller.model.featured'),
|
||||
|
||||
isPage: function () {
|
||||
if (this.get('controller.model.page')) {
|
||||
return 'page';
|
||||
}
|
||||
}.property('controller.model.page'),
|
||||
|
||||
openEditor: function () {
|
||||
this.get('controller').send('openEditor', this.get('controller.model')); // send action to handle transition to editor route
|
||||
}.on('doubleClick')
|
||||
|
|
Loading…
Add table
Reference in a new issue