Created
July 6, 2013 16:53
-
-
Save stephendeyoung/5940490 to your computer and use it in GitHub Desktop.
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
App = Ember.Application.create({}); | |
var attr = Ember.attr; | |
App.Post = Ember.Model.extend({ | |
id: attr('number'), | |
title: attr('string'), | |
author: attr('string'), | |
intro: attr('string'), | |
extended: attr('string'), | |
publishedAt: attr('date') | |
}); | |
App.Post.url = '/posts'; | |
App.Post.adapter = Ember.RESTAdapter.create(); | |
App.Router.map(function() { | |
this.resource('about'); | |
this.resource('posts', function() { | |
this.resource('post', { path: ':id' }); | |
}); | |
}); | |
App.PostsRoute = Ember.Route.extend({ | |
model: function() { | |
return App.Post.find(); | |
} | |
}); | |
App.PostRoute = Ember.Route.extend({ | |
setupController: function(controller, id) { | |
console.log(id) | |
controller.set('model', App.Post.find(id)); | |
} | |
}) | |
App.PostController = Ember.ObjectController.extend({ | |
isEditing: false, | |
edit: function() { | |
this.set('isEditing', true); | |
}, | |
doneEditing: function() { | |
this.set('isEditing', false); | |
this.get('store').commit(); | |
} | |
}); | |
var showdown = new Showdown.converter(); | |
Ember.Handlebars.registerBoundHelper('markdown', function(input) { | |
return new Handlebars.SafeString(showdown.makeHtml(input)); | |
}); | |
Ember.Handlebars.registerBoundHelper('date', function(date) { | |
return moment(date).fromNow(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment