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

1.0.0-alpha.1 #18

Closed ewilan-riviere closed 1 year ago

ewilan-riviere commented 1 year ago

This version rework completely the library, it's not compatible with previous version. Now you can use OPDS 2.0 with partial support.

BREAKING CHANGES

Opds::class

$opds = Opds::make();

$debug = $opds->get(); // `Opds::class` instance with response

return $opds->response(); // `never` because send response
use Kiwilan\Opds\Opds;
use Kiwilan\Opds\OpdsVersionEnum;

$entries = [];

$opds = Opds::make(new OpdsConfig()) // Accept `OpdsConfig::class`
  ->title('My search') // To set feed title
  ->isSearch() // To set feed as search
  ->url('https://example.com/search') // Only for testing, URL is automatically generated
  ->feeds($entries); // Accept `OpdsEntryBook[]`, `OpdsEntryNavigation[]`, `OpdsEntryNavigation` or `OpdsEntryBook`

return $opds->get();

Misc

Added

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage is 44.93% of modified lines.

Files Changed Coverage
src/OpdsConfig.php 0.00%
src/Engine/OpdsJsonEngine.php 31.57%
src/Engine/OpdsXmlEngine.php 33.33%
src/Opds.php 60.00%
src/OpdsResponse.php 80.00%
src/Engine/OpdsEngine.php 96.66%
src/Entries/OpdsEntryBook.php 100.00%

:loudspeaker: Thoughts on this report? Let us know!.

ewilan-riviere commented 1 year ago

@mikespub Do you want to beta-test 1.0.0 with partial JSON support?

mikespub commented 1 year ago

I can give it a go in my kiwilan branch but what do you mean by "partial support"? If it doesn't generate a complete OPDS 2.0 feed yet, then I'm afraid it won't be very helpful at this point...

With the pre-1.0 version I simply rewrote the OPDS renderer to make use of Kiwilan\Opds to render the XML output based on the entries passed by $page: lib/Output/KiwilanOPDS.php

And the new entrypoint opds.php was a straight copy of the existing feed.php, calling $OPDSRender->render($page, $request) and echo-ing the response.

That worked out nicely to generate the same OPDS 1.2 output as the existing renderer, so I was hoping I could use a similar approach when switching to OPDS 2.0 output: use a library that already generates OPDS 2.0-compliant output for different collections and feeds as defined in the specs, and then see how best to map/adapt the COPS page structure to generate meaningful COPS feeds.

Right now 1.0.0-alpha.1 still seems to be missing some of the building blocks, or maybe I missed something?

One last point for future versions: for a re-usable package, it would be easier if we could get back the output as a result so we can handle the response ourselves afterwards, rather than let OPDSResponse->get() handle it.

Thanks

ewilan-riviere commented 1 year ago

This version don't support facets, groups and pagination.

Pagination will be first feature planned. For metadata, this version partially support with just basics entries, for metadata into belongsTo entry, just series supported for now.

One last point for future versions: for a re-usable package, it would be easier if we could get back the output as a result so we can handle the response ourselves afterwards, rather than let OPDSResponse->get() handle it.

I update Opds::class, now you can use get() method to get full instance with generated response into getResponse(). Method response() is available to send response to browser.

If you want to test OPDS 2.0 only when is full ready, I will send you a notification when all is done.

mikespub commented 1 year ago

Thanks Ewilan, I would indeed prefer to wait for a more complete version before testing - sorry about that.

I've spent quite some time dragging the COPS code base from PHP 5.x to PHP 8.x, and adding OPDS 2.0 would be nice to have, so after dealing with a bunch of resource packages that hadn't been updated in 8 years, I was excited to find a modern package I could re-use that might provide that in the future :-)