--- test/html-webhacc/cc.cgi 2008/02/10 02:05:30 1.31 +++ test/html-webhacc/cc.cgi 2008/02/10 02:30:14 1.32 @@ -147,6 +147,8 @@ sub check_and_print ($$) { my ($input, $result) = @_; + $input->{id_prefix} = ''; + #$input->{nested} = 1/0; print_http_header_section ($input, $result); @@ -178,15 +180,16 @@ } if (defined $doc or defined $el) { - print_structure_dump_dom_section ($doc, $el); - my $elements = print_structure_error_dom_section ($doc, $el, $result); - print_table_section ($elements->{table}) if @{$elements->{table}}; - print_id_section ($elements->{id}) if keys %{$elements->{id}}; - print_term_section ($elements->{term}) if keys %{$elements->{term}}; - print_class_section ($elements->{class}) if keys %{$elements->{class}}; + print_structure_dump_dom_section ($input, $doc, $el); + my $elements = print_structure_error_dom_section + ($input, $doc, $el, $result); + print_table_section ($input, $elements->{table}) if @{$elements->{table}}; + print_id_section ($input, $elements->{id}) if keys %{$elements->{id}}; + print_term_section ($input, $elements->{term}) if keys %{$elements->{term}}; + print_class_section ($input, $elements->{class}) if keys %{$elements->{class}}; } elsif (defined $manifest) { - print_structure_dump_manifest_section ($manifest); - print_structure_error_manifest_section ($manifest, $result); + print_structure_dump_manifest_section ($input, $manifest); + print_structure_error_manifest_section ($input, $manifest, $result); } } # check_and_print @@ -196,8 +199,8 @@ defined $input->{header_status_text} or @{$input->{header_field}}; - push @nav, ['#source-header' => 'HTTP Header']; - print STDOUT qq[
+ push @nav, ['#source-header' => 'HTTP Header'] unless $input->{nested}; + print STDOUT qq[

HTTP Header

Note: Due to the limitation of the @@ -231,11 +234,11 @@ require Whatpm::HTML; print STDOUT qq[ -

+

Parse Errors

]; - push @nav, ['#parse-errors' => 'Parse Error']; + push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested}; my $onerror = sub { my (%opt) = @_; @@ -289,11 +292,11 @@ require Message::DOM::XMLParserTemp; print STDOUT qq[ -
+

Parse Errors

]; - push @nav, ['#parse-errors' => 'Parse Error']; + push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{prefix}; my $onerror = sub { my $err = shift; @@ -331,16 +334,17 @@ require Whatpm::CacheManifest; print STDOUT qq[ -
+

Parse Errors

]; - push @nav, ['#parse-errors' => 'Parse Error']; + push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested}; my $onerror = sub { my (%opt) = @_; my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level}); - print STDOUT qq[
], get_error_label (\%opt), qq[
]; + print STDOUT qq[
], get_error_label ($input, \%opt), + qq[
]; $type =~ tr/ /-/; $type =~ s/\|/%7C/g; $msg .= qq[ [Description]]; @@ -367,20 +371,22 @@ my $s = \($enc->decode (${$_[0]})); my $i = 1; - push @nav, ['#source-string' => 'Source']; - print STDOUT qq[
+ push @nav, ['#source-string' => 'Source'] unless $input->{nested}; + print STDOUT qq[

Document Source

    \n]; if (length $$s) { while ($$s =~ /\G([^\x0A]*?)\x0D?\x0A/gc) { - print STDOUT qq[
  1. ], htescape $1, "
  2. \n"; + print STDOUT qq[
  3. ], htescape $1, + "
  4. \n"; $i++; } if ($$s =~ /\G([^\x0A]+)/gc) { - print STDOUT qq[
  5. ], htescape $1, "
  6. \n"; + print STDOUT qq[
  7. ], htescape $1, + "
  8. \n"; } } else { - print STDOUT q[
  9. ]; + print STDOUT q[
  10. ]; } print STDOUT "
