Fix and improve atom/rss feed
authorVincent Tondellier <tonton+hg@team1664.org>
Mon, 04 Aug 2014 14:52:24 +0200
changeset 32 3e776f1b21d4
parent 31 f77c6719c05c
child 33 da690d68c1ff
Fix and improve atom/rss feed
CrashTest.pl
templates/index.atom.ep
--- a/CrashTest.pl	Mon Aug 04 14:51:37 2014 +0200
+++ b/CrashTest.pl	Mon Aug 04 14:52:24 2014 +0200
@@ -78,6 +78,13 @@
     return b($self->t(span => (title => $signature, class => "shortened-signature") => $short_signature));
 };
 
+helper xml_escape_block => sub {
+    my ($c, $block) = @_;
+    my $result = $block->();
+    $result = xml_escape $result;
+    return Mojo::ByteStream->new($result);
+};
+
 get '/' => sub {
     my $self = shift;
     my $page = 1;
--- a/templates/index.atom.ep	Mon Aug 04 14:51:37 2014 +0200
+++ b/templates/index.atom.ep	Mon Aug 04 14:52:24 2014 +0200
@@ -4,19 +4,23 @@
   <link type="text/html" rel="alternate" href="<%= url_for()->to_abs =%>"/>
   <link type="application/atom+xml" rel="self" href="<%= url_for('current', format => 'atom')->to_abs =%>"/>
   <title>Recent Crashs</title>
-  <updated><%= POSIX::strftime("%FT%T%z", gmtime(@$files[0]->{date} || 0)) =%></updated>
+  <updated><%= @$files[0]->{date}->strftime("%FT%TZ") =%></updated>
 
 % foreach my $file(@$files) {
   <entry>
-    <id>tag:crash,2012:uuid::<%= $file->{uuid} =%></id>
+    <id>tag:crash,2014:uuid::<%= $file->{uuid} =%></id>
     <link type="text/html" rel="alternate" href="<%= url_for('report', uuid => $file->{uuid})->to_abs =%>"/>
     <title><%= $file->{product} =%>: <%= $file->{signature} =%></title>
-    <updated><%= POSIX::strftime("%FT%T%z", gmtime($file->{date})) =%></updated>
+    <updated><%= $file->{date}->strftime("%FT%TZ") =%></updated>
+    <published><%= $file->{date}->strftime("%FT%TZ") =%></published>
     <author>
       <name></name>
     </author>
     <content type="html">
-      %= t span => POSIX::strftime("%F %T", localtime($file->{date}))
+    %= xml_escape_block begin
+      %= t h3 => $file->{date}->strftime("%F %T")
+      %= t h3 => $file->{product} . " version " . $file->{version}
+    % end
     </content>
   </entry>
 % }