Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post API: pagination -> meta #2604

Closed
ErisDS opened this issue Apr 17, 2014 · 0 comments · Fixed by #2617
Closed

Post API: pagination -> meta #2604

ErisDS opened this issue Apr 17, 2014 · 0 comments · Fixed by #2617
Assignees
Labels
affects:api Affects the Ghost API
Milestone

Comments

@ErisDS
Copy link
Member

ErisDS commented Apr 17, 2014

This issue is a result of the API format discussion in #2362, and is part of a larger project to move our API towards the JSON-API format which is documented in the Epic: #2124. This is one step in the journey towards achieving the Post JSON object format laid out in #2347.


Currently, all of our pagination data is included as top-level items on a response:

{
    posts: [{...}, {...}],
    page: 1,
    limit: 15,
    pages: 2,
    total: 33
}

As part of our move towards JSON-API, these items should all be included in a meta object:

{
    posts: [{...}, {...}],
    meta: {
        pagination: {
            page: 1,
            limit: 15,
            pages: 2,
            total: 33
        }
    }
}

There are some additional complexities to this issue, in order to ensure that this response remains consistent throughout the Ghost application and to reduce / remove the need for the post-processing which currently exists in controllers/frontend.js.

The final pagination object expected by themes looks like:

pagination: {
    page: #, // The current page number
    prev: #, // The previous page number, not present if there is no previous page
    next: #, // The next page number, not present if there is no next page
    limit: #, // The number of items per page
    total: #, // The total number of items available in the complete set
    pages: # // The total number of pages available in the complete set
}

All of these properties, some of which are computed, are provided to the theme because themes can't do the math.

These items need to be returned by the API instead of calculated afterwards, so that all apps, themes and internal requests get the same data.

The meta.pagination object can then be passed directly to the theme. For the time being it should be passed as its old name pagination.

@ErisDS ErisDS added this to the 0.4 API milestone Apr 17, 2014
sebgie added a commit to sebgie/Ghost that referenced this issue Apr 19, 2014
closes TryGhost#2604
- moved ‚pagination‘ to ‚meta‘ property
- added response test for pagination property
- changed ‚next‘ and ‚prev‘ to be set to null and exist on every
response
- removed unnecessary call to API for RSS author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects:api Affects the Ghost API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants