mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-13 14:39:52 +03:00
b58573ded5
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`
41 lines
1.4 KiB
JavaScript
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;
|