<%DOC>
%# Science is what happens when preconception meets verification.
</%DOC>
<%ARGS>
$URL => 'http://www.openfoundry.org/index.rdf'
$Timeout => 1
</%ARGS>
</form>
<form style="margin: 0" action="http://www.openfoundry.org/mailman/subscribe/openfoundry" method="post" target="_blank">
<table border="0" cellspacing="1" cellpadding="2" width=100%>
<tr><td class="tableTitle">
<&|/l&>Subscribe to OpenFoundry Newsletter</&>
</td></tr>
<tr><td bgcolor="white" align="center">
    <&|/l&>Email</&>:
    <input type="hidden" name="pw" value="foundry">
    <input type="hidden" name="pw-conf" value="foundry">
    <input type="text" name="email" value="">
    <input type="image" border="0" name="Action-Search" src="/img/Go.png" width="23" height="19" align="middle">
</td></tr>
</table>
</form>
<br>
<table border="0" cellspacing="1" cellpadding="2" width=100%>
<tr><td class="tableTitle">
<&|/l&>OpenFoundry Newsletter</&>
</td>
</tr>
% eval { $rss->parsefile($file) };
% if ($@)
% { unlink $file; 
% }
% else{
%   my $count = 0;
%   foreach my $item (@{ $rss->items })
%   { last if $count++ == 7;
        <tr bgcolor="white"><td><nobr>
        <a href="<% $item->{link} %>"><% $item->{title} %></a>
        <img src="/img/external-classic.png">
        </nobr></td></tr>
%   }
% }
</table>
<%ONCE>
require LWP::UserAgent;
my $ua = new LWP::UserAgent;  # we create a global UserAgent object
$ua->agent("OpenFoundry Bot");
require XML::RSS;
my $rss = XML::RSS->new;
</%ONCE>
<%INIT>
%::escapes = map { chr($_) => sprintf("%%%02X", $_) } 0..255 unless %::escapes;

my $file = $URL;
$file =~ s/([^\w\.])/$::escapes{$1}/g;
$file = File::Spec->catfile( ($ENV{TEMP} || '/tmp'), $file);
$ua->timeout($Timeout);
$ua->mirror( $URL, $file );
# Don't care HTTP success or fail , let $rss handle it
</%INIT>
