Add metadata to paginated pages

Include 'total', 'page' and 'per_page' properties on result listings to
make it easier to navigate through the paginated pages.
Add next/prev links and has_more flag to pagination metadata

Adds next_url/prev_url properties to the API output if there are more
pages of results. I've also added a has_more boolean flag which
indicates if there are more pages of results, although this can be
detected by the absence of a next_url property, it seems nicer to have
it in here explicitly.
Make search pagination metadata consistent with listings

Refactors the code from the previous commit so it can be used by both
the listing pages as well as the search results.

I've added a currentUrl middleware which makes it easier generate links
to previous/next pages.