This one here is just repackaged rss2html from XML::RSS module,
made to fit style suggested by John Leonard.
I still think it would be better to make those applets as regular perl
modules - that way it's trivial to precompile them into apache and solves
namespace problems.
--
Dariusz Pietrzak
snafu
<%
# -----------------------------------------------------------------------------------
#
# - rss.inc - Apache::ASP applet
# -
#
# -----------------------------------------------------------------------------------
#
# INCLUDES
use strict;
use XML::RSS;
use LWP::Simple;
# Declare variables
my $content;
my $file;
# MAIN
# get the command-line argument
my ($arg) = @_;
# create new instance of XML::RSS
my $rss = new XML::RSS;
# argument is a URL
if ($arg=~ /http:/i) {
$content = get($arg);
die "Could not retrieve $arg" unless $content;
# parse the RSS content
$rss->parse($content);
# argument is a file
} else {
$file = $arg;
die "File \"$file\" does't exist.\n" unless -e $file;
# parse the RSS file
$rss->parsefile($file);
}
# print the HTML channel
&print_html($rss);
# SUBROUTINES
sub print_html {
my $rss = shift;
print <<HTML;
<table bgcolor="#000000" border="0" width="200"><tr><td>
<TABLE CELLSPACING="1" CELLPADDING="4" BGCOLOR="#FFFFFF" BORDER=0 width="100%">
<tr>
<td valign="middle" align="center" bgcolor="#EEEEEE"><font color="#000000"
face="Arial,Helvetica"><B><a
href="$rss->{'channel'}->{'link'}">$rss->{'channel'}->{'title'}</a></B></font></td></tr>
<tr><td>
HTML
# print channel image
if ($rss->{'image'}->{'link'}) {
print <<HTML;
<center>
<p><a href="$rss->{'image'}->{'link'}"><img src="$rss->{'image'}->{'url'}"
alt="$rss->{'image'}->{'title'}" border="0"
HTML
print " width=\"$rss->{'image'}->{'width'}\""
if $rss->{'image'}->{'width'};
print " height=\"$rss->{'image'}->{'height'}\""
if $rss->{'image'}->{'height'};
print "></a></center><p>\n";
}
# print the channel items
foreach my $item (@{$rss->{'items'}}) {
next unless defined($item->{'title'}) && defined($item->{'link'});
print "<li><a href=\"$item->{'link'}\">$item->{'title'}</a><BR>\n";
}
# if there's a textinput element
if ($rss->{'textinput'}->{'title'}) {
print <<HTML;
<form method="get" action="$rss->{'textinput'}->{'link'}">
$rss->{'textinput'}->{'description'}<BR>
<input type="text" name="$rss->{'textinput'}->{'name'}"><BR>
<input type="submit" value="$rss->{'textinput'}->{'title'}">
</form>
HTML
}
# if there's a copyright element
if ($rss->{'channel'}->{'copyright'}) {
print <<HTML;
<p><sub>$rss->{'channel'}->{'copyright'}</sub></p>
HTML
}
print <<HTML;
</td>
</TR>
</TABLE>
</td></tr></table>
HTML
}
=head1 NAME
rss.inc - Apache::ASP applet
=head1 SYNOPSIS
$Response->Include( "rss.inc" ,"/path/to/file.rdf" );
$Response->Include( "showdir.inc", "http://slashdot.org/slashdot.rdf"); -don't abuse
this!
=head1 DESCRIPTION
This little ASP applet produces html table from RDF file.
It can fetch it from network using LWP agent, but watch out for this solution -
webmasters often
place limits on how often you can fetch their site.rdf file.
=head1 SIDE EFFECTS
Outputs resulting HTML string using print.
=head1 AUTHOR
Jonathan Eisenzopf.
Apache::ASP version - Eyck;)
=cut
%>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]