--- loncom/interface/lonrss.pm 2005/11/18 19:32:05 1.4
+++ loncom/interface/lonrss.pm 2005/11/20 02:12:35 1.5
@@ -1,7 +1,7 @@
# The LearningOnline Network
# RSS Feeder
#
-# $Id: lonrss.pm,v 1.4 2005/11/18 19:32:05 albertel Exp $
+# $Id: lonrss.pm,v 1.5 2005/11/20 02:12:35 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -38,7 +38,7 @@ use Apache::lonhtmlcommon;
sub filterfeedname {
my $filename=shift;
- $filename=~s/\.rss$//;
+ $filename=~s/(\_rss\.html|\.rss)$//;
$filename=~s/\W//g;
return $filename;
}
@@ -79,9 +79,11 @@ sub advertisefeeds {
my %feednames=&Apache::lonnet::dump('nohist_all_rss_feeds',$udom,$uname);
foreach my $feed (sort(keys(%feednames))) {
if ($feed!~/^error\:/) {
- my $url='feed://'.$ENV{'HTTP_HOST'}.'/public/'.$udom.'/'.$uname.'/'.$feed.'.rss';
- $feeds.='
'.
- $feednames{$feed}.' '.$url.' ';
+ my $feedurl='feed://'.$ENV{'HTTP_HOST'}.'/public/'.$udom.'/'.$uname.'/'.$feed.'.rss';
+ my $htmlurl='http://'.$ENV{'HTTP_HOST'}.'/public/'.$udom.'/'.$uname.'/'.$feed.'_rss.html';
+ $feeds.=''.$feednames{$feed}.
+ ' HTML: '.$htmlurl.' '.
+ ' RSS: '.$feedurl.' ';
}
}
if ($feeds) {
@@ -134,21 +136,46 @@ sub changestatus {
sub handler {
my $r = shift;
- &Apache::loncommon::content_type($r,'application/rss+xml');
+
+ my $edit=0;
+ my $html=0;
+ my (undef,$mode,$udom,$uname,$filename)=split(/\//,$r->uri);
+ if (($mode eq 'adm') && ($env{'user.name'} eq $uname) && ($env{'user.domain'} eq $udom)) {
+ $edit=1;
+ $html=1;
+ }
+ if ($filename=~/\.html$/) {
+ $html=1;
+ }
+ if ($html) {
+ &Apache::loncommon::content_type($r,'text/html');
+ } else {
+# Workaround Mozilla/Firefox
+# &Apache::loncommon::content_type($r,'application/rss+xml');
+ &Apache::loncommon::content_type($r,'text/xml');
+ }
$r->send_http_header;
return OK if $r->header_only;
- my (undef,undef,$udom,$uname,$filename)=split(/\//,$r->uri);
my $filterfeedname=&filterfeedname($filename);
my $feedname=&feedname($filename);
my $displayfeedname=&displayfeedname($filename,$uname,$udom);
- $r->print("\n".
- "\n http://".$ENV{'HTTP_HOST'}.'/'.
- "\n".&mt('An RSS Feed provided by the LON-CAPA Learning Content Management System').' ');
+ if ($html) {
+ $r->print(&Apache::lonxml::xmlbegin().&Apache::loncommon::bodytag
+ ($displayfeedname,'','','',$udom,
+ $env{'form.register'}));
+ } else {
+ $r->print("\n".
+ "\n http://".$ENV{'HTTP_HOST'}.'/public/'.$udom.'/'.$uname.'/'.
+ $filterfeedname.'_rss.html'.
+ "\n".
+ &mt('An RSS Feed provided by the LON-CAPA Learning Content Management System').
+ ' ');
+ }
# Is this user for real?
my $homeserver=&Apache::lonnet::homeserver($uname,$udom);
if ($homeserver eq 'no_host') {
- $r->print(''.&mt('No feed available').' ');
+ $r->print(($html?'':'').&mt('No feed available').($html?' ':''));
} else {
# Course or user?
my $name='';
@@ -158,7 +185,10 @@ sub handler {
} else {
$name=&Apache::loncommon::nickname($uname,$udom);
}
- $r->print("\n".&mt('LON-CAPA RSS Feed "[_1]" for [_2]',$displayfeedname,$name).' ');
+ $r->print("\n".
+ ($html?'':'').
+ &mt('LON-CAPA Feed "[_1]" for [_2]',$displayfeedname,$name).
+ ($html?' '.($edit?' \n");
+ $r->print("\n".($html?''.($edit?'':'').'