Masatoshi Mizuno > Egg-Release-XML-FeedPP-0.02 > Egg::View::FeedPP

Download:
Egg-Release-XML-FeedPP-0.02.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.01   Source  

NAME ^

Egg::View::FeedPP - XML::FeedPP for Egg::View.

SYNOPSIS ^

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;

DESCRIPTION ^

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.

CONFIGURATION ^

'FeedPP' is added to the setting of VIEW.

  VIEW=> [ [ FeedPP=> { ... option ... } ] ],

content_type

Contents type when outputting it.

Default is 'application/rss+xml'.

charset

Character set when outputting it.

Default is 'UTF-8'.

cache_name

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.

METHODS ^

new

The object of this View is returned.

  my $view= $e->view('FeedPP');

cache ( [CACHE_KEY] or [CACHE_NAME], [CACHE_KEY] {, [EXPIRES] } )

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.

feed_type ( [FEED_TYPE] )

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);
    .....
    ...
    };

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.

reset

The XML::FeedPP context set in View is erased.

render

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);

output

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.

BINDING METHODS ^

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.

SEE ALSO ^

XML::FeedPP, Egg::Plugin::Cache, Egg::Release,

AUTHOR ^

Masatoshi Mizuno <lushe@cpan.org>

COPYRIGHT ^

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.

syntax highlighting: