Diff for /CVSROOT/cvs2rss.pl between versions 1.2 and 1.9

version 1.2, 2005/10/11 22:11:16 version 1.9, 2005/10/24 21:53:20
Line 43  my $author = getpwuid(getuid()) . "\@" . Line 43  my $author = getpwuid(getuid()) . "\@" .
 $author = 'guy' . "\@" . 'albertelli.com';  $author = 'guy' . "\@" . 'albertelli.com';
 my $pubDate = strftime('%a, %d %b %Y %H:%M:%S %Z',localtime(time));  my $pubDate = strftime('%a, %d %b %Y %H:%M:%S %Z',localtime(time));
 my $description;  my $description;
 my @title=split(",",$ARGV[0]);  
   
   my @args = split(" ", $ARGV[0]);
   # 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
   &bail if $args[0] eq '-' && $args[1] eq 'Imported';
   
   
 my $rss = new XML::RSS(version => '2.0');  my $rss = new XML::RSS(version => '2.0');
 $rss->channel(  
  title=> $channelTitle,  
  link => $channelLink,  
  language => 'en',  
  description => $channelTitle,  
  copyright => '(c) 2005 MSU Board of Trustees.'  
 );  
   
 # If rssFeed exists, parse it  # If rssFeed exists, parse it
 if (-r "$rssFeed") {  if (-r "$rssFeed") {
  $rss->parsefile($rssFeed);      $rss->parsefile($rssFeed);
 }  }
   
   $rss->channel(
         title=> $channelTitle,
         link => $channelLink,
         language => 'en',
         description => $channelTitle,
         copyright => '(c) 2005 MSU Board of Trustees.',
         pubDate => $pubDate 
         );
   
 # Limit entries in the feed to $numEntries  # Limit entries in the feed to $numEntries
 pop(@{$rss->{'items'}}) while (@{$rss->{'items'}} >= $numEntries);  pop(@{$rss->{'items'}}) while (@{$rss->{'items'}} >= $numEntries);
   
 # Format title of the rss item  foreach my $file (@args) {
 # Remove space, append / and set title to /file/that/changed - oldversion/newversion      my @title=split(",",$file);
 $title[0] =~s/ /\//;  
   
 # Format the cvslog msg itself      # Format title of the rss item
 while (<STDIN>) {      # Remove space, append / and set title to /file/that/changed - oldversion/newversion
       $title[0] =~s/ /\//;
       
       # Format the cvslog msg itself
       while (<STDIN>) {
  chomp($_);   chomp($_);
  if ($_=~/^[A-Z].*:\s*$/) {   if ($_=~/^[A-Z].*:\s*$/) {
  $_ = "<br /><b>" . $_ . "</b><br />";      $_ = "<br /><b>" . &HTML::Entities::encode($_,'<>&"') . "</b><br />";
  }   } else {
  else {      $_ = &HTML::Entities::encode($_,'<>&"');
  $_ .= "<br />";      $_ .= "<br />";
  }   }
  $description .= $_;   $description .= $_;
 }      }
   
 if ($cvsDiff == 1) {      if ($cvsDiff == 1) { 
  # If the old version of the file is not NONE (if it isn't a new file), and if it is a .txt or .java file (that has no html)  
  # This will rdiff it against the previous version, and include that diff in the rss feed  
   
  if (($title[1] != "NONE") && ($title[0]=~/(.*).(pm)$/)){  
  my $tmpFile = "/tmp/diff.$$";  
  my $cmdLine = "cvs -n rdiff -kk -r " . $title[1] .  " -r " . $title[2] . " " . $title[0] . ">" . $tmpFile;  
  system($cmdLine);  
   
  $description .= "<br /><b>Differences:</b><br /><pre>";  
  open CVSDIFF, "<" . $tmpFile;  
  foreach my $line (<CVSDIFF>) {  
  $description .= &HTML::Entities::encode($line,'<>&"');  
  }  
  $description .= "</pre>";  
  unlink($tmpFile);     
  }   
 }  
   
 $rss->add_item(   # If the old version of the file is not NONE (if
  title => "/" . $title[0] . " - " . $title[1] . "/" . $title[2],   # it isn't a new file), and if it is a pm/pl/conf/tab file.
  author => $author,   # This will rdiff it against the previous version, and
  pubDate => $pubDate,    # include that diff in the rss feed
  description=> $description,  
  mode => 'insert'   if (($title[1] != "NONE") && ($title[0]=~/(.*).(pm|pl|conf|tab)$/)){
 );      my $tmpFile = "/tmp/diff.$$";
       my $cmdLine = "cvs -n rdiff -u -kk -r " . $title[1] .  " -r " . $title[2] . " " . $title[0] . ">" . $tmpFile;
       system($cmdLine);
       
       $description .= "<br /><b>Differences:</b><br /><pre>";
       open CVSDIFF, "<" . $tmpFile;
       foreach my $line (<CVSDIFF>) {
    $description .= &HTML::Entities::encode($line,'<>&"');
       }
       $description .= "</pre>";
       unlink($tmpFile);   
    }
       }
   
 foreach my $element (@{$rss->{'items'}}) {      my $link = 'http://install.loncapa.org/cgi-bin/cvsweb.cgi/'.$title[0];
       if ($title[1] != "NONE") {
           $link .= '.diff?r1='.$title[1].';r2='.$title[2].';f=h';
       }
   
       $rss->add_item(
      title => "/" . $title[0] . " - " . $title[1] . "/" . $title[2],
      author => $author,
      description=> $description,
      mode => 'insert',
      pubDate => $pubDate,
      link => $link
      );
   
       foreach my $element (@{$rss->{'items'}}) {
  $element->{'description'} = &HTML::Entities::encode($element->{'description'},'<>&"');    $element->{'description'} = &HTML::Entities::encode($element->{'description'},'<>&"'); 
       }
 }  }
   
 $rss->save($rssFeed);  $rss->save($rssFeed);
Line 114  $rss->save($rssFeed); Line 137  $rss->save($rssFeed);
 # Rsync this rss feed to another publically accessable machine.  # Rsync this rss feed to another publically accessable machine.
 #my $cmdLine="rsync -r -e ssh --delete /export/www/rss/html/ builder\@monkey:/export/www/rss/html/";  #my $cmdLine="rsync -r -e ssh --delete /export/www/rss/html/ builder\@monkey:/export/www/rss/html/";
 #system($cmdLine);  #system($cmdLine);
   
   sub bail {
       my @toss = <STDIN>;
       exit @_;
   }

Removed from v.1.2  
changed lines
  Added in v.1.9


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>