[LON-CAPA-cvs] cvs: loncom /interface lonrss.pm
www
lon-capa-cvs@mail.lon-capa.org
Wed, 10 May 2006 15:52:13 -0000
This is a MIME encoded message
--www1147276333
Content-Type: text/plain
www Wed May 10 11:52:13 2006 EDT
Modified files:
/loncom/interface lonrss.pm
Log:
Slowly starting to fix things in RSS - still not working.
--www1147276333
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20060510115213.txt"
Index: loncom/interface/lonrss.pm
diff -u loncom/interface/lonrss.pm:1.17 loncom/interface/lonrss.pm:1.18
--- loncom/interface/lonrss.pm:1.17 Sat Apr 22 16:58:32 2006
+++ loncom/interface/lonrss.pm Wed May 10 11:52:11 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network
# RSS Feeder
#
-# $Id: lonrss.pm,v 1.17 2006/04/22 20:58:32 www Exp $
+# $Id: lonrss.pm,v 1.18 2006/05/10 15:52:11 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -90,7 +90,7 @@
my $htmlurl='http://'.$ENV{'HTTP_HOST'}.'/'.$mode.'/'.$udom.'/'.$uname.'/'.$feed.'_rss.html';
$feeds.='<li>'.$feednames{$feed}.
'<br />'.($edit?&mt('Edit'):'HTML').': <a href="'.$htmlurl.'"><tt>'.$htmlurl.'</tt></a>'.
- ($edit?'':'<br />RSS: <a href="'.$feedurl.'"><tt>'.$feedurl.'</tt></a>').'</li>';
+ '<br />RSS: <a href="'.$feedurl.'"><tt>'.$feedurl.'</tt></a></li>';
}
}
if ($feeds) {
@@ -199,7 +199,7 @@
'force_register' =>
$env{'form.register'}}).
&changed_js());
- } else {
+ } else { # render RSS
$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>'.
@@ -208,21 +208,6 @@
'</description>');
}
# Do we have stuff to store?
- if ($edit) {
- my %newsfeed=&Apache::lonnet::dump($feedname,$udom,$uname);
- foreach my $entry (sort(keys(%newsfeed)),$env{'form.newid'}.'_status') {
- if ($entry=~/^(\d+)\_status$/) {
- my $id=$1;
- if ($env{'form.'.$id.'_modified'}) {
- &editentry($id,$uname,$udom,$feedname,
- $env{'form.'.$id.'_title'},
- $env{'form.'.$id.'_description'},
- $env{'form.'.$id.'_url'},
- $env{'form.'.$id.'_status'});
- }
- }
- }
- }
my $newid = &get_new_feed_id();
# Is this user for real?
my $homeserver=&Apache::lonnet::homeserver($uname,$udom);
@@ -231,7 +216,7 @@
}
if ($homeserver eq 'no_host') {
$r->print(($html?'<h3>':'<title>').&mt('No feed available').($html?'</h3>':'</title>'));
- } else {
+ } else { # is indeed a user
# Course or user?
my $name='';
if ($uname=~/^\d/) {
@@ -240,33 +225,58 @@
} else {
$name=&Apache::loncommon::nickname($uname,$udom);
}
- $r->print("\n".
- ($html?'<h3>':'<title>').
- &mt('LON-CAPA Feed "[_1]" for [_2]',$displayfeedname,$name).
- ($html?'</h3>'.($edit?'<form method="post"><br />'.
- &mt('Name of blog/journal').
- ': <input type="text" size="50" name="newblogname" value="'.
- $displayfeedname.'" />':'').'<ul>':'</title>'));
+ if ($displayfeedname) { # this is an existing feed
+# Anything to store?
+ if ($edit) {
+ my %newsfeed=&Apache::lonnet::dump($feedname,$udom,$uname);
+ foreach my $entry (sort(keys(%newsfeed)),$env{'form.newid'}.'_status') {
+ if ($entry=~/^(\d+)\_status$/) {
+ my $id=$1;
+ if ($env{'form.'.$id.'_modified'}) {
+ &editentry($id,$uname,$udom,$feedname,
+ $env{'form.'.$id.'_title'},
+ $env{'form.'.$id.'_description'},
+ $env{'form.'.$id.'_url'},
+ $env{'form.'.$id.'_status'});
+ }
+ }
+ }
+ if ($env{'form.newblogname'} ne $displayfeedname) {
+ &Apache::lonnet::put('nohist_all_rss_feeds',{ $filterfeedname => $env{'form.newblogname'} },$udom,$uname);
+ $displayfeedname=&displayfeedname($filename,$uname,$udom);
+ }
+ } #done storing
+
+ $r->print("\n".
+ ($html?'<h3>':'<title>').
+ &mt('LON-CAPA Feed "[_1]" for [_2]',$displayfeedname,$name).
+ ($html?'</h3>'.($edit?'<form method="post"><br />'.
+ &mt('Name of blog/journal').
+ ': <input type="text" size="50" name="newblogname" value="'.
+ $displayfeedname.'" />':'').'<ul>':'</title>'));
# Render private items?
- my $viewpubliconly=1;
- if (($env{'user.name'} eq $uname) && ($env{'user.domain'} eq $udom)) {
- $viewpubliconly=0;
- }
+ my $viewpubliconly=1;
+ if (($env{'user.name'} eq $uname) && ($env{'user.domain'} eq $udom)) {
+ $viewpubliconly=0;
+ }
# Get feed items
- my %newsfeed=&Apache::lonnet::dump($feedname,$udom,$uname);
- foreach my $entry (sort(keys(%newsfeed)),$newid.'_status') {
- if ($entry=~/^(\d+)\_status$/) {
- my $id=$1;
- if ($edit) {
- my %lt=&Apache::lonlocal::texthash('public' => 'public',
- 'private' => 'private',
- 'hidden' => 'hidden',
- 'delete' => 'delete',
- 'store' => 'Store changes');
- my %status=();
- unless ($newsfeed{$id.'_status'}) { $newsfeed{$id.'_status'}='public'; }
- $status{$newsfeed{$id.'_status'}}='checked="checked"';
- $r->print(<<ENDEDIT);
+ my %newsfeed=&Apache::lonnet::dump($feedname,$udom,$uname);
+ foreach my $entry (sort(keys(%newsfeed)),$newid.'_status') {
+ if ($entry=~/^(\d+)\_status$/) { # is an entry
+ my $id=$1;
+ if ($edit) {
+ my %lt=&Apache::lonlocal::texthash('public' => 'public',
+ 'private' => 'private',
+ 'hidden' => 'hidden',
+ 'delete' => 'delete',
+ 'store' => 'Store changes',
+ 'title' => 'Title',
+ 'link' => 'Link',
+ 'description' => 'Description');
+ my %status=();
+ unless ($newsfeed{$id.'_status'}) { $newsfeed{$id.'_status'}='public'; }
+ $status{$newsfeed{$id.'_status'}}='checked="checked"';
+ $r->print(<<ENDEDIT);
<li>
<label><input name='$id\_modified' type='checkbox' value="modified" /> $lt{'store'}</label>
@@ -278,43 +288,53 @@
<label><input name='$id\_status' type="radio" value="deleted" onClick="changed(this.form,'$id');" /> $lt{'delete'}</label>
<br />
-<input name='$id\_title' type='text' size='80' value='$newsfeed{$id.'_title'}' onChange="changed(this.form,'$id');" /><br />
+$lt{'title'}:
+<input name='$id\_title' type='text' size='60' value='$newsfeed{$id.'_title'}' onChange="changed(this.form,'$id');" /><br />
+$lt{'description'}:<br />
<textarea name='$id\_description' rows="6" cols="80" onChange="changed(this.form,'$id');">$newsfeed{$id.'_description'}</textarea><br />
-<input name='$id\_link' type='text' size='80' value='$newsfeed{$id.'_link'}' onChange="changed(this.form,'$id');" />
+$lt{'link'}:
+<input name='$id\_link' type='text' size='60' value='$newsfeed{$id.'_link'}' onChange="changed(this.form,'$id');" />
<hr /></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"));
+ } else { # not in edit mode, just displaying
+ 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"));
# Enclosure? Get stats
- if ($newsfeed{$id.'_enclosureurl'}) {
- my @stat=&Apache::lonnet::stat_file($newsfeed{$id.'_enclosureurl'});
- if ($stat[7]) {
+ if ($newsfeed{$id.'_enclosureurl'}) {
+ my @stat=&Apache::lonnet::stat_file($newsfeed{$id.'_enclosureurl'});
+ if ($stat[7]) {
# Has non-zero length (and exists)
- my $enclosuretype=$newsfeed{$id.'_enclosetype'};
- $r->print(($html?"<a href='":"\n<enclosure url='").
- $newsfeed{$id.'_enclosureurl'}."' length='".$stat[7].
- "' type='".$enclosuretype.($html?"'>".&mt('Enclosure')."</a>":"' />"));
+ my $enclosuretype=$newsfeed{$id.'_enclosetype'};
+ $r->print(($html?"<a href='":"\n<enclosure url='").
+ $newsfeed{$id.'_enclosureurl'}."' length='".$stat[7].
+ "' type='".$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");
- }
+ if ($html) { # is HTML
+ $r->print("\n<hr /></li>\n");
+ } else { # is RSS
+ $r->print("\n<guid isPermaLink='false'>".$id.$filterfeedname.'_'.$udom.'_'.$uname."</guid></item>\n");
+ }
+ } # end of "in edit mode"
+ } # end of rendering a real entry
+ } # end of loop through all keys
+ if ($html) {
+ $r->print('</ul>');
+ if ($edit) {
+ $r->print('<input type="hidden" name="newid" value="'.$newid.'"/><input type="submit" value="'.&mt('Store Marked Changes').'" />');
}
}
- }
- }
- $r->print("\n".($html?'</ul>'.($edit?'<input type="hidden" name="newid" value="'.$newid.'"/><input type="submit" value="'.&mt('Store Marked Changes').'" /></form>':'').&Apache::loncommon::end_page():'</channel></rss>'."\n"));
+ } # was a real display feedname
+ $r->print(($html?'</form>'.&Apache::loncommon::end_page():'</channel></rss>'."\n"));
+ } # a real user
return OK;
-}
+} # end handler
1;
__END__
--www1147276333--