# Copyright (c) 2002-2005 the World Wide Web Consortium : # Keio University, # European Research Consortium for Informatics and Mathematics # Massachusetts Institute of Technology. # written by Olivier Thereaux for W3C # # $Id: HTML.pm,v 1.13 2005/09/09 06:33:11 ot Exp $ package W3C::LogValidator::Output::HTML; use strict; require Exporter; our @ISA = qw(Exporter); our %EXPORT_TAGS = ( 'all' => [ qw() ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT = qw(); our $VERSION = sprintf "%d.%03d",q$Revision: 1.13 $ =~ /(\d+)\.(\d+)/; ########################### # usual package interface # ########################### our $verbose = 1; our %config; sub new { my $self = {}; my $proto = shift; my $class = ref($proto) || $proto; # configuration for this module if (@_) {%config = %{(shift)};} if (defined $config{verbose}) {$verbose = $config{verbose}} bless($self, $class); return $self; } sub output { my $self = shift; my %results; my $outputstr =""; if (@_) {%results = %{(shift)}} $outputstr= "

Results for module ".$results{'name'}."

\n"; $outputstr= $outputstr."

".$results{"intro"}."

\n" if ($results{"intro"}); my @thead = @{$results{"thead"}}; my @trows = @{$results{"trows"}}; if ((@thead) or (@trows)) { $outputstr= $outputstr."\n"; if (@thead) { $outputstr= $outputstr."\n"; while (@thead) { my $header = shift (@thead); $outputstr= $outputstr.""; } $outputstr= $outputstr."\n"; } while (@trows) { my @row=@{shift (@trows)}; $outputstr= $outputstr."\n"; my $tcell; while (@row) { $tcell= shift (@row); chomp $tcell; $outputstr= $outputstr.""; } $outputstr= $outputstr."\n"; } $outputstr= $outputstr."
$header
$tcell
\n"; } $outputstr= $outputstr."\n"; $outputstr= $outputstr."

".$results{"outro"}."

\n\n" if ($results{"outro"}); return $outputstr; } sub finish { # embed HTML tidbits in a full HTML file # and either save or output my $self = shift; my $title = "Logvalidator results"; if (defined $config{"Title"}) { $title = $config{"Title"}; } my $result_string = ' '.$title.'

'.$title.'

'; if (@_) { my $tmp_result_string = shift; $result_string = $result_string.$tmp_result_string; } my ($sec,$min,$hour,$day,$mon,$year,$wday,$yday) = gmtime(time); $mon ++; # weird 'feature': months run 0-11; days run 1-31 :-( my $date = ($year+1900) .'-'. ($mon>9 ? $mon:"0$mon") .'-'. ($day>9 ? $day:"0$day"); $result_string = $result_string.' '; if (defined $config{OutputTo}) { my $filetosave = $config{OutputTo}; open (HTMLOUT, "> $filetosave") || print STDERR "could not open file $filetosave for saving : $!"; print HTMLOUT $result_string; close HTMLOUT; } else { print $result_string; } } package W3C::LogValidator::Output::HTML; 1; __END__ =head1 NAME W3C::LogValidator::Output::HTML - [W3C Log Validator] HTML Output module =head1 SYNOPSIS use W3C::LogValidator::HTMLOutput; =head1 DESCRIPTION This module is part of the W3C::LogValidator suite, and outputs the result of the log processing and validation in HTML format. =head1 AUTHOR Olivier Thereaux =head1 SEE ALSO W3C::LogValidator, perl(1). Up-to-date complete info at http://www.w3.org/QA/Tools/LogValidator/ =cut