Specify Amount of Item Text Shown
Status: Beta
Brought to you by:
morbus
Along the lines of one of the suggestions in Feature
Request #584673, how about allowing users to choose
how much of each item to show?
The "My Settings" page could have a choice list
with "Titles Only", "First 240 Characters", and "Full
Text". Just that much of each item would then be
shown to the user. It would go a long way to allowing a
person with multiple feeds to scan past articles they've
already read, and you wouldn't need to play any games
with dynamic pages or CGI.
Logged In: YES
user_id=69804
This is already possible, and has been discussed on the
ampheta-develop mailing list. Ultimately, you yourself can
do this right now by editing templates/default/index.html,
looking for:
# each of the channel items.
foreach my $item (@{$data->{item}}) {
and adding right after it:
$item->{description} = substr(0, 240, $item->{description});
This will cut the description down to 240 characters. Be
forewarned, however, this isn't HTML smart. If the
description contains HTML, there's a good chance you'll cut
a tag in the middle, thus corrupting the remainder of the
AmphetaDesk web page. Either way, there are indeed plans to
make this a user-configurable choice without modifying files.
Likewise, "Titles Only" is a simple matter of looking for:
to_browser(qq{ $item->{description} }) if $item->{description};
and putting a # in front of that line.
Logged In: YES
user_id=492951
I knew it would be something simple... I just wanted to make
certain that someone posted the request in case you hadn't
thought of it yourself. Thank you very much for this software.
It rocks!
Logged In: YES
user_id=754676
As far as the tag problem when grabbing a chunk of
characters. You can follow up the substr code below with
something like:
$_=$item->{description};
$item->{description} = m%\A(.*)(?:<[^/][^>]*>[^>]*)\Z%sm ?
$1 : $_;
That should take care of any partial tags as well as any
tags who are missing their closing twin (like <B> when </B>
or part of it is missing). However, this doesn't handle
cases where there are nested tags very well.
Later,
Peter