mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 11:22:19 +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`
28 lines
682 B
JavaScript
28 lines
682 B
JavaScript
var SlugGenerator = Ember.Object.extend({
|
|
ghostPaths: null,
|
|
value: null,
|
|
toString: function () {
|
|
return this.get('value');
|
|
},
|
|
generateSlug: function (textToSlugify) {
|
|
var self = this,
|
|
url;
|
|
|
|
if (!textToSlugify) {
|
|
return Ember.RSVP.resolve('');
|
|
}
|
|
|
|
url = this.get('ghostPaths').apiUrl('slugs', 'post', encodeURIComponent(textToSlugify));
|
|
|
|
return ic.ajax.request(url, {
|
|
type: 'GET'
|
|
}).then(function (response) {
|
|
var slug = response.slugs[0].slug;
|
|
self.set('value', slug);
|
|
return slug;
|
|
});
|
|
}
|
|
});
|
|
|
|
export default SlugGenerator;
|