--- CVSROOT/cvs2rss.pl 2005/10/24 21:53:20 1.9 +++ CVSROOT/cvs2rss.pl 2007/01/23 21:30:08 1.12 @@ -29,23 +29,23 @@ use XML::RSS; use POSIX; # Stuff you need to setup +my $cvslink = 'http://install.loncapa.org/cgi-bin/cvsweb.cgi/'; my $rssFeed ="/home/loninst/public_html/loncapa.rss"; my $emailDomain = "loncapa.org"; my $channelTitle = "Lon-CAPA RSS Feed"; my $channelLink = "http://install.loncapa.org/loncapa.rss"; -my $numEntries = 200; +my $numEntries = 30; # Set this to 1 to enable cvs rdiff my $cvsDiff = 1; # Leave everything else alone -my $author = getpwuid(getuid()) . "\@" . $emailDomain; -$author = 'guy' . "\@" . 'albertelli.com'; +my $author = getpwuid(getuid()); my $pubDate = strftime('%a, %d %b %Y %H:%M:%S %Z',localtime(time)); -my $description; - my @args = split(" ", $ARGV[0]); +my $dir = shift(@args); + # bail when this is a new directory &bail if $args[0] eq '-' && "$args[1] $args[2]" eq 'New directory'; # bail if this is an import @@ -71,25 +71,30 @@ $rss->channel( # Limit entries in the feed to $numEntries pop(@{$rss->{'items'}}) while (@{$rss->{'items'}} >= $numEntries); +my $commit_msg; +while () { + chomp($_); + if ($_=~/^[A-Z].*:\s*$/) { + $_ = "
" . &HTML::Entities::encode($_,'<>&"') . "
"; + } else { + $_ = &HTML::Entities::encode($_,'<>&"'); + $_ .= "
"; + } + $commit_msg .= $_; +} + +$commit_msg .= '
Author:
'.$author.'
'; + foreach my $file (@args) { my @title=split(",",$file); - + my $description = $commit_msg; # Format title of the rss item # Remove space, append / and set title to /file/that/changed - oldversion/newversion $title[0] =~s/ /\//; - + $title[0] = $dir.'/'.$title[0]; + # Format the cvslog msg itself - while () { - chomp($_); - if ($_=~/^[A-Z].*:\s*$/) { - $_ = "
" . &HTML::Entities::encode($_,'<>&"') . "
"; - } else { - $_ = &HTML::Entities::encode($_,'<>&"'); - $_ .= "
"; - } - $description .= $_; - } if ($cvsDiff == 1) { @@ -98,7 +103,9 @@ foreach my $file (@args) { # This will rdiff it against the previous version, and # include that diff in the rss feed - if (($title[1] != "NONE") && ($title[0]=~/(.*).(pm|pl|conf|tab)$/)){ + if (($title[1] != "NONE") + && ($title[0]=~/(.*)\.(pm|pl|conf|tab)$/) + && ($title[0]!~|/localize/localize/..\.pm|) ) { my $tmpFile = "/tmp/diff.$$"; my $cmdLine = "cvs -n rdiff -u -kk -r " . $title[1] . " -r " . $title[2] . " " . $title[0] . ">" . $tmpFile; system($cmdLine); @@ -113,7 +120,7 @@ foreach my $file (@args) { } } - my $link = 'http://install.loncapa.org/cgi-bin/cvsweb.cgi/'.$title[0]; + my $link = $cvslink.$title[0]; if ($title[1] != "NONE") { $link .= '.diff?r1='.$title[1].';r2='.$title[2].';f=h'; } @@ -126,10 +133,11 @@ foreach my $file (@args) { pubDate => $pubDate, link => $link ); +} - foreach my $element (@{$rss->{'items'}}) { - $element->{'description'} = &HTML::Entities::encode($element->{'description'},'<>&"'); - } +foreach my $element (@{$rss->{'items'}}) { + $element->{'description'} = + &HTML::Entities::encode($element->{'description'},'<>&"'); } $rss->save($rssFeed);