[LON-CAPA-cvs] cvs: loncom /interface lonrss.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Fri, 18 Nov 2005 19:11:06 -0000
albertel Fri Nov 18 14:11:06 2005 EDT
Modified files:
/loncom/interface lonrss.pm
Log:
- style
- xml was invalid (<link> must be full uri, <guid> needs isPermaLink set to false if it isn't a link)
- scope feedcounter
Index: loncom/interface/lonrss.pm
diff -u loncom/interface/lonrss.pm:1.2 loncom/interface/lonrss.pm:1.3
--- loncom/interface/lonrss.pm:1.2 Fri Nov 18 08:35:30 2005
+++ loncom/interface/lonrss.pm Fri Nov 18 14:11:06 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network
# RSS Feeder
#
-# $Id: lonrss.pm,v 1.2 2005/11/18 13:35:30 www Exp $
+# $Id: lonrss.pm,v 1.3 2005/11/18 19:11:06 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,8 +36,6 @@
use Apache::lonlocal;
use Apache::lonhtmlcommon;
-my $feedcounter=0;
-
sub filterfeedname {
my $filename=shift;
$filename=~s/\.rss$//;
@@ -79,11 +77,11 @@
my ($uname,$udom)=@_;
my $feeds='';
my %feednames=&Apache::lonnet::dump('nohist_all_rss_feeds',$udom,$uname);
- foreach (sort keys %feednames) {
- if ($_!~/^error\:/) {
- my $url='feed://'.$ENV{'HTTP_HOST'}.'/public/'.$udom.'/'.$uname.'/'.$_.'.rss';
+ foreach my $feed (sort(keys(%feednames))) {
+ if ($feed!~/^error\:/) {
+ my $url='feed://'.$ENV{'HTTP_HOST'}.'/public/'.$udom.'/'.$uname.'/'.$feed.'.rss';
$feeds.='<li><a href="'.$url.'">'.
- $feednames{$_}.'</a><br /><tt>'.$url.'</tt></li>';
+ $feednames{$feed}.'</a><br /><tt>'.$url.'</tt></li>';
}
}
if ($feeds) {
@@ -93,10 +91,13 @@
}
}
-sub addentry {
- $feedcounter++;
- my $id=time.'00000'.$$.'00000'.$feedcounter;
- return &editentry($id,@_);
+{
+ my $feedcounter;
+ sub addentry {
+ $feedcounter++;
+ my $id=time.'00000'.$$.'00000'.$feedcounter;
+ return &editentry($id,@_);
+ }
}
sub editentry {
@@ -133,7 +134,7 @@
sub handler {
my $r = shift;
- &Apache::loncommon::content_type($r,'text/xml');
+ &Apache::loncommon::content_type($r,'application/rss+xml');
$r->send_http_header;
return OK if $r->header_only;
@@ -165,19 +166,19 @@
}
# Get feed items
my %newsfeed=&Apache::lonnet::dump($feedname,$udom,$uname);
- foreach (sort keys %newsfeed) {
- if ($_=~/^(\d+)\_status$/) {
+ foreach $entry (sort(keys(%newsfeed))) {
+ if ($entry=~/^(\d+)\_status$/) {
my $id=$1;
if (($newsfeed{$id.'_status'} ne 'public') && ($viewpubliconly)) { next; }
if ($newsfeed{$id.'_status'} eq 'hidden') { next; }
$r->print("\n<item>\n<title>".$newsfeed{$id.'_title'}."</title>\n<description>".
- $newsfeed{$id.'_description'}."</description>\n<link>".
+ $newsfeed{$id.'_description'}."</description>\n<link>"."http://".$ENV{'HTTP_HOST'}.
$newsfeed{$id.'_link'}."</link>\n");
if ($newsfeed{$id.'_enclosureurl'}) {
$r->print("\n<enclosure url='".$newsfeed{$id.'_enclosureurl'}."' length='".$newsfeed{$id.'_enclosurelength'}.
"' type='".$newsfeed{$id.'_enclosuretype'}."' />");
}
- $r->print("\n<guid>".$id.$filterfeedname.'_'.$udom.'_'.$uname."</guid></item>\n");
+ $r->print("\n<guid isPermaLink='false'>".$id.$filterfeedname.'_'.$udom.'_'.$uname."</guid></item>\n");
}
}
}