Parent Directory
|
Revision Log
++ ChangeLog 21 Mar 2008 09:17:42 -0000 * cc.cgi (get_rdf_resource_html): undef vs false bug fixed. 2008-03-21 Wakaba <wakaba@suika.fam.cx>
| 1 | #!/usr/bin/perl |
| 2 | use strict; |
| 3 | use utf8; |
| 4 | |
| 5 | use lib qw[/home/httpd/html/www/markup/html/whatpm |
| 6 | /home/wakaba/work/manakai2/lib]; |
| 7 | use CGI::Carp qw[fatalsToBrowser]; |
| 8 | use Scalar::Util qw[refaddr]; |
| 9 | use Time::HiRes qw/time/; |
| 10 | |
| 11 | sub htescape ($) { |
| 12 | my $s = $_[0]; |
| 13 | $s =~ s/&/&/g; |
| 14 | $s =~ s/</</g; |
| 15 | $s =~ s/>/>/g; |
| 16 | $s =~ s/"/"/g; |
| 17 | $s =~ s{([\x00-\x09\x0B-\x1F\x7F-\xA0\x{FEFF}\x{FFFC}-\x{FFFF}])}{ |
| 18 | sprintf '<var>U+%04X</var>', ord $1; |
| 19 | }ge; |
| 20 | return $s; |
| 21 | } # htescape |
| 22 | |
| 23 | my @nav; |
| 24 | my %time; |
| 25 | require Message::DOM::DOMImplementation; |
| 26 | my $dom = Message::DOM::DOMImplementation->new; |
| 27 | { |
| 28 | use Message::CGI::HTTP; |
| 29 | my $http = Message::CGI::HTTP->new; |
| 30 | |
| 31 | if ($http->get_meta_variable ('PATH_INFO') ne '/') { |
| 32 | print STDOUT "Status: 404 Not Found\nContent-Type: text/plain; charset=us-ascii\n\n400"; |
| 33 | exit; |
| 34 | } |
| 35 | |
| 36 | binmode STDOUT, ':utf8'; |
| 37 | $| = 1; |
| 38 | |
| 39 | load_text_catalog ('en'); ## TODO: conneg |
| 40 | |
| 41 | print STDOUT qq[Content-Type: text/html; charset=utf-8 |
| 42 | |
| 43 | <!DOCTYPE html> |
| 44 | <html lang="en"> |
| 45 | <head> |
| 46 | <title>Web Document Conformance Checker (BETA)</title> |
| 47 | <link rel="stylesheet" href="../cc-style.css" type="text/css"> |
| 48 | </head> |
| 49 | <body> |
| 50 | <h1><a href="../cc-interface">Web Document Conformance Checker</a> |
| 51 | (<em>beta</em>)</h1> |
| 52 | ]; |
| 53 | |
| 54 | $| = 0; |
| 55 | my $input = get_input_document ($http, $dom); |
| 56 | my $char_length = 0; |
| 57 | |
| 58 | print qq[ |
| 59 | <div id="document-info" class="section"> |
| 60 | <dl> |
| 61 | <dt>Request URI</dt> |
| 62 | <dd><code class="URI" lang=""><<a href="@{[htescape $input->{request_uri}]}">@{[htescape $input->{request_uri}]}</a>></code></dd> |
| 63 | <dt>Document URI</dt> |
| 64 | <dd><code class="URI" lang=""><<a href="@{[htescape $input->{uri}]}" id=anchor-document-uri>@{[htescape $input->{uri}]}</a>></code> |
| 65 | <script> |
| 66 | document.title = '<' |
| 67 | + document.getElementById ('anchor-document-uri').href + '> \\u2014 ' |
| 68 | + document.title; |
| 69 | </script></dd> |
| 70 | ]; # no </dl> yet |
| 71 | push @nav, ['#document-info' => 'Information']; |
| 72 | |
| 73 | if (defined $input->{s}) { |
| 74 | $char_length = length $input->{s}; |
| 75 | |
| 76 | print STDOUT qq[ |
| 77 | <dt>Base URI</dt> |
| 78 | <dd><code class="URI" lang=""><<a href="@{[htescape $input->{base_uri}]}">@{[htescape $input->{base_uri}]}</a>></code></dd> |
| 79 | <dt>Internet Media Type</dt> |
| 80 | <dd><code class="MIME" lang="en">@{[htescape $input->{media_type}]}</code> |
| 81 | @{[$input->{media_type_overridden} ? '<em>(overridden)</em>' : defined $input->{official_type} ? $input->{media_type} eq $input->{official_type} ? '' : '<em>(sniffed; official type is: <code class=MIME lang=en>'.htescape ($input->{official_type}).'</code>)' : '<em>(sniffed)</em>']}</dd> |
| 82 | <dt>Character Encoding</dt> |
| 83 | <dd>@{[defined $input->{charset} ? '<code class="charset" lang="en">'.htescape ($input->{charset}).'</code>' : '(none)']} |
| 84 | @{[$input->{charset_overridden} ? '<em>(overridden)</em>' : '']}</dd> |
| 85 | <dt>Length</dt> |
| 86 | <dd>$char_ |