Catalyst::Model::XML::Feed - Use RSS/Atom feeds as a Catalyst Model
Version 0.02
In your own model:
package MyApp::Model::Feeds; use base qw(Catalyst::Model::XML::Feed);
Then from elsewhere in your application:
$c->model('Feeds')->register('delicious', 'http://del.icio.us/rss'); $c->model('Feeds')->register('http://blog.jrock.us/'); my @feeds = $c->model('Feeds')->get_all_feeds; my $delicious = $c->model('Feeds')->get('delicious');
You can also pre-register feeds from your config file:
--- Model::Feeds: feeds: - uri: http://blog.jrock.us/ - uri: http://search.cpan.org/ - title: delicious uri: http://del.icio.us/rss/
See CONFIGURATION below for details.
Catalyst::Model::XML::Feed allows you to use XML feeds in your Catalyst application. To use a feed, you need to register it with the register method.
register
Once a feed is registered, it's automatically cached for you.
Configuration is accepted via the standard Catalyst method:
$c->config->{Model::Feeds}->{key} = $value;
Valid keys include:
Time To Live, in seconds, for each feed. If a feed is older than this value, it is refreshed from its source. Defaults to 3600 seconds, 1 hour.
An arrayref of hashes containing feeds to preload. The hash is required to contain a key called "uri" or "location", specifing the URL of the feed to load. It may optinally contain "name" or "title", if you wish to override the feed's own title.
Example config in MyApp.yml (assuming you call your feed model Feeds):
Feeds
Model::Feeds: feeds: - uri: http://blog.jrock.us/ - title: delicious location: http://del.icio.us/rss/ ttl: 1337
Creates a new instance. Called for you by Catalyst. If your config file contains invalid feeds, this will die and kill your entire app, so be careful.
Registers a feed with the Model. If $uri_of_feed points to a feed, the feed is added under its own name. If $$uri_of_feed points to an HTML or XHTML document containing <link> tags pointing to feeds, all feeds are added by using their URIs as their names.
$uri_of_feed
<link>
Returns a list of the names of the feeds that were added.
Throws an exception if the $uri_of_feeds doesn't contain a feed or links to feeds, or it cannot be fetched.
$uri_of_feeds
Registers a feed with the Model. If $name is already registered, the old feed at $name is forgotten and replaced with the new feed at $uri_of_feed. The title of the feed is replaced with $name.
$name
title
Throws an exception if $uri_of_feed isn't an XML feed (or doesn't contain a link to one).
link
Throws an exception if the $uri_of_feed links to multiple feeds.
Returns the names of all registered feeds.
Returns a list of all registered feeds. The elements are XML::Feed objects.
XML::Feed
Returns the XML::Feed object that corresponds to $name. Throws an exception if there is no feed that's named $name.
Forces the feed $name to be refreshed from the source. If $name is omitted, refreshes all registered feeds.
The URI you passed to register was not a feed, or did not link to any feeds.
The URI you passed to register referenced more than one feed. If you want to register all the feeds, use the one argument form of register instead of the two argument form.
The feed that you requested does not exist. Try registering it first.
Jonathan Rockway, <jrockway at cpan.org>
<jrockway at cpan.org>
Please report any bugs or feature requests to bug-catalyst-model-xml-feed at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-Model-XML-Feed. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-catalyst-model-xml-feed at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Catalyst::Model::XML::Feed
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Catalyst-Model-XML-Feed
CPAN Ratings
http://cpanratings.perl.org/d/Catalyst-Model-XML-Feed
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Catalyst-Model-XML-Feed
Search CPAN
http://search.cpan.org/dist/Catalyst-Model-XML-Feed
XML::Feed and XML::Feed::Entry
Copyright 2006 Jonathan Rockway, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Catalyst::Model::XML::Feed, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::Model::XML::Feed
CPAN shell
perl -MCPAN -e shell install Catalyst::Model::XML::Feed
For more information on module installation, please visit the detailed CPAN module installation guide.