[$ # Display a preview of the selected channel
# This involves adding the channel to our list of channels at the top of the page,
# then removing it at the bottom.
use URI::Escape;
# Try to grab the channel
my $tempchannel = param('xmlurl');
my $found = 0;
if (add_url($tempchannel)) {
# Got the temp channel -- now display it.
my @channels = get_my_sorted_channels("date_downloaded", "reversed_data");
# get the user's window target preference (which controls
# whether links should open up in the current or a new window.
my $link_target = get_setting( "user_link_target" );
# for each channel, parse and display.
foreach my $channel (@channels) {
# skip unless this is the right channel
next unless ( uc($channel->{xmlurl}) eq uc(param('xmlurl')) );
$found = 1;
# and then load all the channel data. (Note that it's possible there isn't any data.)
my $data = load_channel($channel->{filename}, $channel->{xmlurl}); next unless $data;
# Only display channel data if it's there. Otherwise show message
if ($channel->{date_downloaded} || $data) {
to_browser(qq{
Preview of the channel "$channel->{title}" |
});
# if there are no channel items, say so.
if ( not defined($data->{item}) or scalar @{$data->{item}} <= 0) {
to_browser(qq{
This channel has no items that AmphetaDesk can display.
\n});
}
# each of the channel items.
foreach my $item (@{$data->{item}}) {
# check to see if mod_content is used, which is a module to RSS 1.0
# allowing more data in a feed as well as embedded HTML. this is NOT
# a full implementation, as it'll only support CDATA's. if it does
# exist, then we stick the data into our $item->{description}.
my $rdf_value = $item->{"content:items"}{"rdf:Bag"}{"rdf:li"}{"content:item"}{"rdf:value"}
if defined($item->{"content:items"}{"rdf:Bag"}{"rdf:li"}{"content:item"}{"rdf:value"});
$item->{description} = $rdf_value if defined($rdf_value);
# display the actual item.
to_browser(qq{
\n});
to_browser(qq{
\n});
to_browser(qq{ $item->{description} \n}) if $item->{description};
to_browser(qq{
\n});
}
} else {
to_browser(qq{
There is no available content for this feed.
\n});
}
}
# Remove the temp channel
del_url($tempchannel);
}
unless ($found) {
# unable to get the temp channel
to_browser(qq{
Unable to build a preview of the channel. Sorry! |
});
}
$OUT = send_to_browser;
$]