1NAME
2    Catalyst::View::XML::Feed - Catalyst view for RSS, Atom, or other XML
3    feeds
4
5SYNOPSIS
6    Create your view, e.g. lib/MyApp/View/Feed.pm
7
8      package MyApp::View::Feed;
9      use base qw( Catalyst::View::XML::Feed );
10      1;
11
12    In a controller, set the "feed" stash variable and forward to your view:
13
14      sub rss : Local {
15          my ($self, $c) = @_:
16          $c->stash->{feed} = $feed_obj_or_data;
17          $c->forward('View::Feed');
18      }
19
20DESCRIPTION
21    Catalyst::View::XML::Feed is a hassle-free way to serve an RSS, Atom, or
22    other XML feed from your Catalyst application.
23
24    Your controller should put feed data into "$c->stash->{feed}".
25
26DATA FORMATS
27    The value in "$c->stash->{feed}" can be an object from any of the
28    popular RSS or Atom classes, a plain Perl data structure, arbitrary
29    custom objects, or an xml string.
30
31  Plain Perl data
32      $c->stash->{feed} = {
33          format      => 'RSS 1.0',
34          id          => $c->req->base,
35          title       => 'My Great Site',
36          description => 'Kitten pictures for the masses',
37          link        => $c->req->base,
38          modified    => DateTime->now,
39
40          entries => [
41              {
42                  id       => $c->uri_for('rss', 'kitten_post')->as_string,
43                  link     => $c->uri_for('rss', 'kitten_post')->as_string,
44                  title    => 'First post!',
45                  modified => DateTime->now,
46                  content  => 'This is my first post!',
47              },
48              # ... more entries.
49          ],
50      };
51
52   Keys for feed
53    The "feed" hash can take any of the following keys. They are identical
54    to those supported by XML::Feed. See XML::Feed for more details.
55
56    *Note*: Depending on the feed format you choose, different subsets of
57    attributes might be required. As such, it is recommended that you run
58    the generated XML through a validator such as
59    <http://validator.w3.org/feed/> to ensure you included all necessary
60    information.
61
62    format
63        Can be any of: "Atom", "RSS 0.91", "RSS 1.0", "RSS 2.0"
64
65    id
66    title
67    link
68    description
69    modified
70        This should be a DateTime object.
71
72    base
73    tagline
74    author
75    language
76    copyright
77    generator
78    self_link
79    entries
80        An array ref of entries.
81
82   Keys for entries
83    The "entries" array contains any number of hashrefs, each representing
84    an entry in the feed. Each can contain any of the following keys. They
85    are identical to those of XML::Feed::Entry. See XML::Feed::Entry for
86    details.
87
88    *Note*: Depending on the feed format you choose, different subsets of
89    attributes might be required. As such, it is recommended that you run
90    the generated XML through a validator such as
91    <http://validator.w3.org/feed/> to ensure you included all necessary
92    information.
93
94    id
95    title
96    content
97    link
98    modified
99        This should be a DateTime object.
100
101    issued
102        This should be a DateTime object.
103
104    base
105    summary
106    category
107    tags
108    author
109
110  Arbitrary custom objects
111    If you have custom objects that you would like to turn into feed
112    entries, this can be done similar to plain Perl data structures.
113
114    For example, if we have a "DB::BlogPost" DBIx::Class model, we can do
115    the following:
116
117      $c->stash->{feed} = {
118          format      => 'Atom',
119          id          => $c->req->base,
120          title       => 'My Great Site',
121          description => 'Kitten pictures for the masses',
122          link        => $c->req->base,
123          modified    => DateTime->now,
124
125          entries => [ $c->model('DB::BlogPost')->all() ],
126      };
127
128    The view will go through the keys for entries fields and, if possible,
129    call a method of the same name on your entry object (e.g.
130    "$your_entry->title(); $your_entry->modified();") to get that value for
131    the XML.
132
133    Any missing fields are simply skipped.
134
135    If your class's method names do not match up to the "entries" keys, you
136    can simply alias them by wrapping with another method. For example, if
137    your "DB::BlogPost" has a "post_title" field which should be the title
138    for the feed entry, you can add this to BlogPost.pm:
139
140      sub title { $_[0]->post_title }
141
142  XML::Feed
143    An XML::Feed object.
144
145      $c->stash->{feed} = $xml_feed_obj;
146
147  XML::RSS
148    An XML::RSS object.
149
150      $c->stash->{feed} = $xml_rss_obj;
151
152  XML::Atom::SimpleFeed
153    An XML::Atom::SimpleFeed object.
154
155      $c->stash->{feed} = $xml_atom_simplefeed_obj;
156
157  XML::Atom::Feed
158    An XML::Atom::Feed object.
159
160      $c->stash->{feed} = $xml_atom_feed_obj;
161
162  XML::Atom::Syndication::Feed
163    An XML::Atom::Syndication::Feed object.
164
165      $c->stash->{feed} = $xml_atom_syndication_feed_obj;
166
167  Plain text
168    If none of the formats mentioned above are suitable, you may also
169    provide a string containing the XML data.
170
171      $c->stash->{feed} = $xml_string;
172
173SOURCE REPOSITORY
174    <http://github.com/mstratman/Catalyst-View-XML-Feed>
175
176AUTHOR
177    Mark A. Stratman <stratman@gmail.com>
178
179COPYRIGHT & LICENSE
180    Copyright 2011 the above author(s).
181
182    This sofware is free software, and is licensed under the same terms as
183    perl itself.
184
185