[Bast-commits] r8090 - ironman/IronMan-Web/lib/IronMan/Web/View
grim at dev.catalyst.perl.org
grim at dev.catalyst.perl.org
Sat Dec 12 21:03:18 GMT 2009
Author: grim
Date: 2009-12-12 21:03:17 +0000 (Sat, 12 Dec 2009)
New Revision: 8090
Added:
ironman/IronMan-Web/lib/IronMan/Web/View/RSS.pm
Log:
Added author to feeds
Added: ironman/IronMan-Web/lib/IronMan/Web/View/RSS.pm
===================================================================
--- ironman/IronMan-Web/lib/IronMan/Web/View/RSS.pm (rev 0)
+++ ironman/IronMan-Web/lib/IronMan/Web/View/RSS.pm 2009-12-12 21:03:17 UTC (rev 8090)
@@ -0,0 +1,64 @@
+package IronMan::Web::View::RSS;
+use Moose;
+use XML::Feed;
+
+use namespace::autoclean;
+
+extends 'Catalyst::View';
+
+=head1 NAME
+
+IronMan::Web::View::RSS - Catalyst View
+
+=head1 DESCRIPTION
+
+Catalyst View.
+
+=head1 AUTHOR
+
+Graeme Lawton,,,
+
+=head1 LICENSE
+
+This library is free software. You can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+__PACKAGE__->meta->make_immutable;
+
+sub process {
+ my ( $self, $c ) = @_;
+
+ my $type;
+ if($c->req->param('feed') eq 'RSS') {
+ $type = 'RSS';
+ $c->res->content_type('application/rss+xml');
+ } else {
+ $type = 'Atom';
+ $c->res->content_type('application/atom+xml');
+ }
+
+ my $feed = new XML::Feed($type);
+
+ #Loop through the posts and add them to the feed.
+ foreach my $post ($c->stash->{'posts'}->all) {
+ #send parameter full=1 for full body in feeds, otherwise show summary.
+ my $content = $post->summary_filtered;
+ $content = $post->body_filtered if($c->req->param('full'));
+
+ my $entry = XML::Feed::Entry->new();
+ $entry->link($post->url);
+ $entry->id($post->post_id);
+ $entry->title($post->feed->title . ' ' . $post->title);
+ $entry->author($post->feed->owner);
+ $entry->modified($post->posted_on);
+ $entry->content($content);
+ $feed->add_entry($entry);
+ }
+
+ $c->res->body($feed->as_xml);
+
+}
+
+1;
More information about the Bast-commits
mailing list