"; } # print_input_string_section @@ -397,7 +403,7 @@ next; } - my $node_id = 'node-'.refaddr $child; + my $node_id = $input->{id_prefix} . 'node-'.refaddr $child; my $nt = $child->node_type; if ($nt == $child->ELEMENT_NODE) { my $child_nsuri = $child->namespace_uri; @@ -408,7 +414,7 @@ $r .= '
    '; for my $attr (sort {$a->[0] cmp $b->[0]} map { [$_->name, $_->value, $_->namespace_uri, 'node-'.refaddr $_] } @{$child->attributes}) { - $r .= qq[
  • ] . htescape ($attr->[0]) . ' = '; ## ISSUE: case? + $r .= qq[
  • ] . htescape ($attr->[0]) . ' = '; ## ISSUE: case? $r .= '' . htescape ($attr->[1]) . '
  • '; ## TODO: children } $r .= '
'; @@ -477,28 +483,28 @@ print STDOUT $r; } # print_document_tree -sub print_structure_dump_dom_section ($$) { - my ($doc, $el) = @_; +sub print_structure_dump_dom_section ($$$) { + my ($input, $doc, $el) = @_; print STDOUT qq[ -
+

Document Tree

]; - push @nav, ['#document-tree' => 'Tree']; + push @nav, ['#document-tree' => 'Tree'] unless $input->{nested}; print_document_tree ($el || $doc); print STDOUT qq[
]; } # print_structure_dump_dom_section -sub print_structure_dump_manifest_section ($) { - my $manifest = shift; +sub print_structure_dump_manifest_section ($$) { + my ($input, $manifest) = @_; print STDOUT qq[ -
+

Cache Manifest

]; - push @nav, ['#dump-manifest' => 'Caceh Manifest']; + push @nav, ['#dump-manifest' => 'Caceh Manifest'] unless $input->{nested}; print STDOUT qq[
Explicit entries
]; for my $uri (@{$manifest->[0]}) { @@ -525,14 +531,14 @@ print STDOUT qq[
]; } # print_structure_dump_manifest_section -sub print_structure_error_dom_section ($$$) { - my ($doc, $el, $result) = @_; +sub print_structure_error_dom_section ($$$$) { + my ($input, $doc, $el, $result) = @_; - print STDOUT qq[
+ print STDOUT qq[

Document Errors

]; - push @nav, ['#document-errors' => 'Document Error']; + push @nav, ['#document-errors' => 'Document Error'] unless $input->{nested}; require Whatpm::ContentChecker; my $onerror = sub { @@ -541,7 +547,7 @@ $type =~ tr/ /-/; $type =~ s/\|/%7C/g; $msg .= qq[ [Description]]; - print STDOUT qq[
] . get_error_label (\%opt) . + print STDOUT qq[
] . get_error_label ($input, \%opt) . qq[
\n
], get_error_level_label (\%opt); print STDOUT $msg, "
\n"; add_error ('structure', \%opt => $result); @@ -562,13 +568,13 @@ } # print_structure_error_dom_section sub print_structure_error_manifest_section ($$$) { - my ($manifest, $result) = @_; + my ($input, $manifest, $result) = @_; - print STDOUT qq[
+ print STDOUT qq[

Document Errors

]; - push @nav, ['#document-errors' => 'Document Error']; + push @nav, ['#document-errors' => 'Document Error'] unless $input->{nested}; require Whatpm::CacheManifest; Whatpm::CacheManifest->check_manifest ($manifest, sub { @@ -577,7 +583,7 @@ $type =~ tr/ /-/; $type =~ s/\|/%7C/g; $msg .= qq[ [Description]]; - print STDOUT qq[
] . get_error_label (\%opt) . + print STDOUT qq[
] . get_error_label ($input, \%opt) . qq[
\n
], $msg, "
\n"; add_error ('structure', \%opt => $result); }); @@ -585,12 +591,12 @@ print STDOUT qq[
]; } # print_structure_error_manifest_section -sub print_table_section ($) { - my $tables = shift; +sub print_table_section ($$) { + my ($input, $tables) = @_; - push @nav, ['#tables' => 'Tables']; + push @nav, ['#tables' => 'Tables'] unless $input->{nested}; print STDOUT qq[ -
+

Tables

@@ -605,8 +611,8 @@ my $i = 0; for my $table_el (@$tables) { $i++; - print STDOUT qq[

] . - get_node_link ($table_el) . q[

]; + print STDOUT qq[

] . + get_node_link ($input, $table_el) . q[

]; ## TODO: Make |ContentChecker| return |form_table| result ## so that this script don't have to run the algorithm twice. @@ -638,18 +644,19 @@ print STDOUT '
]; + print STDOUT qq[, document.getElementById ('$input->{id_prefix}table-$i')]; + print STDOUT qq[, '$input->{id_prefix}');]; } print STDOUT qq[
]; } # print_table_section -sub print_id_section ($) { - my $ids = shift; +sub print_id_section ($$) { + my ($input, $ids) = @_; - push @nav, ['#identifiers' => 'IDs']; + push @nav, ['#identifiers' => 'IDs'] unless $input->{nested}; print STDOUT qq[ -
+

