summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorot <ot@localhost>2005-03-17 06:30:13 +0000
committerot <ot@localhost>2005-03-17 06:30:13 +0000
commite8ce9503dd65ef81f915e077cbd131733cf7e600 (patch)
tree80b2ee15118747f0fd35f41ce1b5e19b35751036
parent8e747e4bbc75963ea7310af50a3d4d22ea6ba4d8 (diff)
downloadmarkup-validator-e8ce9503dd65ef81f915e077cbd131733cf7e600.zip
markup-validator-e8ce9503dd65ef81f915e077cbd131733cf7e600.tar.gz
markup-validator-e8ce9503dd65ef81f915e077cbd131733cf7e600.tar.bz2
htdocs/docs/errors.html is out of sync with current error messages and explanations, creating a small script extracting them from the DB in the same format
-rwxr-xr-xmisc/docs_errors.pl117
-rw-r--r--share/templates/en_US/docs_errors.tmpl31
2 files changed, 148 insertions, 0 deletions
diff --git a/misc/docs_errors.pl b/misc/docs_errors.pl
new file mode 100755
index 0000000..1e98a8a
--- /dev/null
+++ b/misc/docs_errors.pl
@@ -0,0 +1,117 @@
+#!/usr/bin/perl -T
+##
+## Generates HTML documentation of error messages and explanations
+## for W3C Markup Validation Service
+## $Id: docs_errors.pl,v 1.1 2005-03-17 06:30:13 ot Exp $
+
+## Pragmas.
+use strict;
+use warnings;
+
+
+## Modules. See also the BEGIN block further down below.
+
+use HTML::Template 2.6 qw();
+use Config::General 2.19 qw(); # Need 2.19 for -AutoLaunder
+
+use vars qw($DEBUG $CFG $RSRC $VERSION $HAVE_IPC_RUN);
+# Define global constants
+use constant TRUE => 1;
+use constant FALSE => 0;
+
+BEGIN {
+ # Launder data for -T; -AutoLaunder doesn't catch this one.
+ if (exists $ENV{W3C_VALIDATOR_HOME}) {
+ $ENV{W3C_VALIDATOR_HOME} =~ /^(.*)$/;
+ $ENV{W3C_VALIDATOR_HOME} = $1;
+ }
+
+ #
+ # Read Config Files.
+ eval {
+ my %config_opts = (
+ -ConfigFile => ($ENV{W3C_VALIDATOR_CFG} || '/etc/w3c/validator.conf'),
+ -MergeDuplicateOptions => TRUE,
+ -MergeDuplicateBlocks => TRUE,
+ -SplitPolicy => 'equalsign',
+ -UseApacheInclude => TRUE,
+ -IncludeRelative => TRUE,
+ -InterPolateVars => TRUE,
+ -AutoLaunder => TRUE,
+ -AutoTrue => TRUE,
+ -DefaultConfig => {
+ Protocols => {Allow => 'http,https'},
+ Paths => {
+ Base => ($ENV{W3C_VALIDATOR_HOME} || '/usr/local/validator'),
+ SGML => {Parser => '/usr/bin/onsgmls'},
+ },
+ },
+ );
+ my %cfg = Config::General->new(%config_opts)->getall();
+ $CFG = \%cfg;
+ };
+ if ($@) {
+ die <<".EOF.";
+Could not read configuration. Set the W3C_VALIDATOR_CFG environment variable
+or copy conf/* to /etc/w3c/. Make sure that the configuration file and all
+included files are readable by the web server user. The error was:\n'$@'
+.EOF.
+ }
+} # end of BEGIN block.
+
+#
+# Get rid of (possibly insecure) $PATH.
+delete $ENV{PATH};
+
+our $lang = 'en_US'; # @@@ TODO: conneg
+
+# Read error message + explanations file
+our $error_messages_file = File::Spec->catfile($CFG->{Paths}->{Templates}, $lang, 'error_messages.cfg');
+our %config_errs = (-ConfigFile => $error_messages_file);
+our %rsrc = Config::General->new(%config_errs)->getall();
+$RSRC = \%rsrc;
+
+
+our $T = HTML::Template->new(
+ filename => File::Spec->catfile($CFG->{Paths}->{Templates}, $lang, 'docs_errors.tmpl'),
+ die_on_bad_params => FALSE,
+);
+
+$T->param(list_errors => &list_errors($RSRC));
+print $T->output;
+
+sub list_errors{
+ my $RSRC = shift;
+ my $errors = [];
+ my $error_id;
+ my $max_error_id=500; # where to stop
+ for ($error_id=0;$error_id<$max_error_id;$error_id++)
+ {
+ my %single_error;
+ if ($RSRC->{msg}->{$error_id})
+ {
+ my $original = $RSRC->{msg}->{$error_id}->{original};
+ $original = &de_template_explanation($original);
+ $single_error{original} = $original;
+ $single_error{verbose} = $RSRC->{msg}->{$error_id}->{verbose};
+ $single_error{id} = $error_id;
+ push @{$errors}, \%single_error;
+ }
+ }
+ print $errors;
+ return $errors;
+}
+
+sub de_template_explanation {
+# takes the error message template, and replace "template keywords" with real life keywords
+ my $explanation = shift;
+ if ($explanation){
+ $explanation =~ s/\%1/X/;
+ $explanation =~ s/\%2/Y/;
+ $explanation =~ s/\%3/Z/;
+ $explanation =~ s/\%4/a/;
+ $explanation =~ s/\%5/b/;
+ $explanation =~ s/\%6/c/;
+ }
+ return $explanation;
+}
diff --git a/share/templates/en_US/docs_errors.tmpl b/share/templates/en_US/docs_errors.tmpl
new file mode 100644
index 0000000..f094b31
--- /dev/null
+++ b/share/templates/en_US/docs_errors.tmpl
@@ -0,0 +1,31 @@
+<!--#set var="revision" value="\$Id: docs_errors.tmpl,v 1.1 2005-03-17 06:30:13 ot Exp $"
+--><!--#set var="date" value="\$Date: 2005-03-17 06:30:13 $"
+--><!--#set var="title" value="Error Explanations for The W3C Markup Validation Service"
+--><!--#set var="relroot" value="../"
+--><!--#include virtual="../header.html" -->
+
+<h2>Explanation of the error messages<br /> for the W3C Markup Validator</h2>
+ <p>
+ These error explanations were originally written by Scott Bigham,
+ and are used here with his permission.
+ </p>
+
+<h3 id="TableOfContents">Table of Contents</h3>
+ <div id="toc">
+ <ul>
+ <li>...</li>
+ </ul>
+ </div>
+
+ <div>
+ <h3>Listing of errors and their explanation</h3>
+ <dl>
+ <TMPL_LOOP NAME="list_errors">
+ <dt><TMPL_VAR NAME="id"> <TMPL_VAR NAME="original"></dt>
+ <dd><TMPL_VAR NAME="verbose"></dd>
+ </TMPL_LOOP>
+ </dl>
+ </div>
+<!--#include virtual="../footer.html" -->
+ </body>
+</html> \ No newline at end of file