summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xhttpd/cgi-bin/check57
-rw-r--r--share/templates/en_US/invalid.tmpl7
-rw-r--r--share/templates/en_US/table.tmpl3
-rw-r--r--share/templates/en_US/valid.tmpl3
-rw-r--r--share/templates/en_US/xml_output.tmpl2
5 files changed, 57 insertions, 15 deletions
diff --git a/httpd/cgi-bin/check b/httpd/cgi-bin/check
index 58a4150..a84bcee 100755
--- a/httpd/cgi-bin/check
+++ b/httpd/cgi-bin/check
@@ -14,7 +14,7 @@
# This source code is available under the license at:
# http://www.w3.org/Consortium/Legal/copyright-software
#
-# $Id: check,v 1.470 2007-02-20 02:19:27 ot Exp $
+# $Id: check,v 1.471 2007-03-01 02:52:56 ot Exp $
#
# Disable buffering on STDOUT!
@@ -180,7 +180,7 @@ Directory not readable (permission denied): @_r
#
# Strings
- $VERSION = q$Revision: 1.470 $;
+ $VERSION = q$Revision: 1.471 $;
$VERSION =~ s/Revision: ([\d\.]+) /$1/;
#
@@ -694,7 +694,8 @@ if (! $File->{'Is Valid'}) {
eval {
local $SIG{__DIE__};
require HTML::Tidy;
- my $tidy = HTML::Tidy->new();
+ my $tidy = HTML::Tidy->new({config_file => "/Users/ot/Sites/cvs/public/validator/HEAD/htdocs/config/tidy.conf"});
+
$File->{'Tidy'} = $tidy->clean(join"\n",@{$File->{Content}});
$File->{'Tidy_OK'} = TRUE;
};
@@ -853,22 +854,56 @@ sub fin_template ($$) {
my $number_of_errors = ""; # textual form of $num_errors
my $number_of_warnings = ""; # textual form of $num_errors
+# The following is a bit hack-ish, but will enable us to have some logic
+# for a human-readable display of the number, with cases for 0, 1, 2 and above
+# (the case of 2 appears to be useful for localization in some languages where the plural is different for 2, and above)
+
if ($num_errors > 1) {
- $number_of_errors = "$num_errors errors"
+ $T->param(number_of_errors_is_0 => FALSE );
+ $T->param(number_of_errors_is_1 => FALSE);
+ if ($num_errors eq 2) {
+ $T->param(number_of_errors_is_2 => TRUE);
+ }
+ else { $T->param(number_of_errors_is_2 => FALSE ); }
+ $T->param(number_of_errors_is_plural => TRUE );
}
- else {
- $number_of_errors = "$num_errors error"
+ elsif ($num_errors eq 1) {
+ $T->param(number_of_errors_is_0 => FALSE );
+ $T->param(number_of_errors_is_1 => TRUE );
+ $T->param(number_of_errors_is_2 => FALSE );
+ $T->param(number_of_errors_is_plural => FALSE );
+ }
+ else { # 0
+ $T->param(number_of_errors_is_0 => TRUE );
+ $T->param(number_of_errors_is_1 => FALSE );
+ $T->param(number_of_errors_is_2 => FALSE );
+ $T->param(number_of_errors_is_plural => FALSE );
}
+
if ($num_warnings > 1) {
- $number_of_warnings = "$num_warnings warnings"
+ $T->param(number_of_warnings_is_0 => FALSE );
+ $T->param(number_of_warnings_is_1 => FALSE);
+ if ($num_warnings eq 2) {
+ $T->param(number_of_warnings_is_2 => TRUE);
+ }
+ else { $T->param(number_of_warnings_is_2 => FALSE ); }
+ $T->param(number_of_warnings_is_plural => TRUE );
}
- else {
- $number_of_warnings = "$num_warnings warning"
+ elsif ($num_warnings eq 1) {
+ $T->param(number_of_warnings_is_0 => FALSE );
+ $T->param(number_of_warnings_is_1 => TRUE );
+ $T->param(number_of_warnings_is_2 => FALSE );
+ $T->param(number_of_warnings_is_plural => FALSE );
}
+ else { # 0
+ $T->param(number_of_warnings_is_0 => TRUE );
+ $T->param(number_of_warnings_is_1 => FALSE );
+ $T->param(number_of_warnings_is_2 => FALSE );
+ $T->param(number_of_warnings_is_plural => FALSE );
+ }
+
$T->param(file_errors => $reported_errors);
- $T->param(number_of_errors => $number_of_errors);
- $T->param(number_of_warnings => $number_of_warnings);
if ($File->{'Is Valid'}) {
$T->param(VALID => TRUE);
$T->param(valid_status => 'Valid');
diff --git a/share/templates/en_US/invalid.tmpl b/share/templates/en_US/invalid.tmpl
index 4d95bc9..d51bc5b 100644
--- a/share/templates/en_US/invalid.tmpl
+++ b/share/templates/en_US/invalid.tmpl
@@ -8,7 +8,12 @@
<div id="result">
-<h3>Validation Output<TMPL_IF NAME="number_of_errors">: <TMPL_VAR NAME="number_of_errors" ESCAPE="HTML"></TMPL_IF></h3>
+<h3>Validation Output:
+ <!-- this case where validation fails but no error is listed should never happen -->
+ <TMPL_IF NAME="number_of_errors_is_0">Invalid </TMPL_IF>
+ <TMPL_IF NAME="number_of_errors_is_1">1 Error</TMPL_IF>
+ <TMPL_IF NAME="number_of_errors_is_plural"><TMPL_VAR NAME="valid_errors_num" ESCAPE="HTML"> Errors</TMPL_IF>
+ </h3>
<TMPL_IF NAME="opt_group_errors">
<TMPL_INCLUDE NAME="error_loop_grouped.tmpl">
diff --git a/share/templates/en_US/table.tmpl b/share/templates/en_US/table.tmpl
index e733b0a..c9e1269 100644
--- a/share/templates/en_US/table.tmpl
+++ b/share/templates/en_US/table.tmpl
@@ -24,7 +24,8 @@
</TMPL_IF>
<TMPL_ELSE>
<td colspan="2" class="invalid">
- Failed validation<TMPL_IF NAME="number_of_errors">, <TMPL_VAR NAME="number_of_errors" ESCAPE="HTML"></TMPL_IF>
+ Failed validation<TMPL_IF NAME="number_of_errors_is_1">, 1 Error</TMPL_IF><TMPL_IF NAME="number_of_errors_is_plural">, <TMPL_VAR NAME="valid_errors_num" ESCAPE="HTML"> Errors</TMPL_IF>
+ <!-- this case where validation fails but no error is listed should never happen -->
</TMPL_IF>
</td>
</tr>
diff --git a/share/templates/en_US/valid.tmpl b/share/templates/en_US/valid.tmpl
index e0178c8..4c3bc20 100644
--- a/share/templates/en_US/valid.tmpl
+++ b/share/templates/en_US/valid.tmpl
@@ -5,7 +5,8 @@
</TMPL_IF>
<TMPL_IF NAME="has_errors">
-<h3 id="warning_loop">Validation Output<TMPL_IF NAME="number_of_warnings">: <TMPL_VAR NAME="number_of_warnings" ESCAPE="HTML"></TMPL_IF></h3>
+<h3 id="warning_loop">Validation Output<TMPL_IF NAME="number_of_warnings_is_1">: 1 Warning</TMPL_IF><TMPL_IF NAME="number_of_warnings_is_plural">: <TMPL_VAR NAME="valid_warnings_num" ESCAPE="HTML"> Warnings</TMPL_IF>
+ </h3>
<p>
Below is a list of the warning message(s) produced when validating your document.
</p>
diff --git a/share/templates/en_US/xml_output.tmpl b/share/templates/en_US/xml_output.tmpl
index 83d7785..5d0b5c5 100644
--- a/share/templates/en_US/xml_output.tmpl
+++ b/share/templates/en_US/xml_output.tmpl
@@ -50,7 +50,7 @@ X-W3C-Validator-Errors: <TMPL_VAR NAME="valid_errors_num">
<size><TMPL_VAR NAME="file_size" ESCAPE="HTML"></size>
<encoding><TMPL_VAR NAME="file_charset" ESCAPE="HTML"></encoding>
<doctype><TMPL_VAR NAME="file_doctype" ESCAPE="HTML"></doctype>
- <errors><TMPL_VAR NAME="number_of_errors" ESCAPE="HTML"></errors>
+ <errors><TMPL_VAR NAME="valid_errors_num" ESCAPE="HTML"></errors>
</meta>
<warnings>