0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-13 22:41:32 -05:00
ghost/core/admin/assets/js/models/post.js
Tim Griesser e5ce70e175 Added models & collections for various pieces
Saving post as draft, or publishing
Added HBS parser for some client tmpls
Parsing paginated posts
Added grunt watch for hbs parsing on updates
2013-06-03 00:56:57 -04:00

41 lines
No EOL
1.1 KiB
JavaScript

/*global window, document, Ghost, $, Backbone, _ */
(function () {
"use strict";
Ghost.Models.Post = Backbone.Model.extend({
defaults: {
status: 'draft'
},
parse: function (resp) {
if (resp.tags) {
// TODO: parse tags into it's own collection on the model (this.tags)
return resp;
}
return resp;
},
validate: function (attrs) {
if (_.isEmpty(attrs.title)) {
return 'You must specify a title for the post.';
}
}
});
Ghost.Collections.Posts = Backbone.Collection.extend({
url: Ghost.settings.apiRoot + '/posts',
model: Ghost.Models.Post,
parse: function (resp) {
if (_.isArray(resp.posts)) {
this.limit = resp.limit;
this.currentPage = resp.page;
this.totalPages = resp.pages;
this.totalPosts = resp.total;
return resp.posts;
}
return resp;
}
});
}());