From 5d05ef4ea802d11c43d1b6550d795279a7cc1939 Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Tue, 16 Jan 2007 00:46:09 +0000 Subject: [PATCH] # Experimental Atom feed output for public revision log This was SVN commit r4774. --- source/tools/autolog/SVNLog/config.yml | 1 + .../SVNLog/lib/SVNLog/Controller/LogUpdate.pm | 49 +++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/source/tools/autolog/SVNLog/config.yml b/source/tools/autolog/SVNLog/config.yml index 3e18d63a7b..907ec25b66 100644 --- a/source/tools/autolog/SVNLog/config.yml +++ b/source/tools/autolog/SVNLog/config.yml @@ -8,3 +8,4 @@ cdbi: scp: command : /usr/bin/scp -i /var/www/svnlog/ssh/wfgkey filename: philip@wildfiregames.com:~/svnlog/public + filename_feed: philip@wildfiregames.com:~/svnlog/public_feed diff --git a/source/tools/autolog/SVNLog/lib/SVNLog/Controller/LogUpdate.pm b/source/tools/autolog/SVNLog/lib/SVNLog/Controller/LogUpdate.pm index a1c295f2a2..a914dc15cf 100644 --- a/source/tools/autolog/SVNLog/lib/SVNLog/Controller/LogUpdate.pm +++ b/source/tools/autolog/SVNLog/lib/SVNLog/Controller/LogUpdate.pm @@ -4,8 +4,9 @@ use strict; use base 'Catalyst::Controller'; use XML::Simple; -use Text::ASCIITable::Wrap; -use File::Remote; +use File::Remote; +use XML::Atom::SimpleFeed; +use Data::UUID; sub doupdate : Local { @@ -47,7 +48,8 @@ sub doupdate : Local add_default_public_msgs($c); my $scp = new File::Remote(rcp => $c->config->{scp}{command}); - $scp->writefile($c->config->{scp}{filename}, generate_text()) or die $!; + $scp->writefile($c->config->{scp}{filename}, generate_text()) or die $!; + $scp->writefile($c->config->{scp}{filename_feed}, generate_feed()) or die $!; $c->res->body("Updated log to $max_seen."); } @@ -93,7 +95,14 @@ sub createtext : Local { my ($self, $c) = @_; my $out = generate_text(); - $c->res->body("$out"); + $c->res->body($out); +} + +sub createfeed : Local +{ + my ($self, $c) = @_; + my $out = generate_feed(); + $c->res->body($out); } @@ -125,6 +134,38 @@ EOF return $out; } +sub generate_feed +{ + my @logentries = SVNLog::Model::CDBI::Logentry->recent(7); + + my $uid_gen = new Data::UUID; + + my $feed = new XML::Atom::SimpleFeed( + title => "0 A.D. Revision Log", + link => "http://www.wildfiregames.com/0ad/", + id => "urn:uuid:" . $uid_gen->create_from_name_str('WFG SVN feed', 'feed'), + ); + + for (@logentries) + { + my ($revision, $author, $date, $msg) = ($_->revision, $_->author, $_->date, $_->public_msg); + next unless defined $msg and $msg->msg; + + my $uid = $uid_gen->create_from_name_str('WFG SVN feed', $revision); + + $feed->add_entry( + title => "Revision $revision", + id => "urn:uuid:$uid", + author => $author, + content => $msg->msg, + published => $date, + updated => $date, + ); + } + + return $feed->as_string; +} + sub filter_copyfrom { my @r = @_;