[LON-CAPA-cvs] cvs: loncom / loncapa_apache.conf /interface lonfeedback.pm lonrss.pm
www
lon-capa-cvs@mail.lon-capa.org
Sun, 20 Nov 2005 02:12:35 -0000
This is a MIME encoded message
--www1132452755
Content-Type: text/plain
www Sat Nov 19 21:12:35 2005 EDT
Modified files:
/loncom loncapa_apache.conf
/loncom/interface lonfeedback.pm lonrss.pm
Log:
HTML rendering of RSS
Saving my work: edit interface
--www1132452755
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20051119211235.txt"
Index: loncom/loncapa_apache.conf
diff -u loncom/loncapa_apache.conf:1.121 loncom/loncapa_apache.conf:1.122
--- loncom/loncapa_apache.conf:1.121 Thu Nov 17 16:33:21 2005
+++ loncom/loncapa_apache.conf Sat Nov 19 21:12:32 2005
@@ -1,7 +1,7 @@
##
## loncapa_apache.conf -- Apache HTTP LON-CAPA configuration file
##
-## $Id: loncapa_apache.conf,v 1.121 2005/11/17 21:33:21 www Exp $
+## $Id: loncapa_apache.conf,v 1.122 2005/11/20 02:12:32 www Exp $
##
#
@@ -115,7 +115,7 @@
ErrorDocument 500 /adm/errorhandler
</LocationMatch>
-<LocationMatch "^/+public/.*\.rss$">
+<LocationMatch "^/+(public|adm)/.*(\.rss|_rss\.html)$">
PerlAccessHandler Apache::lonacc
SetHandler perl-script
PerlHandler Apache::lonrss
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.175 loncom/interface/lonfeedback.pm:1.176
--- loncom/interface/lonfeedback.pm:1.175 Fri Nov 18 08:35:30 2005
+++ loncom/interface/lonfeedback.pm Sat Nov 19 21:12:35 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.175 2005/11/18 13:35:30 www Exp $
+# $Id: lonfeedback.pm,v 1.176 2005/11/20 02:12:35 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2315,7 +2315,7 @@
'<a href="/adm/preferences?action=changescreenname">'.&mt('Change Screenname').'</a>';
}
$discussoptions.='<br /><label><input type="checkbox" name="blog" /> '.
- &mt('Add to my course blog').'</label>';
+ &mt('Add to my public course blog').'</label>';
}
if ($msgoptions) { $msgoptions='<h2><img src="'.&Apache::loncommon::lonhttpdurl('/adm/lonMisc/feedback.gif').'" />'.&mt('Sending Messages').'</h2>'.$msgoptions; }
if ($discussoptions) {
Index: loncom/interface/lonrss.pm
diff -u loncom/interface/lonrss.pm:1.4 loncom/interface/lonrss.pm:1.5
--- loncom/interface/lonrss.pm:1.4 Fri Nov 18 14:32:05 2005
+++ loncom/interface/lonrss.pm Sat Nov 19 21:12:35 2005
@@ -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 @@
sub filterfeedname {
my $filename=shift;
- $filename=~s/\.rss$//;
+ $filename=~s/(\_rss\.html|\.rss)$//;
$filename=~s/\W//g;
return $filename;
}
@@ -79,9 +79,11 @@
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.='<li><a href="'.$url.'">'.
- $feednames{$feed}.'</a><br /><tt>'.$url.'</tt></li>';
+ my $feedurl='feed://'.$ENV{'HTTP_HOST'}.'/public/'.$udom.'/'.$uname.'/'.$feed.'.rss';
+ my $htmlurl='http://'.$ENV{'HTTP_HOST'}.'/public/'.$udom.'/'.$uname.'/'.$feed.'_rss.html';
+ $feeds.='<li>'.$feednames{$feed}.
+ '<br />HTML: <a href="'.$htmlurl.'"><tt>'.$htmlurl.'</tt></a>'.
+ '<br />RSS: <a href="'.$feedurl.'"><tt>'.$feedurl.'</tt></a></li>';
}
}
if ($feeds) {
@@ -134,21 +136,46 @@
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("<rss version='2.0' xmlns:dc='http://purl.org/dc/elements/1.1'>\n<channel>".
- "\n<link>http://".$ENV{'HTTP_HOST'}.'/</link>'.
- "\n<description>".&mt('An RSS Feed provided by the LON-CAPA Learning Content Management System').'</description>');
+ if ($html) {
+ $r->print(&Apache::lonxml::xmlbegin().&Apache::loncommon::bodytag
+ ($displayfeedname,'','','',$udom,
+ $env{'form.register'}));
+ } else {
+ $r->print("<rss version='2.0' xmlns:dc='http://purl.org/dc/elements/1.1'>\n<channel>".
+ "\n<link>http://".$ENV{'HTTP_HOST'}.'/public/'.$udom.'/'.$uname.'/'.
+ $filterfeedname.'_rss.html</link>'.
+ "\n<description>".
+ &mt('An RSS Feed provided by the LON-CAPA Learning Content Management System').
+ '</description>');
+ }
# Is this user for real?
my $homeserver=&Apache::lonnet::homeserver($uname,$udom);
if ($homeserver eq 'no_host') {
- $r->print('<title>'.&mt('No feed available').'</title>');
+ $r->print(($html?'<h3>':'<title>').&mt('No feed available').($html?'</h3>':'</title>'));
} else {
# Course or user?
my $name='';
@@ -158,7 +185,10 @@
} else {
$name=&Apache::loncommon::nickname($uname,$udom);
}
- $r->print("\n<title>".&mt('LON-CAPA RSS Feed "[_1]" for [_2]',$displayfeedname,$name).'</title>');
+ $r->print("\n".
+ ($html?'<h3>':'<title>').
+ &mt('LON-CAPA Feed "[_1]" for [_2]',$displayfeedname,$name).
+ ($html?'</h3>'.($edit?'<form method="post">':'').'<ul>':'</title>'));
# Render private items?
my $viewpubliconly=1;
if (($env{'user.name'} eq $uname) && ($env{'user.domain'} eq $udom)) {
@@ -169,22 +199,54 @@
foreach my $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>"."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'}."' />");
+ if ($edit) {
+ my %lt=&Apache::lonlocal::texthash('public' => 'public',
+ 'private' => 'private',
+ 'hidden' => 'hidden',
+ 'delete' => 'delete');
+ my %status=();
+ $status{$newsfeed{$id.'_status'}}='checked="checked"';
+ $r->print(<<ENDEDIT);
+<li>
+<input name='$id\_modified' type='hidden' value='0' />
+<label><input name='$id\_status' type="radio" value="public" $status{'public'}> $lt{'public'}</label>
+
+<label><input name='$id\_status' type="radio" value="private" $status{'private'}> $lt{'private'}</label>
+
+<label><input name='$id\_status' type="radio" value="hidden" $status{'hidden'}> $lt{'hidden'}</label>
+
+<label><input name='$id\_status' type="radio" value="delete"> $lt{'delete'}</label>
+<br />
+<input name='$id\_title' type='text' size='80' value='$newsfeed{$id.'_title'}' /><br />
+<textarea name='$id\_description' rows="6" cols="80">$newsfeed{$id.'_description'}</textarea>
+</li>
+ENDEDIT
+ } else {
+ if (($newsfeed{$id.'_status'} ne 'public') && ($viewpubliconly)) { next; }
+ if ($newsfeed{$id.'_status'} eq 'hidden') { next; }
+ $r->print("\n".($html?"\n<li><b>":"<item>\n<title>").$newsfeed{$id.'_title'}.
+ ($html?"</b><br />\n":"</title>\n<description>").
+ $newsfeed{$id.'_description'}.
+ ($html?"<br />\n<a href='":"</description>\n<link>").
+ "http://".$ENV{'HTTP_HOST'}.
+ $newsfeed{$id.'_link'}.
+ ($html?("'>".&mt('Read more')."</a><br />\n"):"</link>\n"));
+ if ($newsfeed{$id.'_enclosureurl'}) {
+ $r->print(($html?"<a href='":"\n<enclosure url='").
+ $newsfeed{$id.'_enclosureurl'}."' length='".$newsfeed{$id.'_enclosurelength'}.
+ "' type='".$newsfeed{$id.'_enclosuretype'}.($html?"'>".&mt('Enclosure')."</a>":"' />"));
+ }
+ if ($html) {
+ $r->print("\n<hr /></li>\n");
+ } else {
+ $r->print("\n<guid isPermaLink='false'>".$id.$filterfeedname.'_'.$udom.'_'.$uname."</guid></item>\n");
+ }
}
- $r->print("\n<guid isPermaLink='false'>".$id.$filterfeedname.'_'.$udom.'_'.$uname."</guid></item>\n");
}
}
}
- $r->print("\n</channel></rss>\n");
+ $r->print("\n".($html?'</ul>'.($edit?'</form>':'').'</body></html>':'</channel></rss>'."\n"));
return OK;
}
-
1;
__END__
--www1132452755--