kiwilan / php-opds

PHP package to create OPDS feed (Open Publication Distribution System) for eBooks.
https://packagist.org/packages/kiwilan/php-opds
MIT License
6 stars 2 forks source link

Paging information for pre-paginated feeds #40

Closed mikespub closed 8 months ago

mikespub commented 10 months ago

This gives a basic example of how paging information could be added for pre-paginated feeds

Practical use-case is discussed in issue #38 where feeds are already pre-paginated by the application, and the paging information is prepared up-front (total, page, first link, last link, ...).

See for example https://github.com/mikespub-org/seblucas-cops/blob/main/lib/Output/KiwilanOPDS.php#L216

        $url = $request->getCurrentUrl(static::$endpoint);
        if ($page->isPaginated()) {
            // ... prepare $first, $last, ... links
            $opds = Opds::make($this->getOpdsConfig())
            ->title($title)
            ->url($url)
            ->feeds($feeds)
            ->paging(page: $page->n, total: $page->totalNumber, first: $first, last: $last, previous: $previous, next: $next)
            ->get();
        } else {
            // ...
        }
        return $opds->getResponse();

Note: it's not meant to be complete with tests etc., and it completely by-passes/ignores the current paginator. Use as inspiration or stepping stone for your own further development :-)

codecov[bot] commented 10 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (2de093d) 99.56% compared to head (dbc1f05) 99.58%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #40 +/- ## ============================================= + Coverage 99.56% 99.58% +0.02% - Complexity 259 270 +11 ============================================= Files 10 10 Lines 915 967 +52 ============================================= + Hits 911 963 +52 Misses 4 4 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

ewilan-riviere commented 9 months ago

Thanks for this PR!

I have some work this week, I will try to merge this soon.