From: Matt S Trout Date: Tue, 25 Oct 2011 08:42:35 +0000 (+0000) Subject: make the atom feed valid X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b0df368c0a3e1356522c54a0a358e2e09d9c7c1f;hp=581526556280ae8db00f9466052eef4d0d43a1a7;p=scpubgit%2FSCS.git make the atom feed valid --- diff --git a/lib/SCSite/FeedGenerator.pm b/lib/SCSite/FeedGenerator.pm index 981865c..e8e28c1 100644 --- a/lib/SCSite/FeedGenerator.pm +++ b/lib/SCSite/FeedGenerator.pm @@ -18,19 +18,21 @@ sub _config_to_data { my $base_page = $self->pages->get({ path => $config->{base} }); my @entry_pages = $base_page->children(%{$config->{entries}}) ->latest(10)->flatten; + my $updated = (sort map $_->created, @entry_pages)[-1]; +{ %$config, id => $self->_id_for($base_page->path), - web_url => $base_page->path, - feed_url => "/feed/${\$config->{base}}", + web_url => $base_page->path.'/', + feed_url => "/feed/${\$config->{base}}/", + updated => join('T', split(' ',$updated)).'Z', entries => [ map +{ title => $_->title, summary_html => do { use HTML::Tags; - HTML::Tags::to_html_string(

, $_->description,

) + join '', HTML::Tags::to_html_string(

, $_->description,

) }, content_html => $_->body, - created => $_->created, + created => join('T', split(' ',$_->created)).'Z', web_url => $_->path, }, @entry_pages ], } @@ -70,6 +72,7 @@ sub _feed_data_to_tags { : ()), ' ', , "\n", ' ', , "\n", + ' ', , $data->{updated}, , "\n", ' ', , $data->{id}, , "\n", (map $self->_entry_data_to_tags($_), @{$data->{entries}}), ); @@ -77,19 +80,22 @@ sub _feed_data_to_tags { sub _entry_data_to_tags { my ($self, $data) = @_; - use XML::Tags qw(entry title link id published updated summary content); + use XML::Tags qw( + entry title author name link id published updated summary content + ); my $web_url = $data->{web_url}; ' ', , "\n", ' ', , $data->{title}, , "\n", + ' ', , , "Shadowcat Staff", , , "\n", ' ', , "\n", ' ', , $self->_id_for($data->{web_url}), , "\n", ' ', , $data->{created}, , "\n", ' ', , ($data->{created}||$data->{updated}), , "\n", ($data->{summary_html} - ? (' ', , \($data->{summary_html}), , "\n") + ? (' ', , \('{summary_html}.']]>'), , "\n") : () ), - ' ', , \($data->{body_html}), , "\n", + ' ', , \('{content_html}.']]>'), , "\n", ' ', , "\n"; }