Egg::View::FeedPP - XML::FeedPP for Egg::View.
configuration.
... VIEW=> [ [ FeedPP=> { content_type => 'application/rss+xml', charset => 'UTF-8', } ], ],
example code.
my $view= $e->view('FeedPP'); my $feed= $view->feed; $feed->title('MY BLOG'); $feed->link('http://myblog.domain.name/'); for my $item (@items) { $feed->add_item( $item->{url}, title => $item->{title}, description => $item->{description}, ); } print $view->render;
It is a module to use XML::FeedPP with VIEW.
I think that you should operate the XML::FeedPP object directly from the feed method though some methods of XML::FeedPP do bind.
It has the function to cache feeding that XML::FeedPP generated. * Egg::Plugin::Cache is used.
'FeedPP' is added to the setting of VIEW.
VIEW=> [ [ FeedPP=> { ... option ... } ] ],
Contents type when outputting it.
Default is 'application/rss+xml'.
Character set when outputting it.
Default is 'UTF-8'.
If the cash function is used, the cash name to use Egg::Plugin::Cache is set.
* Even if cash is used, it is not indispensable because the thing specified when the cash function is called can be done.
see Egg::Plugin::Cache.
The object of this View is returned.
my $view= $e->view('FeedPP');
The cash function is made effective.
* Thing that can be used by Egg::Plugin::Cache's being appropriately set.
CACHE_KEY is only passed if 'cache_name' is set with CONFIGURATION.
When CACHE_NAME is passed, the cash is used. * It gives priority more than set of 'cache_name'.
EXPIRES is validity term to pass it to the set method when Cache::Memcached is used with Egg::Plugin::Cache. * It is not necessary usually.
my $expr= 60* 60; # one hour. my $view= $e->view('FeedPP'); unless ($view->cache('CACHE_NAME', 'CACHE_KEY', $expr)) { # # RSS feed generation code. # my $feed= $view->feed; $feed->title('MYBLOG'); .... .... # ---------------- }
* 'RSS feed generation code' part from the unless sentence though the image might not be gripped easily for a moment You only have to move as usual even if it removes.
Anything need not be done excluding this. If cash becomes a hit, the content of cash is output with output.
The type of the generation feeding to use it by the feed method is returned.
The value that can be specified for FEED_TYPE is rss, rdf, and atom.
FEED_TYPE returns and 'RSS' always returns when it is not given or wrong specification is done.
# Example of generating key to cash with value obtained from URI. # example uri = http://domain/xml/hoge/rdf # my $feed_type= $view->feed_type( $e->snip->[2] ); $view->cache('FileCache', "xml_hoge_${feed_type}") || do { my $feed= $view->feed($feed_type); ..... ... };
The XML::FeedPP object is returned.
When FEED_TYPE is specified, the corresponding module is read.
If FEED_TYPE unspecifies it, 'RSS' is processed to have specified it.
my $feed= $view->feed('Atom');
see XML::FeedPP.
The XML::FeedPP context set in View is erased.
To_string of XML::FeedPP is called and feeding is generated.
If cash is effective, the content of cash is returned.
my $feed_text= $view->render($feed);
The result of the render method is received, and set contents type and contents body are set in Egg::Response.
$view->output($feed);
* It is not necessary to call it from the project code because it is called by the operation of Egg usually.
Tentatively, Messod of following XML::FeedPP that seems to be necessary for the feeding generation it is done and bind is done to this View.
item, title, pubDate, link, add_item, merge, remove_item, clear_item, sort_item, uniq_item, limit_item, normalize
XML::FeedPP, Egg::Plugin::Cache, Egg::Release,
Masatoshi Mizuno <lushe@cpan.org>
Copyright (C) 2007 by Bee Flag, Corp. <http://egg.bomcity.com/>, All Rights Reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
To install Egg::Release::XML::FeedPP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Egg::Release::XML::FeedPP
CPAN shell
perl -MCPAN -e shell install Egg::Release::XML::FeedPP
For more information on module installation, please visit the detailed CPAN module installation guide.