/[suikacvs]/test/html-webhacc/cc.cgi
Suika

Diff of /test/html-webhacc/cc.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.47 by wakaba, Fri Mar 21 11:17:00 2008 UTC revision 1.48 by wakaba, Sat Apr 12 15:57:56 2008 UTC
# Line 218  sub check_and_print ($$) { Line 218  sub check_and_print ($$) {
218      print_listing_section ({      print_listing_section ({
219        id => 'classes', label => 'Classes', heading => 'Classes',        id => 'classes', label => 'Classes', heading => 'Classes',
220      }, $input, $elements->{class}) if keys %{$elements->{class}};      }, $input, $elements->{class}) if keys %{$elements->{class}};
221        print_uri_section ($input, $elements->{uri}) if keys %{$elements->{uri}};
222      print_rdf_section ($input, $elements->{rdf}) if @{$elements->{rdf}};      print_rdf_section ($input, $elements->{rdf}) if @{$elements->{rdf}};
223    } elsif (defined $cssom) {    } elsif (defined $cssom) {
224      print_structure_dump_cssom_section ($input, $cssom);      print_structure_dump_cssom_section ($input, $cssom);
# Line 322  sub print_syntax_error_html_section ($$) Line 323  sub print_syntax_error_html_section ($$)
323    if (defined $inner_html_element and length $inner_html_element) {    if (defined $inner_html_element and length $inner_html_element) {
324      $input->{charset} ||= 'windows-1252'; ## TODO: for now.      $input->{charset} ||= 'windows-1252'; ## TODO: for now.
325      my $time1 = time;      my $time1 = time;
326      my $t = Encode::decode ($input->{charset}, $input->{s});      my $t = \($input->{s});
327        unless ($input->{is_char_string}) {
328          $t = \(Encode::decode ($input->{charset}, $$t));
329        }
330      $time{decode} = time - $time1;      $time{decode} = time - $time1;
331            
332      $el = $doc->create_element_ns      $el = $doc->create_element_ns
333          ('http://www.w3.org/1999/xhtml', [undef, $inner_html_element]);          ('http://www.w3.org/1999/xhtml', [undef, $inner_html_element]);
334      $time1 = time;      $time1 = time;
335      Whatpm::HTML->set_inner_html ($el, $t, $onerror);      Whatpm::HTML->set_inner_html ($el, $$t, $onerror);
336      $time{parse} = time - $time1;      $time{parse} = time - $time1;
337    } else {    } else {
338      my $time1 = time;      my $time1 = time;
339      Whatpm::HTML->parse_byte_string      if ($input->{is_char_string}) {
340          ($input->{charset}, $input->{s} => $doc, $onerror);        Whatpm::HTML->parse_char_string ($input->{s} => $doc, $onerror);
341        } else {
342          Whatpm::HTML->parse_byte_string
343              ($input->{charset}, $input->{s} => $doc, $onerror);
344        }
345      $time{parse_html} = time - $time1;      $time{parse_html} = time - $time1;
346    }    }
347    $doc->manakai_charset ($input->{official_charset})    $doc->manakai_charset ($input->{official_charset})
# Line 373  sub print_syntax_error_xml_section ($$) Line 381  sub print_syntax_error_xml_section ($$)
381      return 1;      return 1;
382    };    };
383    
384      my $t = \($input->{s});
385      if ($input->{is_char_string}) {
386        require Encode;
387        $t = \(Encode::encode ('utf8', $$t));
388        $input->{charset} = 'utf-8';
389      }
390    
391    my $time1 = time;    my $time1 = time;
392    open my $fh, '<', \($input->{s});    open my $fh, '<', $t;
393    my $doc = Message::DOM::XMLParserTemp->parse_byte_stream    my $doc = Message::DOM::XMLParserTemp->parse_byte_stream
394        ($fh => $dom, $onerror, charset => $input->{charset});        ($fh => $dom, $onerror, charset => $input->{charset});
395    $time{parse_xml} = time - $time1;    $time{parse_xml} = time - $time1;
# Line 647  sub print_syntax_error_manifest_section Line 662  sub print_syntax_error_manifest_section
662      add_error ('syntax', \%opt => $result);      add_error ('syntax', \%opt => $result);
663    };    };
664    
665      my $m = $input->{is_char_string} ? 'parse_char_string' : 'parse_byte_string';
666    my $time1 = time;    my $time1 = time;
667    my $manifest = Whatpm::CacheManifest->parse_byte_string    my $manifest = Whatpm::CacheManifest->$m
668        ($input->{s}, $input->{uri}, $input->{base_uri}, $onerror);        ($input->{s}, $input->{uri}, $input->{base_uri}, $onerror);
669    $time{parse_manifest} = time - $time1;    $time{parse_manifest} = time - $time1;
670    
# Line 1002  sub print_listing_section ($$$) { Line 1018  sub print_listing_section ($$$) {
1018    print STDOUT qq[</dl></div>];    print STDOUT qq[</dl></div>];
1019  } # print_listing_section  } # print_listing_section
1020    
1021    sub print_uri_section ($$$) {
1022      my ($input, $uris) = @_;
1023    
1024      ## NOTE: URIs contained in the DOM (i.e. in HTML or XML documents),
1025      ## except for those in RDF triples.
1026      ## TODO: URIs in CSS
1027      
1028      push @nav, ['#' . $input->{id_prefix} . 'uris' => 'URIs']
1029          unless $input->{nested};
1030      print STDOUT qq[
1031    <div id="$input->{id_prefix}uris" class="section">
1032    <h2>URIs</h2>
1033    
1034    <dl>];
1035      for my $uri (sort {$a cmp $b} keys %$uris) {
1036        my $euri = htescape ($uri);
1037        print STDOUT qq[<dt><code class=uri>&lt;<a href="$euri">$euri</a>></code>];
1038        my $eccuri = htescape (get_cc_uri ($uri));
1039        print STDOUT qq[<dd><a href="$eccuri">Check conformance of this document</a>];
1040        print STDOUT qq[<dd>Found at: <ul>];
1041        for my $entry (@{$uris->{$uri}}) {
1042          print STDOUT qq[<li>], get_node_link ($input, $entry->{node});
1043          if (keys %{$entry->{type} or {}}) {
1044            print STDOUT ' (';
1045            print STDOUT join ', ', map {
1046              {
1047                hyperlink => 'Hyperlink',
1048                resource => 'Link to an external resource',
1049                namespace => 'Namespace URI',
1050                cite => 'Citation or link to a long description',
1051                embedded => 'Link to an embedded content',
1052                base => 'Base URI',
1053                action => 'Submission URI',
1054              }->{$_}
1055                or
1056              htescape ($_)
1057            } keys %{$entry->{type}};
1058            print STDOUT ')';
1059          }
1060        }
1061        print STDOUT qq[</ul>];
1062      }
1063      print STDOUT qq[</dl></div>];
1064    } # print_uri_section
1065    
1066  sub print_rdf_section ($$$) {  sub print_rdf_section ($$$) {
1067    my ($input, $rdfs) = @_;    my ($input, $rdfs) = @_;
1068        
# Line 1363  sub get_text ($) { Line 1424  sub get_text ($) {
1424    
1425  }  }
1426    
1427    sub encode_uri_component ($) {
1428      require Encode;
1429      my $s = Encode::encode ('utf8', shift);
1430      $s =~ s/([^0-9A-Za-z_.~-])/sprintf '%%%02X', ord $1/ge;
1431      return $s;
1432    } # encode_uri_component
1433    
1434    sub get_cc_uri ($) {
1435      return './?uri=' . encode_uri_component ($_[0]);
1436    } # get_cc_uri
1437    
1438  sub get_input_document ($$) {  sub get_input_document ($$) {
1439    my ($http, $dom) = @_;    my ($http, $dom) = @_;
1440    

Legend:
Removed from v.1.47  
changed lines
  Added in v.1.48

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24