my $out = shift @ARGV;
open OUT, ">$out";
my $last_year, $last_week;

print OUT `cat $ENV{srcdir}/doc/tmpl.blog.txt` . "\n";

print OUT '$$html <table class="blog">' . "\n";
for my $f ( reverse @ARGV )
{
    my $url = ( $f =~ s,(.*?)/([^/]*).txt,$2.html,r );
    $f =~ m,([0-9]{2})([0-9]{2}),;
    print OUT '$$html <tr>';

    print OUT "<td>";
    print OUT "20$1&nbsp;" unless $1 eq $last_year;
    print OUT "</td><td>";
    print OUT "week $2:&nbsp;" unless $2 eq $last_week;
    print OUT "</td>";

    $last_year = $1;
    $last_week = $2;

    print OUT "<td><a href=\"$url\">";
    my $head = `head -n 5 $f`;
    $head =~ m,^# (.*?)\n,sm;
    print STDERR $head;
    print OUT "$1</a></td></tr>\n";
}

print OUT '$$html </table>' . "\n";
