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:
*
@ -62,6 +70,7 @@ module.exports = {
if (!localUtils.isContentAPI(frame)) {
forceStatusFilter(frame);
defaultFormat(frame);
}
debug(frame.options);
@ -79,6 +88,7 @@ module.exports = {
if (!localUtils.isContentAPI(frame)) {
forceStatusFilter(frame);
defaultFormat(frame);
}
debug(frame.options);
@ -122,6 +132,8 @@ module.exports = {
}
});
}
defaultFormat(frame);
},
edit(apiConfig, frame) {
@ -138,5 +150,7 @@ module.exports = {
id: frame.options.id,
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:
*
@ -84,6 +92,7 @@ module.exports = {
if (!localUtils.isContentAPI(frame)) {
forceStatusFilter(frame);
defaultFormat(frame);
}
debug(frame.options);
@ -114,6 +123,7 @@ module.exports = {
if (!localUtils.isContentAPI(frame)) {
forceStatusFilter(frame);
defaultFormat(frame);
}
debug(frame.options);
@ -157,6 +167,8 @@ module.exports = {
}
});
}
defaultFormat(frame);
},
edit(apiConfig, frame) {
@ -171,5 +183,7 @@ module.exports = {
id: frame.options.id,
page: false
};
defaultFormat(frame);
}
};

View file

@ -77,7 +77,7 @@ describe('Posts API', function () {
should.exist(jsonResponse.posts);
localUtils.API.checkResponse(jsonResponse, 'posts');
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');
_.isBoolean(jsonResponse.posts[0].featured).should.eql(true);

View file

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

View file

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