#!/usr/bin/perl -w
#
# output_html.pl
#
# Writes out the results of calling output() on the multi-level
# navigation structure to files, so that the tests can compare
# the results once the files have been verified by a human.
#
# $Id: output_html.pl,v 1.1 2000/10/14 01:48:58 adam Exp $

if (($ENV{USER} || '') ne 'adams' ||
    ($ENV{HOSTNAME} || '') !~ /mediaconsult|guideguide/)
{
  die <<EOF;
WHOA THERE!

This file should only be run by the author, or someone who understands
the point of it.  Anyone else runs the risk of invalidating the results
of `make test'.

EOF
}

use strict;

use MyTest qw(callbacks callback html_page
              multi_level multi_page multi_filename);
use HTML::Navigation;

my $nav = new HTML::Navigation();
my $struct = multi_level();

$nav->structure($struct);
#$nav->debug_level(4);
$| = 0;

foreach my $param_set ([], $nav->dump_all_params()) {
  my $query_string = $nav->query_string($param_set) || 'none';
  my $filename = multi_filename($query_string);

  if (0) {
    print "$query_string\n";
    next;
  }
  
  open(HTML, ">$filename")
    or die "Couldn't open $filename for writing: $!\n";
  print "Writing $filename ... ";
  print HTML multi_page($nav->output({ @$param_set }));
  close(HTML);
  print "done.\n";
}
