/[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.9 by wakaba, Sun Jul 15 16:39:10 2007 UTC revision 1.11 by wakaba, Mon Jul 16 10:55:11 2007 UTC
# Line 80  if (defined $input->{s}) { Line 80  if (defined $input->{s}) {
80    if ($input->{media_type} eq 'text/html') {    if ($input->{media_type} eq 'text/html') {
81      require Encode;      require Encode;
82      require Whatpm::HTML;      require Whatpm::HTML;
83    
84        $input->{charset} ||= 'ISO-8859-1'; ## TODO: for now.
85            
86      my $t = Encode::decode ($input->{charset}, $input->{s});      my $t = Encode::decode ($input->{charset}, $input->{s});
87    
# Line 87  if (defined $input->{s}) { Line 89  if (defined $input->{s}) {
89  <div id="parse-errors" class="section">  <div id="parse-errors" class="section">
90  <h2>Parse Errors</h2>  <h2>Parse Errors</h2>
91    
92  <dl>  <dl>];
 ];  
93    push @nav, ['#parse-errors' => 'Parse Error'];    push @nav, ['#parse-errors' => 'Parse Error'];
94    
95    my $onerror = sub {    my $onerror = sub {
96      my (%opt) = @_;      my (%opt) = @_;
97      my ($cls, $msg) = get_text ($opt{type}, $opt{level});      my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level});
98      if ($opt{column} > 0) {      if ($opt{column} > 0) {
99        print STDOUT qq[<dt class="$cls"><a href="#line-$opt{line}">Line $opt{line}</a> column $opt{column}</dt>\n];        print STDOUT qq[<dt class="$cls"><a href="#line-$opt{line}">Line $opt{line}</a> column $opt{column}</dt>\n];
100      } else {      } else {
101        $opt{line} = $opt{line} - 1 || 1;        $opt{line} = $opt{line} - 1 || 1;
102        print STDOUT qq[<dt class="$cls"><a href="#line-$opt{line}">Line $opt{line}</a></dt>\n];        print STDOUT qq[<dt class="$cls"><a href="#line-$opt{line}">Line $opt{line}</a></dt>\n];
103      }      }
104      $opt{type} =~ tr/ /-/;      $type =~ tr/ /-/;
105      $opt{type} =~ s/\|/%7C/g;      $type =~ s/\|/%7C/g;
106      $msg .= qq[ [<a href="../error-description#$opt{type}">Description</a>]];      $msg .= qq[ [<a href="../error-description#@{[htescape ($type)]}">Description</a>]];
107      print STDOUT qq[<dd class="$cls">$msg</dd>\n];      print STDOUT qq[<dd class="$cls">$msg</dd>\n];
108    };    };
109    
# Line 115  if (defined $input->{s}) { Line 116  if (defined $input->{s}) {
116      Whatpm::HTML->parse_string ($t => $doc, $onerror);      Whatpm::HTML->parse_string ($t => $doc, $onerror);
117    }    }
118    
119    print STDOUT qq[    print STDOUT qq[</dl>
 </dl>  
120  </div>  </div>
121  ];  ];
122    
# Line 185  if (defined $input->{s}) { Line 185  if (defined $input->{s}) {
185      require Whatpm::ContentChecker;      require Whatpm::ContentChecker;
186      my $onerror = sub {      my $onerror = sub {
187        my %opt = @_;        my %opt = @_;
188        my ($cls, $msg) = get_text ($opt{type}, $opt{level});        my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level});
189        $opt{type} = $opt{level} . ':' . $opt{type} if defined $opt{level};        $type =~ tr/ /-/;
190        $opt{type} =~ tr/ /-/;        $type =~ s/\|/%7C/g;
191        $opt{type} =~ s/\|/%7C/g;        $msg .= qq[ [<a href="../error-description#@{[htescape ($type)]}">Description</a>]];
       $msg .= qq[ [<a href="../error-description#$opt{type}">Description</a>]];  
192        print STDOUT qq[<dt class="$cls">] . get_node_link ($opt{node}) .        print STDOUT qq[<dt class="$cls">] . get_node_link ($opt{node}) .
193            qq[</dt>\n<dd class="$cls">], $msg, "</dd>\n";            qq[</dt>\n<dd class="$cls">], $msg, "</dd>\n";
194      };      };
# Line 246  if (defined $input->{s}) { Line 245  if (defined $input->{s}) {
245              for (@$_) {              for (@$_) {
246                $_->{id} = refaddr $_->{element} if defined $_->{element};                $_->{id} = refaddr $_->{element} if defined $_->{element};
247                delete $_->{element};                delete $_->{element};
248                  $_->{is_header} = $_->{is_header} ? 1 : 0;
249              }              }
250            }            }
251          }          }
# Line 493  sub get_text ($) { Line 493  sub get_text ($) {
493    {    {
494      if (defined $Msg->{$type}) {      if (defined $Msg->{$type}) {
495        my $msg = $Msg->{$type}->[1];        my $msg = $Msg->{$type}->[1];
496        $msg =~ s/\$([0-9]+)/defined $arg[$1] ? htescape ($arg[$1]) : '(undef)'/ge;        $msg =~ s{<var>\$([0-9]+)</var>}{
497        return ($Msg->{$type}->[0], $msg);          defined $arg[$1] ? htescape ($arg[$1]) : '(undef)';
498          }ge;
499          return ($type, $Msg->{$type}->[0], $msg);
500      } elsif ($type =~ s/:([^:]*)$//) {      } elsif ($type =~ s/:([^:]*)$//) {
501        unshift @arg, $1;        unshift @arg, $1;
502        redo;        redo;
503      }      }
504    }    }
505    return ('', htescape ($_[0]));    return ($type, '', htescape ($_[0]));
506  } # get_text  } # get_text
507    
508  }  }

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.11

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24