Identifiers

@@ -657,18 +664,18 @@ for my $id (sort {$a cmp $b} keys %$ids) { print STDOUT qq[
@{[htescape $id]}
]; for (@{$ids->{$id}}) { - print STDOUT qq[
].get_node_link ($_).qq[
]; + print STDOUT qq[
].get_node_link ($input, $_).qq[
]; } } print STDOUT qq[
]; } # print_id_section -sub print_term_section ($) { - my $terms = shift; +sub print_term_section ($$) { + my ($input, $terms) = @_; - push @nav, ['#terms' => 'Terms']; + push @nav, ['#terms' => 'Terms'] unless $input->{nested}; print STDOUT qq[ -
+

Terms

@@ -676,18 +683,18 @@ for my $term (sort {$a cmp $b} keys %$terms) { print STDOUT qq[
@{[htescape $term]}
]; for (@{$terms->{$term}}) { - print STDOUT qq[
].get_node_link ($_).qq[
]; + print STDOUT qq[
].get_node_link ($input, $_).qq[
]; } } print STDOUT qq[
]; } # print_term_section -sub print_class_section ($) { - my $classes = shift; +sub print_class_section ($$) { + my ($input, $classes) = @_; - push @nav, ['#classes' => 'Classes']; + push @nav, ['#classes' => 'Classes'] unless $input->{nested}; print STDOUT qq[ -
+

Classes

@@ -695,7 +702,7 @@ for my $class (sort {$a cmp $b} keys %$classes) { print STDOUT qq[
@{[htescape $class]}
]; for (@{$classes->{$class}}) { - print STDOUT qq[
].get_node_link ($_).qq[
]; + print STDOUT qq[
].get_node_link ($input, $_).qq[
]; } } print STDOUT qq[
]; @@ -822,10 +829,10 @@

Input Error: @{[htescape ($input->{error_status_text})]}

]; push @nav, ['#result-summary' => 'Result']; -} # print_Result_input_error_section +} # print_result_input_error_section -sub get_error_label ($) { - my $err = shift; +sub get_error_label ($$) { + my ($input, $err) = @_; my $r = ''; @@ -840,7 +847,7 @@ if (defined $err->{node}) { $r .= ' ' if length $r; - $r = get_node_link ($err->{node}); + $r = get_node_link ($input, $err->{node}); } if (defined $err->{index}) { @@ -909,9 +916,9 @@ return join '/', @r; } # get_node_path -sub get_node_link ($) { - return qq[] . - htescape (get_node_path ($_[0])) . qq[]; +sub get_node_link ($$) { + return qq[] . + htescape (get_node_path ($_[1])) . qq[]; } # get_node_link { @@ -1156,4 +1163,4 @@ =cut -## $Date: 2008/02/10 02:05:30 $ +## $Date: 2008/02/10 02:30:14 $