mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-16 12:16:09 +03:00
45ccad58f9
closes #2422 - updated to use new change password method - have all save settings use notifications - create assetUrl helper for creating asset paths with subdir's properly prefixed - move all url based helpers onto a url object in ghost-paths
28 lines
683 B
JavaScript
28 lines
683 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.url').api('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;
|