#!/usr/bin/perl -w
sub
	set_hrefs
{
    while (<HTMLIN>) {
	s#href=([A-Za-z.]+)#href=$base/$1#g;
	print HTMLOUT $_;
    }
}

local $base="lilypond/";
local @examples=("wohltemperirt");

system  'pod2html';

print "resetting refs.\n";

foreach $a (<*.html>)
{
    rename $a, "$a~";
    open HTMLIN, "$a~";
    open HTMLOUT, ">$a";
    set_hrefs;
}

foreach $a (@examples) {
    $texfile="test";
    system "cd ..; lilypond input/$a; tex $texfile;";
    system "dvips -o $texfile.ps $texfile;";    
    system "mv ../$texfile.ps $a.ps;".
	"gs -q -sDEVICE=ppmraw -sOutputFile=- -r200 -dNOPAUSE  $a.ps -c quit |pnmscale 0.5| ppmtogif > $a.gif"
}

system "mkdir docxx; make -C.. docxx; ln ../docxx/* ./docxx/;" .
	 "tar cf website.tar *.html *.gif *.png *.ps docxx/;" .
	"gzip -9 website.tar;"
