0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Changed default format from html to mobiledoc for Admin API v2

no issue

- Ghost-Admin needs mobiledoc only
- Ghost-Android needs mobiledoc only
- any other client can fetch other formats using the query param
This commit is contained in:
kirrg001 2019-02-25 10:44:19 +01:00 committed by Katharina Irrgang
parent f558b58c89
commit e65a82833c
5 changed files with 35 additions and 7 deletions

View file

@ -25,6 +25,14 @@ function setDefaultOrder(frame) {
} }
} }
function defaultFormat(frame) {
if (frame.options.formats) {
return;
}
frame.options.formats = 'mobiledoc';
}
/** /**
* CASE: * CASE:
* *
@ -62,6 +70,7 @@ module.exports = {
if (!localUtils.isContentAPI(frame)) { if (!localUtils.isContentAPI(frame)) {
forceStatusFilter(frame); forceStatusFilter(frame);
defaultFormat(frame);
} }
debug(frame.options); debug(frame.options);
@ -79,6 +88,7 @@ module.exports = {
if (!localUtils.isContentAPI(frame)) { if (!localUtils.isContentAPI(frame)) {
forceStatusFilter(frame); forceStatusFilter(frame);
defaultFormat(frame);
} }
debug(frame.options); debug(frame.options);
@ -122,6 +132,8 @@ module.exports = {
} }
}); });
} }
defaultFormat(frame);
}, },
edit(apiConfig, frame) { edit(apiConfig, frame) {
@ -138,5 +150,7 @@ module.exports = {
id: frame.options.id, id: frame.options.id,
page: true page: true
}; };
defaultFormat(frame);
} }
}; };

View file

@ -34,6 +34,14 @@ function setDefaultOrder(frame) {
} }
} }
function defaultFormat(frame) {
if (frame.options.formats) {
return;
}
frame.options.formats = 'mobiledoc';
}
/** /**
* CASE: * CASE:
* *
@ -84,6 +92,7 @@ module.exports = {
if (!localUtils.isContentAPI(frame)) { if (!localUtils.isContentAPI(frame)) {
forceStatusFilter(frame); forceStatusFilter(frame);
defaultFormat(frame);
} }
debug(frame.options); debug(frame.options);
@ -114,6 +123,7 @@ module.exports = {
if (!localUtils.isContentAPI(frame)) { if (!localUtils.isContentAPI(frame)) {
forceStatusFilter(frame); forceStatusFilter(frame);
defaultFormat(frame);
} }
debug(frame.options); debug(frame.options);
@ -157,6 +167,8 @@ module.exports = {
} }
}); });
} }
defaultFormat(frame);
}, },
edit(apiConfig, frame) { edit(apiConfig, frame) {
@ -171,5 +183,7 @@ module.exports = {
id: frame.options.id, id: frame.options.id,
page: false page: false
}; };
defaultFormat(frame);
} }
}; };

View file

@ -77,7 +77,7 @@ describe('Posts API', function () {
should.exist(jsonResponse.posts); should.exist(jsonResponse.posts);
localUtils.API.checkResponse(jsonResponse, 'posts'); localUtils.API.checkResponse(jsonResponse, 'posts');
jsonResponse.posts.should.have.length(3); jsonResponse.posts.should.have.length(3);
localUtils.API.checkResponse(jsonResponse.posts[0], 'post', ['mobiledoc', 'plaintext'], ['html', 'primary_tag', 'primary_author']); localUtils.API.checkResponse(jsonResponse.posts[0], 'post', ['mobiledoc', 'plaintext'], ['primary_tag', 'primary_author']);
localUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination'); localUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination');
_.isBoolean(jsonResponse.posts[0].featured).should.eql(true); _.isBoolean(jsonResponse.posts[0].featured).should.eql(true);

View file

@ -24,8 +24,8 @@ const expectedProperties = {
post: _(schema.posts) post: _(schema.posts)
.keys() .keys()
// by default we only return html // by default we only return mobildoc
.without('mobiledoc', 'plaintext') .without('html', 'plaintext')
.without('visibility') .without('visibility')
.without('locale') .without('locale')
.without('page') .without('page')
@ -35,8 +35,8 @@ const expectedProperties = {
page: _(schema.posts) page: _(schema.posts)
.keys() .keys()
// by default we only return html // by default we only return mobildoc
.without('mobiledoc', 'plaintext') .without('html', 'plaintext')
.without('visibility') .without('visibility')
.without('locale') .without('locale')
.without('page') .without('page')

View file

@ -20,8 +20,8 @@ const expectedProperties = {
post: _(schema.posts) post: _(schema.posts)
.keys() .keys()
// by default we only return html // by default we only return mobiledoc
.without('mobiledoc', 'plaintext') .without('html', 'plaintext')
.without('visibility') .without('visibility')
.without('locale') .without('locale')
.without('page') .without('page')