Skip to content

Commit

Permalink
index.cgi: trim really long rss entries down to size.
Browse files Browse the repository at this point in the history
If an entry gets too long, cut the middle part out. The beginning and end
tend to be the interesting partsy anyway.  In any case, you can click on the
entry itself to read the full log.
  • Loading branch information
apenwarr committed Aug 23, 2008
1 parent a09571d commit 9c92dae
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions index.cgi
Expand Up @@ -51,6 +51,20 @@ sub stripwhite($)
return $s;
}

sub shorten($$)
{
my ($s, $len) = @_;
if (length($s) > $len) {
return substr($s, 0, $len/2)
. "\n\n ... PARTS OMITTED FROM RSS FEED ...\n\n"
. substr($s, length($s)-$len/2);
} else {
return $s;
}
}





my $url = url();
Expand Down Expand Up @@ -81,6 +95,7 @@ sub rss_item($$$$)
my $date = strftime("%a, %d %b %Y %H:%M:%S %z", localtime($datecode));
$description =~ s/\&/\&/g;
$description =~ s/</&lt;/g;
$description = shorten($description, 10240);

die unless utf8::valid($description . $title . $date . $link);

Expand Down

0 comments on commit 9c92dae

Please sign in to comment.