This repository has been archived by the owner on Sep 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://github.com/broerse/ember-cli-blog notice if running Ember.js 1.13.4, need build ember.js yourself due to issue below. emberjs/ember.js#11742
- Loading branch information
Showing
32 changed files
with
434 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Component.extend({ | ||
actions: { | ||
edit: function() { | ||
this.set('isEditing', true); | ||
}, | ||
|
||
doneEditing: function() { | ||
this.set('isEditing', false); | ||
this.sendAction('saveAction'); | ||
}, | ||
|
||
deleteAuthor: function() { | ||
this.sendAction('deleteAction'); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Component.extend({ | ||
actions: { | ||
saveAction: function() { | ||
this.sendAction('saveAction'); | ||
}, | ||
deleteAction: function() { | ||
this.sendAction('deleteAction'); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Component.extend({ | ||
authorlist: function() { | ||
var selected = this.get('post.author'); // author from post model | ||
var content = []; | ||
if (selected !== null) { | ||
content.push(selected); | ||
} | ||
|
||
this.get('authors').forEach(function(listAuthorObj) { | ||
var listName = listAuthorObj.get('name'); | ||
if (selected !== listName) { | ||
content.push(listName); | ||
} | ||
}); | ||
|
||
return content.sort(); | ||
}.property("post.author", "authors"), | ||
|
||
|
||
actions: { | ||
edit: function() { | ||
this.set('isEditing', true); | ||
}, | ||
|
||
doneEditing: function() { | ||
this.set('isEditing', false); | ||
this.sendAction('saveAction'); | ||
}, | ||
|
||
deletePost: function() { | ||
this.sendAction('deleteAction'); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Component.extend({ | ||
actions: { | ||
saveAction: function() { | ||
this.sendAction('saveAction'); | ||
}, | ||
deleteAction: function() { | ||
this.sendAction('deleteAction'); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Ember from "ember"; | ||
|
||
export default Ember.Controller.extend({ | ||
isEditing: false | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import Ember from "ember"; | ||
import pagedArray from 'ember-cli-pagination/computed/paged-array'; | ||
|
||
export default Ember.Controller.extend({ | ||
page: 1, | ||
perPage: 5, | ||
|
||
pagedContent: pagedArray("arrangedContent", {pageBinding: "page", perPageBinding: "perPage"}), | ||
|
||
queryParams: ["page", "perPage"], | ||
|
||
totalPagesBinding: "pagedContent.totalPages", | ||
|
||
arrangedContent: function() { | ||
return Ember.ArrayProxy.extend(Ember.SortableMixin).create({ | ||
sortProperties: ['name'], | ||
sortAscending: true, | ||
sortFunction: function(v, w) { | ||
var lowerV = v.toLowerCase(); | ||
var lowerW = w.toLowerCase(); | ||
|
||
if (lowerV < lowerW) { | ||
return -1; | ||
} | ||
if (lowerV > lowerW) { | ||
return 1; | ||
} | ||
return 0; | ||
}, | ||
content: this.get('model') | ||
}); | ||
}.property('model') | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Ember from "ember"; | ||
import pagedArray from 'ember-cli-pagination/computed/paged-array'; | ||
import computedFilterByQuery from 'ember-cli-filter-by-query/util/filter'; | ||
|
||
export default Ember.Controller.extend({ | ||
page: 1, | ||
perPage: 5, | ||
|
||
pagedContent: pagedArray("filteredContent", {pageBinding: "page", perPageBinding: "perPage"}), | ||
|
||
queryParams: ["page", "perPage", "query"], | ||
|
||
totalPagesBinding: "pagedContent.totalPages", | ||
|
||
arrangedContent: function() { | ||
return Ember.ArrayProxy.extend(Ember.SortableMixin).create({ | ||
sortProperties: ['date'], | ||
sortAscending: false, | ||
content: this.get('model') | ||
}); | ||
}.property('model'), | ||
|
||
filteredContent: function() { | ||
return computedFilterByQuery( | ||
this.get('arrangedContent'), | ||
['title', 'body', 'author', 'excerpt'], | ||
this.get('query'), | ||
{ conjunction: 'and', sort: false} | ||
); | ||
}.property('arrangedContent.@each.title', 'arrangedContent.@each.author', 'query') | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import DS from "ember-data"; | ||
|
||
var Author = DS.Model.extend({ | ||
name: DS.attr('string', {defaultValue: ""}) | ||
}); | ||
|
||
export default Author; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import DS from "ember-data"; | ||
|
||
var Post = DS.Model.extend({ | ||
title: DS.attr('string'), | ||
author: DS.attr('string'), | ||
title: DS.attr('string', {defaultValue: ""}), | ||
author: DS.attr('string', {defaultValue: ""}), | ||
date: DS.attr('date'), | ||
excerpt: DS.attr('string'), | ||
body: DS.attr('string') | ||
excerpt: DS.attr('string', {defaultValue: ""}), | ||
body: DS.attr('string', {defaultValue: ""}) | ||
}); | ||
|
||
export default Post; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Ember from "ember"; | ||
|
||
export default Ember.Route.extend({ | ||
model: function(params) { | ||
return this.store.find('author', params.author_id); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Ember from "ember"; | ||
|
||
export default Ember.Route.extend({ | ||
model: function() { | ||
return this.store.findAll('author'); | ||
}, | ||
|
||
actions: { | ||
createAuthor: function() { | ||
this.controllerFor('author').set('isEditing', true); | ||
var newauthor = this.store.createRecord('author'); | ||
this.transitionTo('author', newauthor.save()); | ||
}, | ||
|
||
saveAuthor: function() { | ||
this.modelFor('author').save(); | ||
}, | ||
|
||
deleteAuthor: function() { | ||
this.modelFor('author').destroyRecord().then(function() { | ||
this.transitionTo('authors'); | ||
}.bind(this)); | ||
} | ||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,35 @@ | ||
import Ember from "ember"; | ||
|
||
export default Ember.Route.extend({ | ||
model: function() { | ||
return this.store.find('post'); | ||
} | ||
}); | ||
model: function() { | ||
var store = this.store; | ||
return Ember.RSVP.hash({ | ||
content: store.findAll('post'), | ||
authors: store.findAll('author') | ||
}); | ||
}, | ||
|
||
setupController: function(controller, models) { | ||
controller.setProperties(models); | ||
}, | ||
|
||
actions: { | ||
createPost: function() { | ||
this.controllerFor('post').set('isEditing', true); | ||
var newPost = this.store.createRecord('post'); | ||
newPost.set('date' , new Date()); | ||
newPost.set('author' , 'C.L.I. Ember'); | ||
this.transitionTo('post', newPost.save()); | ||
}, | ||
|
||
savePost: function() { | ||
this.modelFor('post').save(); | ||
}, | ||
|
||
deletePost: function() { | ||
this.modelFor('post').destroyRecord().then(function() { | ||
this.transitionTo('posts'); | ||
}.bind(this)); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{blog-author author=model isEditing=isEditing saveAction="saveAuthor" deleteAction="deleteAuthor"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<div class="container-fluid"> | ||
<div class="row"> | ||
<!-- author listing --> | ||
<div class="col-xs-5"> | ||
<button {{action 'createAuthor'}}>Create</button> | ||
<table class='table'> | ||
<thead> | ||
<tr><th>Authors</th></tr> | ||
</thead> | ||
<tbody> | ||
{{#each pagedContent as |author|}} | ||
<tr><td> | ||
{{#link-to 'author' author}} | ||
• {{author.name}} | ||
{{/link-to}} | ||
</td></tr> | ||
{{/each}} | ||
</tbody> | ||
</table> | ||
{{page-numbers content=pagedContent}} | ||
</div> | ||
|
||
<!-- author content --> | ||
<div class="col-xs-7"> | ||
{{outlet}} | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p class="text-warning">Please select an author</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{{#if isEditing}} | ||
<p><button {{action 'doneEditing'}}>Done</button></p> | ||
<p>{{input type="text" value=author.name placeholder="Author name" class="form-control"}}</p> | ||
|
||
<p><button {{action 'deleteAuthor'}}>Delete</button></p> | ||
{{else}} | ||
<p><button {{action 'edit'}}>Edit</button></p> | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{{blog-author-edit author=author isEditing=isEditing saveAction="saveAction" deleteAction="deleteAction"}} | ||
|
||
<h1>{{author.name}}</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{{#if isEditing}} | ||
<p><button {{action 'doneEditing'}}>Done</button></p> | ||
<p>{{input type="text" value=post.title class="form-control"}}</p> | ||
<p>{{ember-selectize content=authorlist selection=post.author}}</p> | ||
<p>{{input type="text" value=post.excerpt class="form-control"}}</p> | ||
<p>{{textarea value=post.body class="form-control"}}</p> | ||
|
||
<p><button {{action 'deletePost' class="btn btn-default"}}>Delete</button></p> | ||
{{else}} | ||
<p><button {{action 'edit'}}>Edit</button></p> | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{{blog-post-edit post=post authors=authors isEditing=isEditing saveAction="saveAction" deleteAction="deleteAction"}} | ||
|
||
<h1>{{post.title}}</h1> | ||
<h2>by {{post.author}} <small class='muted'>({{format-date post.date}})</small></h2> | ||
|
||
<hr> | ||
|
||
<div class='intro'> | ||
{{format-markdown post.excerpt}} | ||
</div> | ||
|
||
<div class='below-the-fold'> | ||
{{format-markdown post.body}} | ||
</div> |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.