[LON-CAPA-cvs] cvs: CVSROOT / cvs2rss.pl

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 14 Oct 2005 14:35:44 -0000


albertel		Fri Oct 14 10:35:44 2005 EDT

  Modified files:              
    /CVSROOT	cvs2rss.pl 
  Log:
  - pubData in items seems to not work well
  - update channel info after parsing the existing file
  - escape entiites in comments
  
  
Index: CVSROOT/cvs2rss.pl
diff -u CVSROOT/cvs2rss.pl:1.3 CVSROOT/cvs2rss.pl:1.4
--- CVSROOT/cvs2rss.pl:1.3	Wed Oct 12 12:50:42 2005
+++ CVSROOT/cvs2rss.pl	Fri Oct 14 10:35:43 2005
@@ -46,18 +46,21 @@
 my @title=split(",",$ARGV[0]);
 
 my $rss = new XML::RSS(version => '2.0');
+
+# If rssFeed exists, parse it
+if (-r "$rssFeed") {
+	$rss->parsefile($rssFeed);
+}
+
 $rss->channel(
 	title=> $channelTitle,
 	link => $channelLink,
 	language => 'en',
 	description => $channelTitle,
-	copyright => '(c) 2005 MSU Board of Trustees.'
+	copyright => '(c) 2005 MSU Board of Trustees.',
+	pubDate => $pubDate 
 );
 
-# If rssFeed exists, parse it
-if (-r "$rssFeed") {
-	$rss->parsefile($rssFeed);
-}
 
 # Limit entries in the feed to $numEntries
 pop(@{$rss->{'items'}}) while (@{$rss->{'items'}} >= $numEntries);
@@ -70,7 +73,7 @@
 while (<STDIN>) {
 	chomp($_);
 	if ($_=~/^[A-Z].*:\s*$/) {
-		$_ = "<br /><b>" . $_ . "</b><br />";
+		$_ = "<br /><b>" . &HTML::Entities::encode($_,'<>&"') . "</b><br />";
 	}
 	else {
 		$_ .= "<br />";
@@ -100,9 +103,9 @@
 $rss->add_item(
 	title => "/" . $title[0] . " - " . $title[1] . "/" . $title[2],
 	author => $author,
-	pubDate => $pubDate, 
 	description=> $description,
-	mode => 'insert'
+	mode => 'insert',
+	link => 'http://install.loncapa.org/cgi-bin/cvsweb.cgi/'.$title[0]
 );		
 
 foreach my $element (@{$rss->{'items'}}) {