[$ include( catfile( get_setting("dir_templates"), "tpl_header.html") ) $]


<!-- and I say to thee heathens, let there be pointless tables! -->
<br /><table cellspacing="8" cellpadding="4" border="0" width="90%" align="center"><tr align="center">
   <td><strong>Below are the newest items from your [$ count_my_channels $] channels, ordered by channel modification date.</strong>
   <br /><small><font color="#666666">A "channel" (also "feed") is a website offering its headlines, news or content in a simplistic format.</font></small></td>
</tr></table>


 [$ # display each channel that has been successfully downloaded.
    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) {

       # stuck inside our loop to load the page faster, as well
       # as to prevent runaway <pre> tags from messing with our output.
       to_browser(qq{<!-- begin our silly table that creates a grey highlight. -->});
       to_browser(qq{<table width="90%" cellpadding="0" cellspacing="0" border="0" align="center"><tr><td bgcolor="#cccccc" align="center">});

       # and then load all the channel data, moving on if nothing's there.
       my $data = load_channel($channel->{filename}, $channel->{xmlurl}); next unless $data;

       # if there's nothing in our date_downloaded, then we maybe
       # coming from an importing, so we'll skip this feed for now.
       next unless $channel->{date_downloaded};

       # the channel header. I go through insane amounts
       # of effort to make sure the result HTML has perfect
       # line spacing and indentation. You certainly don't
       # have to mimick my anality. (Moortal KombutTT!).
       to_browser(qq{\n});
       to_browser(qq{       <table width="100%" cellpadding="5" cellspacing="1" border="0">\n});
       to_browser(qq{         <tr valign="top"><td width="15" bgcolor="#ffcc33">&nbsp;</td>\n});
       to_browser(qq{           <td bgcolor="#ffcc33">\n});
       to_browser(qq{             <table width="100%"><tr>\n});
       to_browser(qq{               <td align="center"><a href="$channel->{htmlurl}" target="$link_target"><img src="images/globe.gif" alt="Go To The '$channel->{title}' Site." title="Go To The '$channel->{title}' Site." width="13" height="13" border="0" align="center" /></a></td>\n});
       to_browser(qq{               <td width="90%" align="left"><strong>$channel->{title}</strong><br /><small><font color="#333333">Last Downloaded: $channel->{date_downloaded}.</font></small></td>\n});

       # is there an email address associated with this site?
       if ($channel->{email}) { to_browser(qq{               <td align="center"><a href="mailto:$channel->{email}"><img src="images/email.gif" alt="Send an email to '$channel->{title}'." title="Send an email to '$channel->{title}'" width="14" height="10" border="0" align="center" /></a></td>\n}); }

       # continue on with the rest of our header.
       # we create an encoded 'xmlurl' for our del_url.
       # this is so we don't get confused with channel
       # query_strings being interpreted as part of our own.
       my $encoded_xmlurl = encode_to_dec($channel->{xmlurl});
       to_browser(qq{               <td align="center"><a href="$channel->{xmlurl}" target="$link_target"><img src="images/xml.gif" alt="View The Raw XML Source Of '$channel->{title}'." title="View The Raw XML Source Of '$channel->{title}'" width="36" height="14" border="0" align="center" /></a></td>\n});
       to_browser(qq{               <td align="center"><a href="index.html?del_url=$encoded_xmlurl&amp;go=1" onClick="popupWindow('popup.html?del_url=$encoded_xmlurl&amp;go=1'); return false;"><img src="images/delete.gif" alt="Remove '$channel->{title}'." title="Remove '$channel->{title}'." width="13" height="13" border="0" align="center" /></a></td>\n});
       to_browser(qq{             </tr></table>\n});
       to_browser(qq{         </td></tr>\n\n});

       # if there are no channel items, say so.
       if ( not defined($data->{item}) or scalar @{$data->{item}} <= 0) {
          to_browser(qq{         });
          to_browser(qq{<tr><td width="15" bgcolor="#ffffff">&nbsp;</td><td bgcolor="#ffffff" align="left">});
          to_browser(qq{ This channel has no items that AmphetaDesk can display. });
          to_browser(qq{</td></tr>\n});
       }

       # each of the channel items.
       foreach my $item (@{$data->{item}}) {

          # is mod_content's content:encoded used?
          $item->{description} = $item->{"content:encoded"} if defined($item->{"content:encoded"});

          # display the actual item.
          to_browser(qq{         });
          to_browser(qq{<tr><td width="15" bgcolor="#ffffff">&nbsp;</td><td bgcolor="#ffffff" align="left">});
          to_browser(qq{<a href="$item->{link}" target="$link_target">}) if $item->{link};
          to_browser(qq{$item->{title}}) if $item->{title}; to_browser(qq{</a>}) if $item->{link};
          to_browser(qq{ $item->{description} }) if $item->{description};
          to_browser(qq{</td></tr>\n});
       }
 
       # finish the table, both for
       # our channel, as well as our
       # grey hilighter (whee!).
       to_browser(qq{       </table>\n});
       to_browser(qq{<!-- end silliness -->});
       to_browser(qq{</td></tr></table>});
    }

    # and spit it out.
    $OUT = send_to_browser;
 $]


<!-- and I utter anew, let there be yet another pointless table! -->
<table cellspacing="8" cellpadding="4" border="0" width="90%" align="center"><tr align="center">
   <td><small><font color="#666666">A "channel" (also "feed") is a website offering its headlines, news or content in a simplistic format.</font></small>
   <br /><strong>Above are the newest items from your [$ count_my_channels $] channels, ordered by channel modification date.</strong></td>
</tr></table>


[$ include( catfile( get_setting("dir_templates"), "tpl_footer.html") ) $]
