Diff for /CVSROOT/cvs2rss.pl between versions 1.8 and 1.12

version 1.8, 2005/10/24 21:38:14 version 1.12, 2007/01/23 21:30:08
Line 29  use XML::RSS; Line 29  use XML::RSS;
 use POSIX;  use POSIX;
   
 # Stuff you need to setup   # Stuff you need to setup 
   my $cvslink = 'http://install.loncapa.org/cgi-bin/cvsweb.cgi/';
 my $rssFeed ="/home/loninst/public_html/loncapa.rss";  my $rssFeed ="/home/loninst/public_html/loncapa.rss";
 my $emailDomain = "loncapa.org";  my $emailDomain = "loncapa.org";
 my $channelTitle = "Lon-CAPA RSS Feed";  my $channelTitle = "Lon-CAPA RSS Feed";
 my $channelLink = "http://install.loncapa.org/loncapa.rss";  my $channelLink = "http://install.loncapa.org/loncapa.rss";
 my $numEntries = 200;  my $numEntries = 30;
   
 # Set this to 1 to enable cvs rdiff  # Set this to 1 to enable cvs rdiff
 my $cvsDiff = 1;  my $cvsDiff = 1;
   
 # Leave everything else alone  # Leave everything else alone
 my $author = getpwuid(getuid()) . "\@" . $emailDomain;  my $author = getpwuid(getuid());
 $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 @title=split(",",$ARGV[0]);  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
   &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');
   
Line 61  $rss->channel( Line 68  $rss->channel(
       pubDate => $pubDate         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  my $commit_msg;
 # Remove space, append / and set title to /file/that/changed - oldversion/newversion  
 $title[0] =~s/ /\//;  
   
 # Format the cvslog msg itself  
 while (<STDIN>) {  while (<STDIN>) {
     chomp($_);      chomp($_);
     if ($_=~/^[A-Z].*:\s*$/) {      if ($_=~/^[A-Z].*:\s*$/) {
Line 78  while (<STDIN>) { Line 80  while (<STDIN>) {
  $_ = &HTML::Entities::encode($_,'<>&"');   $_ = &HTML::Entities::encode($_,'<>&"');
  $_ .= "<br />";   $_ .= "<br />";
     }      }
     $description .= $_;      $commit_msg .= $_;
 }  }
   
 if ($cvsDiff == 1) {   $commit_msg .= '<br /><b>Author:</b><br />'.$author.'<br />';
   
   foreach my $file (@args) {
       my @title=split(",",$file);
   
     # If the old version of the file is not NONE (if      my $description = $commit_msg;
     # it isn't a new file), and if it is a pm/pl/conf/tab file.      # Format title of the rss item
     # This will rdiff it against the previous version, and      # Remove space, append / and set title to /file/that/changed - oldversion/newversion
     # include that diff in the rss feed      $title[0] =~s/ /\//;
       $title[0] = $dir.'/'.$title[0];
     if (($title[1] != "NONE") && ($title[0]=~/(.*).(pm|pl|conf|tab)$/)){  
  my $tmpFile = "/tmp/diff.$$";      # Format the cvslog msg itself
  my $cmdLine = "cvs -n rdiff -u -kk -r " . $title[1] .  " -r " . $title[2] . " " . $title[0] . ">" . $tmpFile;  
  system($cmdLine);      if ($cvsDiff == 1) { 
   
  $description .= "<br /><b>Differences:</b><br /><pre>";   # If the old version of the file is not NONE (if
  open CVSDIFF, "<" . $tmpFile;   # it isn't a new file), and if it is a pm/pl/conf/tab file.
  foreach my $line (<CVSDIFF>) {   # This will rdiff it against the previous version, and
     $description .= &HTML::Entities::encode($line,'<>&"');   # include that diff in the rss feed
   
    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);
       
       $description .= "<br /><b>Differences:</b><br /><pre>";
       open CVSDIFF, "<" . $tmpFile;
       foreach my $line (<CVSDIFF>) {
    $description .= &HTML::Entities::encode($line,'<>&"');
       }
       $description .= "</pre>";
       unlink($tmpFile);   
  }   }
  $description .= "</pre>";      }
  unlink($tmpFile);     
     }       my $link = $cvslink.$title[0];
 }      if ($title[1] != "NONE") {
           $link .= '.diff?r1='.$title[1].';r2='.$title[2].';f=h';
       }
   
 $rss->add_item(      $rss->add_item(
        title => "/" . $title[0] . " - " . $title[1] . "/" . $title[2],     title => "/" . $title[0] . " - " . $title[1] . "/" . $title[2],
        author => $author,     author => $author,
        description=> $description,     description=> $description,
        mode => 'insert',     mode => 'insert',
        pubDate => $pubDate,     pubDate => $pubDate,
        link => 'http://install.loncapa.org/cgi-bin/cvsweb.cgi/'.$title[0].'.diff?r1='.$title[1].';r2='.$title[2].';f=h'     link => $link
        );     );
   }
   
 foreach my $element (@{$rss->{'items'}}) {  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 121  $rss->save($rssFeed); Line 145  $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.8  
changed lines
  Added in v.1.12


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