mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-02 08:13:34 +03:00
832340e4c8
Closes #2831 -use new slug endpoint in fixture -use new slug endpoint in post model -do not try to generate slug for zero length titles
51 lines
1.4 KiB
JavaScript
51 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'),
|
|
html: DS.attr('string'),
|
|
image: DS.attr('string'),
|
|
featured: DS.attr('boolean'),
|
|
page: DS.attr('boolean'),
|
|
status: DS.attr('string'),
|
|
language: DS.attr('string'),
|
|
meta_title: DS.attr('string'),
|
|
meta_description: DS.attr('string'),
|
|
author: DS.belongsTo('user', { async: true }),
|
|
created_at: DS.attr('date'),
|
|
created_by: DS.belongsTo('user', { async: true }),
|
|
updated_at: DS.attr('date'),
|
|
updated_by: DS.belongsTo('user', { async: true }),
|
|
published_at: DS.attr('date'),
|
|
published_by: DS.belongsTo('user', { async: true }),
|
|
tags: DS.hasMany('tag', { async: true }),
|
|
|
|
generateSlug: function () {
|
|
var title = this.get('title'),
|
|
url;
|
|
|
|
if (!title) {
|
|
return;
|
|
}
|
|
|
|
url = this.get('ghostPaths').apiUrl('slugs', 'post', encodeURIComponent(title));
|
|
|
|
return ic.ajax.request(url, {
|
|
type: 'GET'
|
|
});
|
|
},
|
|
|
|
validationErrors: 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; |