Ghost/ghost/admin/models/post.js
Matt Enlow b58573ded5 Refactored PostSettingsMenuController
Closes #2845.
Ref #1351.
- Refactored `PostSettingsMenuController` to appropriately set and display
  slug and publish date and their placeholders.
- Removed api spam on title change by putting `slugPlaceholder` generation
  inside of an `Ember.run.debounce` call.
- Renamed `gh-blur-text-field` to `gh-blur-input`
- Created `SlugGenerator` class to abstract slug generation.
- Added `timestampVerification` function to `utils/date-formatting`
- `utils/date-formatting` now uses `strict` parsing of dates
- Added more acceptable date formats to accommodate strict parsing
- Moved `isDraft` and `isPublished` computed properties from
  `EditorController` to `PostModel`
2014-06-13 12:14:58 -06:00

41 lines
1.4 KiB
JavaScript

var Post = DS.Model.extend({
uuid: DS.attr('string'),
title: DS.attr('string'),
slug: DS.attr('string'),
markdown: DS.attr('string', {defaultValue: ''}),
html: DS.attr('string'),
image: DS.attr('string'),
featured: DS.attr('boolean', {defaultValue: false}),
page: DS.attr('boolean', {defaultValue: false}),
status: DS.attr('string', {defaultValue: 'draft'}),
language: DS.attr('string', {defaultValue: 'en_US'}),
meta_title: DS.attr('string'),
meta_description: DS.attr('string'),
author: DS.belongsTo('user', { async: true }),
created_at: DS.attr('moment-date'),
created_by: DS.belongsTo('user', { async: true }),
updated_at: DS.attr('moment-date'),
updated_by: DS.belongsTo('user', { async: true }),
published_at: DS.attr('moment-date'),
published_by: DS.belongsTo('user', { async: true }),
tags: DS.hasMany('tag', { async: true }),
//## Computed post properties
isPublished: Ember.computed.equal('status', 'published'),
isDraft: Ember.computed.equal('status', 'draft'),
validate: function () {
var validationErrors = [];
if (!this.get('title.length')) {
validationErrors.push({
message: 'You must specify a title for the post.'
});
}
return validationErrors;
}.property('title')
});
export default Post;