[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Perl Filter Demos?



Rich--

Because I SAID I had this puppy.  I'm leaving you on your own for finding an
RSS file, but this does work as advertised.

--B

#!perl -w
# my_rss2html - converts an RSS file to HTML
# Modified for use as BBEdit Filter
# Brian McNett 10/24/1999
# orig. by Jonathan Eisenzopf. v1.0 19990901
# See http://www.webreference.com/perl for more information

# INCLUDES
use strict;
use XML::RSS;

# create new instance of XML::RSS
my $rss = new XML::RSS;

# parse the RSS file
$rss->parsefile(shift @ARGV);

# print the HTML channel
&print_html($rss);

# SUBROUTINES
sub print_html {
    my $rss = shift;
    print <<HTML;
<table border="0" width="210">
<tr>
<td bgcolor="#000000">
<table cellspacing="1" cellpadding="8" border=0 width="100%">
<tr>
<td valign="middle" align="center" bgcolor="#cccccc">
<font face="Arial,Helvetica">
<b><a
href="$rss->{'channel'}->{'link'}">$rss->{'channel'}->{'title'}</a></b>
</font>
</td>
</tr>
<tr>
<td bgcolor="#ffffff">
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 "<font size='-1'><a
href=\"$item->{'link'}\">$item->{'title'}</a><br><br></font>\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 align='right'>
<sub>$rss->{'channel'}->{'copyright'}</sub>
</p>
HTML
    }

    print <<HTML;
</td>
</tr>
</table>
</td>
</tr>
</table>
HTML
}

__END__

--B

Webmaster/MacPerl Guru
*****************************************************
Mycoinfo, the World's First Mycology e-Journal
http://www.mycoinfo.com/
*****************************************************

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org