mirror of
https://github.com/TryGhost/Ghost-Admin.git
synced 2023-12-14 02:33:04 +01:00
7cecbe301f
closes #3401 - modifying slug-generator to be more generic - adding slugging capabilities for /settings/users/:slug - modified posts to use the updated slug-generator
28 lines
717 B
JavaScript
28 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;
|