mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 19:52:01 +03:00
489cd08d97
closes #3401 - modifying slug-generator to be more generic - adding slugging capabilities for /settings/users/:slug - modified posts to use the updated slug-generator
29 lines
717 B
JavaScript
29 lines
717 B
JavaScript
var SlugGenerator = Ember.Object.extend({
|
|
ghostPaths: null,
|
|
slugType: 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', this.get('slugType'), 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;
|