#!/usr/bin/perl

$progf = "./PROGRESSLOG";
$tmplf = "./content.tmpl";
$htmlf  = "./content.html";
$date  = `date`; chomp $date;

open tmpl, "$tmplf";
open html, ">$htmlf";

$ARGV[0] =~ m/-([\d.a-zA-Z]+?)\.tar\.gz/;

$v = $1;

while(<tmpl>) {
    my $counter = 0;
    if(/DATE_MARKER/) {
        print html "        This site was last updated $date.\n";
    }
    elsif(/PROGRESS_MARKER/) {
        open pf, "$progf";
        print html "        <li>\n";
        while(<pf>) {
            last if $counter > 3;
            s/-/<br>/ if /^\s*-/;
            print html $_;
            if(/^$/) {
                print html "        <br><li>\n" if $counter < 3;
                $counter++;
            }
        }
        close pf;
    }
    else {
        s/JDIST/$ARGV[0]/g;
        s/\/SRPM/\/jneural-$v-1.src.rpm/g;
        s/\/RPM/\/jneural-$v-1.i386.rpm/g;
        print html $_;
    }
}

close htmlf;
close tmpl;
