Implement an RSS feed with the changes from the commitfest app.
authorMagnus Hagander <magnus@hagander.net>
Fri, 31 Jul 2009 11:56:38 +0000 (07:56 -0400)
committerRobert Haas <robertmhaas@gmail.com>
Fri, 31 Jul 2009 11:56:38 +0000 (07:56 -0400)
perl-lib/PgCommitFest/CommitFest.pm
perl-lib/PgCommitFest/Handler.pm
template/header.tt2

index 695583926293fcb0346a12135147a47a43c666aa..7e67f970b9080c1b212fc5d2da70d17764168edb 100644 (file)
@@ -1,6 +1,7 @@
 package PgCommitFest::CommitFest;
 use strict;
 use warnings;
+use XML::RSS;
 
 sub activity {
        my ($r, $extrapath) = @_;
@@ -23,6 +24,52 @@ EOM
                'activity' => $activity });
 }
 
+sub activity_rss {
+       my ($r, $extrapath) = @_;
+       my $where = ''; # By default, show all commitfests
+       my @l = ();
+
+       if (defined($extrapath)) {
+               $l[0] = setup($r, $extrapath)->{'id'};
+               $where = 'WHERE v.commitfest_id = ?';
+       }
+       my $activity = $r->db->select(<<EOM, @l);
+SELECT
+       to_char(v.last_updated_time, 'YYYY-MM-DD HH24:MI:SS') AS last_updated_time,
+       v.last_updater, v.patch_name, v.patch_id, v.activity_type, v.details,
+       commitfest.name as commitfest_name
+FROM
+       commitfest_activity_log v
+INNER JOIN
+       commitfest ON v.commitfest_id=commitfest.id
+$where
+ORDER BY
+       v.last_updated_time DESC LIMIT 50
+EOM
+
+       my $rss = new XML::RSS(version=>'2.0');
+       $rss->channel(  title           => 'PostgreSQL commitfest updates',
+                       link            => 'http://commitfest.postgresql.org',
+                       language        => 'en',
+                       description     => 'PostgreSQL commitfest updates'
+                       );
+       foreach my $row (@$activity) {
+               $rss->add_item(guid     => 'http://commitfest.postgresql.org/activity/' .
+                                       $row->{'patch_id'} . '/' . $row->{'last_updated_time'},
+                               title   => $row->{'commitfest_name'} . ': ' . $row->{'patch_name'},
+                               description => 'Commitfest: ' . $row->{'commitfest_name'} .
+                                       '<br/>Patch: <a href="http://commitfest.postgresql.org/action/patch_view?id=' .
+                                       $row->{'patch_id'} . '">' . $row->{'patch_name'} . '</a><br/>Change by: ' .
+                                       $row->{'last_updater'} . '<br/>Change: ' . $row->{'activity_type'} . ': ' .
+                                       $row->{'details'}
+                               );
+       }
+       print "Content-type: application/xml+rss\n\n";
+
+       print $rss->as_string;
+       $r->{'response_sent'} = 1;
+}
+
 sub delete {
        my ($r) = @_;
        $r->authenticate('require_login' => 1, 'require_administrator' => 1);
index b269e0f1b5bfad3370f53c631d6d236272544687..57dc859931169b2e94cbece6ab71e81ac12c9822 100644 (file)
@@ -13,6 +13,7 @@ our %ACTION = (
        'login'                                     => \&PgCommitFest::Handler::login,
        'logout'                                    => \&PgCommitFest::Handler::logout,
        'commitfest_activity'           => \&PgCommitFest::CommitFest::activity,
+       'commitfest_activity.rss'               => \&PgCommitFest::CommitFest::activity_rss,
        'commitfest_delete'                     => \&PgCommitFest::CommitFest::delete,
        'commitfest_form'                       => \&PgCommitFest::CommitFest::form,
        'commitfest_search'                 => \&PgCommitFest::CommitFest::search,
index 1563751cb587dd6e8983b8f832621b0c29df1c7b..f9648ecc028f8ec4c349ae246975e5cc7f56ab72 100644 (file)
@@ -5,6 +5,7 @@
   <title>PostgreSQL CommitFest Management[% IF title != '' %]: [% title | htmlsafe %][% END %]</title>
     <style type="text/css" media="screen" title="Normal Text">@import url("/layout/css/blue/commitfest.css");</style>
     <script type="text/javascript" src="/layout/js/geckostyle.js"></script>
+    <link rel="alternate" type="application/rss+xml" title="Commitfest changes" href="/action/commitfest_activity.rss" />
 </head>
 <body>
 <table id="commitfestHeader">