#!/usr/bin/perl
#use strict;
#use diagnostics;

require XML::RSS;

my @sites = ();
push(@sites, "http://linuxdot.nl.linux.org/linuxdot.php");

my @news = ();

my $rss = new XML::RSS;
foreach my $site (@sites) {
  my $rdfstring = `lynx -source $site`;
  if ($rdfstring) {
    $rss->parse($rdfstring);
    my $time = `date +"%e %B %Y - %k:%M"`;
    push (@news, "<b><a href=\"$rss->{channel}->{'link'}\">$rss->{channel}->{title}</a></b> <i>$time</i>\n");
    push (@news, "<ul>\n");
    foreach my $item (@{$rss->{'items'}}) {
        push (@news, "<a href=\"$item->{'link'}\">$item->{'title'}</a><br>\n");
    }
    push (@news, "</ul>\n");
  }
}

open (OUTPUT, ">../../News/index.html");
open (TEMPLATE, "template.html");
my $line = "";
while ($line = <TEMPLATE>) {
    if ($line =~ /macro\ insert\ news/) {
	print OUTPUT @news;
    }
    print OUTPUT $line;
}
close (TEMPLATE);

1;






