perl/modules/W3C/LogValidator/lib/W3C/LogValidator HTMLValidator.pm,1.23,1.24

Update of /sources/public/perl/modules/W3C/LogValidator/lib/W3C/LogValidator
In directory hutz:/tmp/cvs-serv9076/lib/W3C/LogValidator

Modified Files:
	HTMLValidator.pm 
Log Message:
Adding options for the HTMLValidator module, to list valid, invalid or non-validable
documents in the final report, providing more flexibility on what is reported



Index: HTMLValidator.pm
===================================================================
RCS file: /sources/public/perl/modules/W3C/LogValidator/lib/W3C/LogValidator/HTMLValidator.pm,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- HTMLValidator.pm	24 Jul 2007 06:08:11 -0000	1.23
+++ HTMLValidator.pm	4 Sep 2007 05:38:13 -0000	1.24
@@ -52,6 +52,11 @@
         {
 		$self->{AUTH_EXT} = ".html .xhtml .phtml .htm .shtml .php .svg .xml /";
 	}
+	$config{ShowInvalid} = "Yes" if (!exists $config{ShowInvalid});
+	$config{ShowAborted} = "No" if (!exists $config{ShowAborted});
+	$config{ShowValid} = "No" if (!exists $config{ShowValid});
+
+
 	if (exists $config{verbose}) {$verbose = $config{verbose}}
 	@{$self->{URIs}} = undef;
         bless($self, $class);
@@ -224,8 +229,24 @@
 	@uris = $self->trim_uris(@uris);
 	my @result;
 	my @result_head;
-	my $intro="Here are the <census> most popular invalid document(s) that I could find in the 
+	my @whatweshow;
+	my $whatweshow_str = "";
+
+	push @whatweshow, "valid" if ($config{ShowValid} eq "Yes");
+	push @whatweshow, "invalid" if ($config{ShowInvalid} eq "Yes");
+  push @whatweshow, "non-validable"  if ($config{ShowAborted} eq "Yes");
+	if (@whatweshow eq 3) {
+	  $whatweshow_str = "$whatweshow[0], $whatweshow[1] or $whatweshow[2]";
+	}
+	elsif (@whatweshow eq 2) {
+	  $whatweshow_str = "$whatweshow[0] or $whatweshow[1]";
+	}
+	elsif (@whatweshow eq 1) {
+	  $whatweshow_str = "$whatweshow[0]";
+	}
+	my $intro="Here are the <census> most popular $whatweshow_str document(s) that I could find in the 
 logs for $name.";
+
 	my $outro;
 	push @result_head, "Rank";
 	push @result_head, "Hits";
@@ -262,7 +283,7 @@
 			if ( ($self->valid) and ($self->valid_err_num) ) # invalid doc
 #			if (1) # debug
 			{
-			    if ($self->valid =~ /Invalid/i){
+			    if ( (($self->valid =~ /Invalid/i) and ($config{ShowInvalid} eq "Yes")) or (($self->valid =~ /Valid/i) and ($config{ShowValid} eq "Yes")) )  {
 				my @result_tmp;
 				push @result_tmp, $total_census;
 				push @result_tmp, $hits{$uri_orig};
@@ -273,13 +294,35 @@
 				$last_invalid_position = $total_census;
 			    }
 			}
+			elsif (($self->valid =~ /Abort/i) and ($config{ShowAborted} eq "Yes")) {
+			  my @result_tmp;
+				push @result_tmp, $total_census;
+				push @result_tmp, $hits{$uri_orig};
+				push @result_tmp, "Abort";
+				push @result_tmp, $uri_orig;
+				push @result, [@result_tmp];
+				$invalid_census++;
+				$last_invalid_position = $total_census;
+			}
 			printf (" %s!", $self->valid) if ( ($verbose > 1) and (defined ($self->valid)));
 			print " Could not validate!" if (($verbose > 1) and(!defined ($self->valid)));
 
 			if (($verbose > 1) and ($self->valid_err_num)) # verbose or debug
 				{printf ", %s errors!",$self->valid_err_num}
 		}
-		else { print " Could not validate!" if ($verbose > 1) }
+		else { 
+		  print " Could not validate!" if ($verbose > 1) ;
+		  if ($config{ShowAborted} eq "Yes") {
+			  my @result_tmp;
+				push @result_tmp, $total_census;
+				push @result_tmp, $hits{$uri_orig};
+				push @result_tmp, "Abort";
+				push @result_tmp, $uri_orig;
+				push @result, [@result_tmp];
+				$invalid_census++;
+				$last_invalid_position = $total_census;
+			}
+		  }
 		print "\n" if ($verbose > 1);
 
 		$self->valid_head($response->as_string); # for debug
@@ -304,7 +347,7 @@
 		# usual case
 		{
 			$outro="Conclusion :
-I had to check $last_invalid_position document(s) in order to find $invalid_census invalid HTML documents.
+I had to check $last_invalid_position document(s) in order to find $invalid_census $whatweshow_str HTML documents.
 This means that about $ratio\% of your most popular documents were invalid.";
 		}
 		else
@@ -312,12 +355,12 @@
 		{
         if ($max_invalid) {
 			$outro="Conclusion :
-You asked for $max_invalid invalid HTML document but I could only find $invalid_census 
+You asked for $max_invalid $whatweshow_str HTML document but I could only find $invalid_census 
 by processing (all the) $total_census document(s) in your logs. 
 This means that about $ratio\% of your most popular documents were invalid.";}
         else # max_invalid set to 0, user asked for all invalid docs
    		{$outro="Conclusion :
-I found $invalid_census 
+I found $invalid_census $whatweshow_str HTML document(s)
 by processing (all the) $total_census document(s) in your logs. 
 This means that about $ratio\% of your most popular documents were invalid.";}     
 		}

Received on Tuesday, 4 September 2007 05:38:38 UTC