17 Jan 2020 07:30:55 UTC
- Distribution: XML-OPDS
- Module version: 0.06
- Source (raw)
- Browse (raw)
- How to Contribute
- Testers (126 / 0 / 0)
- KwaliteeBus factor: 1
- 91.39% Coverage
- License: perl_5
- Perl: v5.8.0
- Activity24 month
- Download (13.64KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionMELMOTHX Marco Pessottoand 1 contributors
- Marco Pessotto
- INTERNAL METHODS
- OPENSEARCH RESULTS
- LICENSE AND COPYRIGHT
XML::OPDS - OPDS (Open Publication Distribution System) feed creation
This module facilitates the creation of OPDS feeds.
The idea is that it should be enough to pass the navigation links and the title entries with some data, and have the feed back.
The OPDS feeds are basically Atom feeds, hence this module uses XML::Atom under the hood.
Some features are not supported yet, but patches are welcome. Also keep in mind that the applications which are supposed to talk to your server have a level of support which varies from decent to "keep crashing".
This is still very much a work in progress, but it's already generating valid and usable catalogs.
use XML::OPDS; my $feed = XML::OPDS->new(prefix => 'http://amusewiki.org'); # add two links, self and start are mandatory. $feed->add_to_navigations( rel => 'self', title => 'Root', href => '/', ); $feed->add_to_navigations( rel => 'start', title => 'Root', href => '/', ); # add a navigation for the title list, marking as leaf, where the # download links can be retrieved. $feed->add_to_navigations( title => 'Titles', description => 'texts sorted by title', href => '/titles', acquisition => 1, ); # and render print $feed->render; # you can reuse the object for leaf feeds (i.e. the acquistion # feeds), pushing another self navigation, which will replace the # previous one. $feed->add_to_navigations( rel => 'self', title => 'Titles', description => 'texts sorted by title', href => '/titles', ); # or, implicitely setting the self rel and cleaning the navigation # stash, keeping the meta $feed->add_to_navigations_new_level( title => 'Titles', acquisition => 1, href => '/titles', ); $feed->add_to_acquisitions( href => '/my/title', title => 'My title', files => [ '/my/title.epub' ], ); # and here we have an acquisition feed, because of the presence of # the acquisition. print $feed->render;
Even if the module wants characters as input (decoded strings, not bytes), the output XML is an UTF-8 encoded string.
Arrayref of XML::OPDS::Navigation objects. An object with a rel
self(the feed itself) and one with the rel
start(the root feed) are mandatory. If not present, the module will crash while rendering the feed.
Arrayref of XML::OPDS::Acquisition objects. If one or more objects are present, the feed will become an acquistion feed.
The producer of the feed. Defaults to this class name and version.
The uri of the author. Defaults to http://amusewiki.org (which is the home of this class).
Default to the empty string. On instances of this class, by itself has no effect. However, when calling
add_to_navigations, it will be passed to the constructors of those objects.
This is usually the hostname of the OPDS server. So you need just to pass, e.g. 'http://amusewiki.org' and have all the links prefixed by that (no slash mangling or adding is performed). If you are going to pass the full urls, leave it at the default.
Default to current timestamp. When calling
create_acquistion, use this timestamp as default.
The feed logo. If prefix is set, prepend it.
The feed icon. If prefix is set, prepend it.
Return the generated xml.
Return the XML::Atom::Feed object.
Create a XML::OPDS::Navigation object inheriting the prefix.
Create a XML::OPDS::Acquisition object inheriting the prefix.
create_navigationand add it to the
add_to_navigations, but it's meant to be used for
rel:selfattribute is injected in the arguments which are passed to
If a navigation with the attribute
selfwas already present in the stack, the new one will become the new
self, while the old one will become an
Also, this will remove any existing navigation with the
relattribute set to
subsection, given that you are creating a new level.
This is designed to play well with chained actions (so you can reuse the object, stack selfs, and the result will be correct).
create_acquisitionand add it to the
Return a list of XML::OPDS::Navigation objects excluding unique relationships like
Return an hashref, where the keys are the
relattributes of the navigation objects. The value is an object if the navigation is meant to be unique, or an arrayref of objects if not so.
Return true if there are acquisition objects stacked.
The following attributes can be set if you are building an Atom response for OpenSearch. See XML::OPDS::OpenSearch::Query for a concrete example.
A Data::Page object with the specification of the pages.
A string with the query for which you are serving the results.
Additional Query elements, should be an arrayref of XML::OPDS::OpenSearch::Query objects.
<melmothx at gmail.com>
Please report any bugs or feature requests to
bug-xml-opds at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=XML-OPDS. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
Copyright 2016 Marco Pessotto.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.