diff options
author | ot <ot@localhost> | 2007-04-12 07:18:15 +0000 |
---|---|---|
committer | ot <ot@localhost> | 2007-04-12 07:18:15 +0000 |
commit | 70c050ad6210c2f59de0b572e26b3473c134a55a (patch) | |
tree | 5cfe6d90c49308afc2fc777e1387276ed439d9f0 | |
parent | 660a791b18379b02a8f515c08c9967c422ca6684 (diff) | |
download | markup-validator-70c050ad6210c2f59de0b572e26b3473c134a55a.zip markup-validator-70c050ad6210c2f59de0b572e26b3473c134a55a.tar.gz markup-validator-70c050ad6210c2f59de0b572e26b3473c134a55a.tar.bz2 |
making prefilling of document structure on the server-side rather than via scripting.
See: http://lists.w3.org/Archives/Public/www-validator/2007Mar/0078.html
+thread
and: http://lists.w3.org/Archives/Public/www-validator/2007Apr/0049.html
+thread
-rwxr-xr-x | htdocs/detailed-form_directinput.html | 23 | ||||
-rwxr-xr-x | htdocs/header.html | 5 | ||||
-rw-r--r-- | htdocs/scripts/prefill.js | 19 | ||||
-rw-r--r-- | htdocs/style/base.css | 48 | ||||
-rwxr-xr-x | httpd/cgi-bin/check | 41 |
5 files changed, 85 insertions, 51 deletions
diff --git a/htdocs/detailed-form_directinput.html b/htdocs/detailed-form_directinput.html index 5d1d436..f1c0734 100755 --- a/htdocs/detailed-form_directinput.html +++ b/htdocs/detailed-form_directinput.html @@ -1,10 +1,19 @@ -<tr><th>Pre-fill with:</th><td> <a href="#validate-by-input" onclick="prefill_document('fragment', 'xhtml1')">XHTML 1.0</a> · - <a href="#validate-by-input" onclick="prefill_document('fragment', 'html401')">HTML 4.01</a> document structure.</td></tr> -<tr> - <th><label for="<!--#echo var="fieldset_id" -->-doctype">Use Doctype:</label></th> +<tr><th><input id="<!--#echo var="fieldset_id" -->_prefill_no" name="prefill" type="radio" value="0" checked="checked" /> + <label for="<!--#echo var="fieldset_id" -->_prefill_no">Validate Full Document</label></th></tr> + +<tr class="subchoice" id="choice_full"> + <th class="subchoice_head"><label for="<!--#echo var="fieldset_id" -->-doctype">Use Doctype:</label></th> + <td> <!--#include virtual="doctype-select.html" --></td> -<td> <label for="<!--#echo var="fieldset_id" -->-fbd"><input id="<!--#echo var="fieldset_id" -->-fbd" name="fbd" type="checkbox" value="1" />Only if Doctype is missing</label></td> +<td> <input id="<!--#echo var="fieldset_id" -->-fbd" name="fbd" type="checkbox" value="1" /><label for="<!--#echo var="fieldset_id" -->-fbd">Only if Doctype is missing</label></td> </tr> +<tr><th><input id="<!--#echo var="fieldset_id" -->_prefill_yes" name="prefill" type="radio" value="1" /> + <label for="<!--#echo var="fieldset_id" -->_prefill_yes">Validate HTML fragment</label></th></tr> + <tr class="subchoice" id="choice_frag"> + <th class="subchoice_head"><label for="fill_doctype">Use Doctype:</label></th> + <td> + <input type="radio" name="prefill_doctype" id="<!--#echo var="fieldset_id" -->fill_doctype_html401" value="html401" checked="checked" /><label for="<!--#echo var="fieldset_id" -->fill_doctype_html401">HTML 4.01</label> + <input type="radio" name="prefill_doctype" id="<!--#echo var="fieldset_id" -->fill_doctype_xhtml10" value="xhtml10" /><label for="<!--#echo var="fieldset_id" -->fill_doctype_xhtml10">XHTML 1.0</label></td></tr> <tr> <td colspan="3"><input type="radio" name="group" id="<!--#echo var="fieldset_id" -->group_no" value="0" checked="checked" /><label for="<!--#echo var="fieldset_id" -->group_no">List Messages Sequentially</label> <input type="radio" name="group" id="<!--#echo var="fieldset_id" -->group_yes" value="1" /><label for="<!--#echo var="fieldset_id" -->group_yes">Group Error Messages by type</label></td> @@ -20,7 +29,7 @@ <tr> <td><input id="<!--#echo var="fieldset_id" -->-outline" name="outline" type="checkbox" value="1" /><label title="Show an Outline of the document" for="<!--#echo var="fieldset_id" -->-outline">Show Outline</label> </td> - <td><label title="Validate also pages for which the HTTP status code indicates an error" for="<!--#echo var="fieldset_id" -->-No200"><input id="<!--#echo var="fieldset_id" -->-No200" name="No200" type="checkbox" value="1" /> Validate error pages</label></td> + <td><input id="<!--#echo var="fieldset_id" -->-No200" name="No200" type="checkbox" value="1" /><label title="Validate also pages for which the HTTP status code indicates an error" for="<!--#echo var="fieldset_id" -->-No200">Validate error pages</label></td> - <td><label title="Verbose Output" for="<!--#echo var="fieldset_id" -->-verbose"><input id="<!--#echo var="fieldset_id" -->-verbose" name="verbose" type="checkbox" value="0" />Verbose Output</label></td> + <td><input id="<!--#echo var="fieldset_id" -->-verbose" name="verbose" type="checkbox" value="0" /><label title="Verbose Output" for="<!--#echo var="fieldset_id" -->-verbose">Verbose Output</label></td> </tr> diff --git a/htdocs/header.html b/htdocs/header.html index b77151e..4487861 100755 --- a/htdocs/header.html +++ b/htdocs/header.html @@ -12,8 +12,7 @@ <script type="text/javascript" src="<!--#echo var="relroot" -->scripts/tabtastic/attachevent.js"></script> <script type="text/javascript" src="<!--#echo var="relroot" -->scripts/tabtastic/addcss.js"></script> <script type="text/javascript" src="<!--#echo var="relroot" -->scripts/tabtastic/tabtastic.js"></script> - <script type="text/javascript" src="<!--#echo var="relroot" -->scripts/prefill.js"></script> - <meta name="revision" content="$Id: header.html,v 1.46 2007-04-10 02:49:44 ot Exp $" /> + <meta name="revision" content="$Id: header.html,v 1.47 2007-04-12 07:18:14 ot Exp $" /> <meta name="keywords" content="HTML, HyperText Markup Language, Validation, W3C Markup Validation Service" /> <meta name="description" content="W3C's easy-to-use @@ -22,7 +21,7 @@ <!--#if expr="$feeds = 1" --> <link rel="alternate" type="application/atom+xml" href="whatsnew.atom" /> <!--#endif --> - <!-- SSI Template Version: $Id: header.html,v 1.46 2007-04-10 02:49:44 ot Exp $ --> + <!-- SSI Template Version: $Id: header.html,v 1.47 2007-04-12 07:18:14 ot Exp $ --> </head> diff --git a/htdocs/scripts/prefill.js b/htdocs/scripts/prefill.js deleted file mode 100644 index 3c9074d..0000000 --- a/htdocs/scripts/prefill.js +++ /dev/null @@ -1,19 +0,0 @@ -// prefill validator "direct input" form with basic document structure - - -var text_xhtml1 = '<?xml version="1.0" encoding="utf-8"?>\n<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"\n "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n <head>\n <title>I AM YOUR DOCUMENT TITLE REPLACE ME</title>\n <meta http-equiv="content-type" content="application/xhtml+xml;charset=utf-8" />\n <meta http-equiv="content-style-type" content="text/css" />\n </head>\n <body>\n <div>… Your HTML content here …</div>\n</body>\n </html>'; - -var text_html401 = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"\n "http://www.w3.org/TR/html4/strict.dtd">\n<html>\n<head>\n <title>I AM YOUR DOCUMENT TITLE REPLACE ME</title>\n <meta http-equiv="content-type" content="text/html;charset=utf-8">\n <meta http-equiv="Content-Style-Type" content="text/css">\n</head>\n<body>\n <div>… Your HTML content here …</div>\n</body>\n</html>'; - -function prefill_document(textarea_id, doctype) { - var txtarea = document.getElementById(textarea_id); - // first we remove all children nodes - if (doctype == "html401") { - txtarea.value = text_html401; - } - else { - txtarea.value = text_xhtml1; - } -// txtarea.select(); - txtarea.focus(); -}; diff --git a/htdocs/style/base.css b/htdocs/style/base.css index 61ad6bb..70c1e41 100644 --- a/htdocs/style/base.css +++ b/htdocs/style/base.css @@ -5,7 +5,7 @@ Copyright 2000~2007 W3C (MIT, INRIA, Keio). All Rights Reserved. See http://www.w3.org/Consortium/Legal/ipr-notice.html#Copyright - $Id: base.css,v 1.8 2007-04-02 11:19:55 ot Exp $ + $Id: base.css,v 1.9 2007-04-12 07:18:15 ot Exp $ */ /* @@ -199,6 +199,27 @@ ul.toc { list-style: none; } +/* tables in the documentation */ + +table { + border-collapse: collapse; + border-right: 1px solid #ccc; +} +td, th{ + border-top: 0px solid #ddd; + border-bottom: 1px solid #ccc; + border-left: 1px solid #eee; + padding: 6px; + border-collapse: collapse; +} +th { + background-color: #eee; + color: #11111A; + border-right: 1px solid #ccc; +} + + + /* Stuff we don't actually want too visible - or not at all */ @@ -233,6 +254,12 @@ fieldset legend { fieldset.moreoptions legend { font-weight: normal; } + +fieldset.moreoptions table tr.subchoice th { + font-weight: normal; + padding-left: 3em; +} + fieldset p { margin: 0 0 0.8em 0; padding: 0; @@ -387,25 +414,6 @@ border: 0; -/* tables in the documentation */ - -table { - border-collapse: collapse; - border-right: 1px solid #ccc; -} -td, th{ - border-top: 0px solid #ddd; - border-bottom: 1px solid #ccc; - border-left: 1px solid #eee; - padding: 6px; - border-collapse: collapse; -} -th { - background-color: #eee; - color: #11111A; - border-right: 1px solid #ccc; -} - /* Menu Bar diff --git a/httpd/cgi-bin/check b/httpd/cgi-bin/check index ef4cc84..50cd3f4 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.498 2007-04-09 07:51:30 ot Exp $ +# $Id: check,v 1.499 2007-04-12 07:18:15 ot Exp $ # # Disable buffering on STDOUT! @@ -180,7 +180,7 @@ Directory not readable (permission denied): @_r # # Strings - $VERSION = q$Revision: 1.498 $; + $VERSION = q$Revision: 1.499 $; $VERSION =~ s/Revision: ([\d\.]+) /$1/; # @@ -375,6 +375,25 @@ my $N3T = HTML::Template->new( global_vars => TRUE, ); +my $PREFILL_HTML_T = HTML::Template->new( + filename => File::Spec->catfile($CFG->{Paths}->{Templates}, + $lang, 'prefill_html401.tmpl'), + die_on_bad_params => FALSE, + loop_context_vars => TRUE, + cache => TRUE, + global_vars => TRUE, +); + +my $PREFILL_XHTML_T = HTML::Template->new( + filename => File::Spec->catfile($CFG->{Paths}->{Templates}, + $lang, 'prefill_xhtml10.tmpl'), + die_on_bad_params => FALSE, + loop_context_vars => TRUE, + cache => TRUE, + global_vars => TRUE, +); + + $File->{T} = $T; $File->{S} = $SOAPT; $File->{E} = $E; @@ -406,6 +425,8 @@ $File->{Opt}->{'Charset'} = $q->param('charset') ? lc $q->param('charset' $File->{Opt}->{'DOCTYPE'} = $q->param('doctype') ? $q->param('doctype') : ''; $File->{Opt}->{'Output'} = $q->param('output') ? $q->param('output') : 'html'; $File->{Opt}->{'Max Errors'} = $q->param('me') ? $q->param('me') : ''; +$File->{Opt}->{'Prefill'} = $q->param('prefill') ? TRUE : FALSE; +$File->{Opt}->{'Prefill Doctype'} = $q->param('prefill_doctype') ? $q->param('prefill_doctype') : 'html401'; # # "Fallback" info for Character Encoding (fbc), Content-Type (fbt), @@ -1293,6 +1314,22 @@ sub handle_frag { $File->{'Direct Input'} = TRUE; $File->{Charset}->{HTTP} = "utf-8"; # by default, the form accepts utf-8 chars + if ($File->{Opt}->{'Prefill'} eq TRUE ) { + # we surround the HTML fragment with some basic document structure + my $prefill_Template = undef; + if ($File->{Opt}->{'Prefill Doctype'} eq 'html401') { + $prefill_Template = $PREFILL_HTML_T; + } + else { + $prefill_Template = $PREFILL_XHTML_T; + } + $prefill_Template->param(fragment => $File->{Bytes}); + $File->{Bytes} = $prefill_Template->output(); + # let's force the view source so that the user knows what we've put around their code + $File->{Opt}->{'Show Source'} = TRUE; + } + + return $File; } |