Created
April 8, 2013 16:57
-
-
Save edipofederle/5338424 to your computer and use it in GitHub Desktop.
This file contains hidden or 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(); | |
| App.Store = DS.Store.extend({ | |
| revision: 12, | |
| adapter: 'App.MyCustomAdapter' | |
| }); | |
| App.MyCustomAdapter = DS.RESTAdapter.extend({ | |
| bulkCommit: false, | |
| url: "http://localhost:3000", | |
| buildURL: function(record, suffix) { | |
| var s = this._super(record, suffix); | |
| return s + ".json"; | |
| } | |
| }) | |
| App.Router.map( function() { | |
| this.resource('posts', function(){ | |
| this.resource('post', {path: ':post_id'}) | |
| }); | |
| this.resource('about'); | |
| }); | |
| App.IndexRoute = Ember.Route.extend({ | |
| redirect: function(){ | |
| this.transitionTo('posts'); | |
| } | |
| }); | |
| App.PostsRoute = Ember.Route.extend({ | |
| model: function(){ | |
| return App.Post.find(); | |
| } | |
| }) | |
| App.PostController = Ember.ObjectController.extend({ | |
| isEditing: false, | |
| doneEditing: function(){ | |
| this.set('isEditing', false); | |
| }, | |
| edit: function(){ | |
| this.set('isEditing', true); | |
| } | |
| }); | |
| App.Post = DS.Model.extend({ | |
| title: DS.attr('string'), | |
| body: DS.attr('text'), | |
| }); | |
| // App.Post.FIXTURES = [{ | |
| // id: 1, | |
| // title: "Dev in PF", | |
| // author: "Edipo L Federle", | |
| // publishedAt: new Date('12-27-2013'), | |
| // intro: "Alguma coisa", | |
| // extended: "Uma monte de coisas aqui" | |
| // }, { | |
| // id: 2, | |
| // title: "Hello Ember.js", | |
| // author: "Edipo L Federle", | |
| // publishedAt: new Date('12-05-2013'), | |
| // intro: "Alguma coisa", | |
| // extended: "Uma monte de coisas **Teste** aqui" | |
| // }] | |
| //Format date, with moment.js | |
| Ember.Handlebars.registerBoundHelper('date', function(date){ | |
| return moment(date).fromNow(); | |
| }); | |
| //Markdown format | |
| var showdown = new Showdown.converter(); | |
| Ember.Handlebars.registerBoundHelper('markdown', function(input){ | |
| return new Ember.Handlebars.SafeString(showdown.makeHtml(input)) | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment