/[pub]/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.37 by wakaba, Sun Feb 24 02:17:51 2008 UTC revision 1.45 by wakaba, Fri Mar 21 08:59:47 2008 UTC
# Line 86  if (defined $input->{s}) { Line 86  if (defined $input->{s}) {
86      <dd>$char_length byte@{[$char_length == 1 ? '' : 's']}</dd>      <dd>$char_length byte@{[$char_length == 1 ? '' : 's']}</dd>
87  </dl>  </dl>
88  </div>  </div>
89    
90    <script src="../cc-script.js"></script>
91  ];  ];
92    
93    $input->{id_prefix} = '';    $input->{id_prefix} = '';
# Line 171  sub check_and_print ($$) { Line 173  sub check_and_print ($$) {
173              'text/xml' => 1,              'text/xml' => 1,
174              'application/atom+xml' => 1,              'application/atom+xml' => 1,
175              'application/rss+xml' => 1,              'application/rss+xml' => 1,
176              'application/svg+xml' => 1,              'image/svg+xml' => 1,
177              'application/xhtml+xml' => 1,              'application/xhtml+xml' => 1,
178              'application/xml' => 1,              'application/xml' => 1,
179                ## TODO: Should we make all XML MIME Types fall
180                ## into this category?
181    
182                'application/rdf+xml' => 1, ## NOTE: This type has different model.
183             }->{$input->{media_type}}) {             }->{$input->{media_type}}) {
184      ($doc, $el) = print_syntax_error_xml_section ($input, $result);      ($doc, $el) = print_syntax_error_xml_section ($input, $result);
185      print_source_string_section ($input,      print_source_string_section ($input,
# Line 212  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_rdf_section ($input, $elements->{rdf}) if @{$elements->{rdf}};
222    } elsif (defined $cssom) {    } elsif (defined $cssom) {
223      print_structure_dump_cssom_section ($input, $cssom);      print_structure_dump_cssom_section ($input, $cssom);
224      ## TODO: CSSOM validation      ## TODO: CSSOM validation
# Line 292  sub print_syntax_error_html_section ($$) Line 299  sub print_syntax_error_html_section ($$)
299  <div id="$input->{id_prefix}parse-errors" class="section">  <div id="$input->{id_prefix}parse-errors" class="section">
300  <h2>Parse Errors</h2>  <h2>Parse Errors</h2>
301    
302  <dl>];  <dl id="$input->{id_prefix}parse-errors-list">];
303    push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested};    push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested};
304    
305    my $onerror = sub {    my $onerror = sub {
306      my (%opt) = @_;      my (%opt) = @_;
307      my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level});      my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level});
308      if ($opt{column} > 0) {      print STDOUT qq[<dt class="$cls">], get_error_label ($input, \%opt),
309        print STDOUT qq[<dt class="$cls"><a href="#$input->{id_prefix}line-$opt{line}">Line $opt{line}</a> column $opt{column}</dt>\n];          qq[</dt>];
     } else {  
       $opt{line} = $opt{line} - 1 || 1;  
       print STDOUT qq[<dt class="$cls"><a href="#$input->{id_prefix}line-$opt{line}">Line $opt{line}</a></dt>\n];  
     }  
310      $type =~ tr/ /-/;      $type =~ tr/ /-/;
311      $type =~ s/\|/%7C/g;      $type =~ s/\|/%7C/g;
312      $msg .= qq[ [<a href="../error-description#@{[htescape ($type)]}">Description</a>]];      $msg .= qq[ [<a href="../error-description#@{[htescape ($type)]}">Description</a>]];
# Line 350  sub print_syntax_error_xml_section ($$) Line 353  sub print_syntax_error_xml_section ($$)
353  <div id="$input->{id_prefix}parse-errors" class="section">  <div id="$input->{id_prefix}parse-errors" class="section">
354  <h2>Parse Errors</h2>  <h2>Parse Errors</h2>
355    
356  <dl>];  <dl id="$input->{id_prefix}parse-errors-list">];
357    push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{prefix};    push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{prefix};
358    
359    my $onerror = sub {    my $onerror = sub {
# Line 561  sub print_syntax_error_css_section ($$) Line 564  sub print_syntax_error_css_section ($$)
564  <div id="$input->{id_prefix}parse-errors" class="section">  <div id="$input->{id_prefix}parse-errors" class="section">
565  <h2>Parse Errors</h2>  <h2>Parse Errors</h2>
566    
567  <dl>];  <dl id="$input->{id_prefix}parse-errors-list">];
568    push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested};    push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested};
569    
570    my $p = get_css_parser ();    my $p = get_css_parser ();
# Line 627  sub print_syntax_error_manifest_section Line 630  sub print_syntax_error_manifest_section
630  <div id="$input->{id_prefix}parse-errors" class="section">  <div id="$input->{id_prefix}parse-errors" class="section">
631  <h2>Parse Errors</h2>  <h2>Parse Errors</h2>
632    
633  <dl>];  <dl id="$input->{id_prefix}parse-errors-list">];
634    push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested};    push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested};
635    
636    my $onerror = sub {    my $onerror = sub {
# Line 673  sub print_source_string_section ($$$) { Line 676  sub print_source_string_section ($$$) {
676  <h2>Document Source</h2>  <h2>Document Source</h2>
677  <ol lang="">\n];  <ol lang="">\n];
678    if (length $$s) {    if (length $$s) {
679      while ($$s =~ /\G([^\x0A]*?)\x0D?\x0A/gc) {      while ($$s =~ /\G([^\x0D\x0A]*?)(?>\x0D\x0A?|\x0A)/gc) {
680        print STDOUT qq[<li id="$input->{id_prefix}line-$i">], htescape $1,        print STDOUT qq[<li id="$input->{id_prefix}line-$i">], htescape $1,
681            "</li>\n";            "</li>\n";
682        $i++;        $i++;
683      }      }
684      if ($$s =~ /\G([^\x0A]+)/gc) {      if ($$s =~ /\G([^\x0D\x0A]+)/gc) {
685        print STDOUT qq[<li id="$input->{id_prefix}line-$i">], htescape $1,        print STDOUT qq[<li id="$input->{id_prefix}line-$i">], htescape $1,
686            "</li>\n";            "</li>\n";
687      }      }
688    } else {    } else {
689      print STDOUT q[<li id="$input->{id_prefix}line-1"></li>];      print STDOUT q[<li id="$input->{id_prefix}line-1"></li>];
690    }    }
691    print STDOUT "</ol></div>";    print STDOUT "</ol></div>
692    <script>
693      addSourceToParseErrorList ('$input->{id_prefix}', 'parse-errors-list');
694    </script>";
695  } # print_input_string_section  } # print_input_string_section
696    
697  sub print_document_tree ($$) {  sub print_document_tree ($$) {
# Line 854  sub print_structure_error_dom_section ($ Line 860  sub print_structure_error_dom_section ($
860    print STDOUT qq[<div id="$input->{id_prefix}document-errors" class="section">    print STDOUT qq[<div id="$input->{id_prefix}document-errors" class="section">
861  <h2>Document Errors</h2>  <h2>Document Errors</h2>
862    
863  <dl>];  <dl id=document-errors-list>];
864    push @nav, [qq[#$input->{id_prefix}document-errors] => 'Document Error']    push @nav, [qq[#$input->{id_prefix}document-errors] => 'Document Error']
865        unless $input->{nested};        unless $input->{nested};
866    
# Line 882  sub print_structure_error_dom_section ($ Line 888  sub print_structure_error_dom_section ($
888    }    }
889    $time{check} = time - $time1;    $time{check} = time - $time1;
890    
891    print STDOUT qq[</dl></div>];    print STDOUT qq[</dl>
892    <script>
893      addSourceToParseErrorList ('$input->{id_prefix}', 'document-errors-list');
894    </script></div>];
895    
896    return $elements;    return $elements;
897  } # print_structure_error_dom_section  } # print_structure_error_dom_section
# Line 993  sub print_listing_section ($$$) { Line 1002  sub print_listing_section ($$$) {
1002    print STDOUT qq[</dl></div>];    print STDOUT qq[</dl></div>];
1003  } # print_listing_section  } # print_listing_section
1004    
1005    sub print_rdf_section ($$$) {
1006      my ($input, $rdfs) = @_;
1007      
1008      push @nav, ['#' . $input->{id_prefix} . 'rdf' => 'RDF']
1009          unless $input->{nested};
1010      print STDOUT qq[
1011    <div id="$input->{id_prefix}rdf" class="section">
1012    <h2>RDF Triples</h2>
1013    
1014    <dl>];
1015      my $i = 0;
1016      for my $rdf (@$rdfs) {
1017        print STDOUT qq[<dt id="$input->{id_prefix}rdf-@{[$i++]}">];
1018        print STDOUT get_node_link ($input, $rdf->[0]);
1019        print STDOUT qq[<dd><dl>];
1020        for my $triple (@{$rdf->[1]}) {
1021          print STDOUT '<dt>' . get_node_link ($input, $triple->[0]) . '<dd>';
1022          print STDOUT get_rdf_resource_html ($triple->[1]);
1023          print STDOUT ' ';
1024          print STDOUT get_rdf_resource_html ($triple->[2]);
1025          print STDOUT ' ';
1026          print STDOUT get_rdf_resource_html ($triple->[3]);
1027        }
1028        print STDOUT qq[</dl>];
1029      }
1030      print STDOUT qq[</dl></div>];
1031    } # print_rdf_section
1032    
1033    sub get_rdf_resource_html ($) {
1034      my $resource = shift;
1035      if ($resource->{uri}) {
1036        my $euri = htescape ($resource->{uri});
1037        return '<code class=uri>&lt;<a href="' . $euri . '">' . $euri .
1038            '</a>></code>';
1039      } elsif ($resource->{bnodeid}) {
1040        return htescape ('_:' . $resource->{bnodeid});
1041      } elsif ($resource->{nodes}) {
1042        return '(rdf:XMLLiteral)';
1043      } elsif (defined $resource->{value}) {
1044        my $elang = htescape (defined $resource->{language}
1045                                  ? $resource->{language} : '');
1046        my $r = qq[<q lang="$elang">] . htescape ($resource->{value}) . '</q>';
1047        if (defined $resource->{datatype}) {
1048          my $euri = htescape ($resource->{datatype});
1049          $r .= '^^<code class=uri>&lt;<a href="' . $euri . '">' . $euri .
1050              '</a>></code>';
1051        } elsif (length $resource->{language}) {
1052          $r .= '@' . htescape ($resource->{language});
1053        }
1054        return $r;
1055      } else {
1056        return '??';
1057      }
1058    } # get_rdf_resource_html
1059    
1060  sub print_result_section ($) {  sub print_result_section ($) {
1061    my $result = shift;    my $result = shift;
1062    
# Line 1122  sub get_error_label ($$) { Line 1186  sub get_error_label ($$) {
1186    
1187    my $r = '';    my $r = '';
1188    
1189    if (defined $err->{line}) {    my $line;
1190      if ($err->{column} > 0) {    my $column;
1191        $r = qq[<a href="#$input->{id_prefix}line-$err->{line}">Line $err->{line}</a> column $err->{column}];      
1192      if (defined $err->{node}) {
1193        $line = $err->{node}->get_user_data ('manakai_source_line');
1194        if (defined $line) {
1195          $column = $err->{node}->get_user_data ('manakai_source_column');
1196        } else {
1197          if ($err->{node}->node_type == $err->{node}->ATTRIBUTE_NODE) {
1198            my $owner = $err->{node}->owner_element;
1199            $line = $owner->get_user_data ('manakai_source_line');
1200            $column = $owner->get_user_data ('manakai_source_column');
1201          } else {
1202            my $parent = $err->{node}->parent_node;
1203            if ($parent) {
1204              $line = $parent->get_user_data ('manakai_source_line');
1205              $column = $parent->get_user_data ('manakai_source_column');
1206            }
1207          }
1208        }
1209      }
1210      unless (defined $line) {
1211        if (defined $err->{token} and defined $err->{token}->{line}) {
1212          $line = $err->{token}->{line};
1213          $column = $err->{token}->{column};
1214        } elsif (defined $err->{line}) {
1215          $line = $err->{line};
1216          $column = $err->{column};
1217        }
1218      }
1219    
1220      if (defined $line) {
1221        if (defined $column and $column > 0) {
1222          $r = qq[<a href="#$input->{id_prefix}line-$line">Line $line</a> column $column];
1223      } else {      } else {
1224        $err->{line} = $err->{line} - 1 || 1;        $line = $line - 1 || 1;
1225        $r = qq[<a href="#$input->{id_prefix}line-$err->{line}">Line $err->{line}</a>];        $r = qq[<a href="#$input->{id_prefix}line-$line">Line $line</a>];
1226      }      }
1227    }    }
1228    
1229    if (defined $err->{node}) {    if (defined $err->{node}) {
1230      $r .= ' ' if length $r;      $r .= ' ' if length $r;
1231      $r = get_node_link ($input, $err->{node});      $r .= get_node_link ($input, $err->{node});
1232    }    }
1233    
1234    if (defined $err->{index}) {    if (defined $err->{index}) {

Legend:
Removed from v.1.37  
changed lines
  Added in v.1.45

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24