Skip to content

Commit

Permalink
Use new slug endpoint in ember admin
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jaswilli committed May 29, 2014
1 parent d3c1bdb commit 86a7e48
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/client/fixtures/init.js
Expand Up @@ -41,7 +41,7 @@ var defineFixtures = function (status) {
ic.ajax.defineFixture('/ghost/api/v0.1/posts/2', post(2, status));
ic.ajax.defineFixture('/ghost/api/v0.1/posts/3', post(3, status));
ic.ajax.defineFixture('/ghost/api/v0.1/posts/4', post(4, status));
ic.ajax.defineFixture('/ghost/api/v0.1/posts/slug/test%20title/', response('generated-slug', status));
ic.ajax.defineFixture('/ghost/api/v0.1/slugs/post/test%20title/', response('generated-slug', status));

ic.ajax.defineFixture('/ghost/api/v0.1/users/me/', user(status));
ic.ajax.defineFixture('/ghost/changepw/', response({
Expand Down
8 changes: 7 additions & 1 deletion core/client/models/post.js
Expand Up @@ -22,7 +22,13 @@ var Post = DS.Model.extend({

generateSlug: function () {
var title = this.get('title'),
url = this.get('ghostPaths').apiUrl('posts', 'slug', encodeURIComponent(title));
url;

if (!title) {
return;
}

url = this.get('ghostPaths').apiUrl('slugs', 'post', encodeURIComponent(title));

return ic.ajax.request(url, {
type: 'GET'
Expand Down

0 comments on commit 86a7e48

Please sign in to comment.