/[suikacvs]/test/html-webhacc/WebHACC/Output.pm
Suika

Diff of /test/html-webhacc/WebHACC/Output.pm

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

revision 1.15 by wakaba, Thu Aug 14 15:50:42 2008 UTC revision 1.19 by wakaba, Fri Aug 15 14:11:13 2008 UTC
# Line 55  sub handle ($;$) { Line 55  sub handle ($;$) {
55    return $_[0]->{handle};    return $_[0]->{handle};
56  } # handle  } # handle
57    
58    sub has_error ($;$) {
59      if (@_ > 1) {
60        if (defined $_[1]) {
61          $_[0]->{has_error} = 1;
62        } else {
63          delete $_[0]->{has_error};
64        }
65      }
66      
67      return $_[0]->{has_error};
68    } # has_error
69    
70  sub set_utf8 ($) {  sub set_utf8 ($) {
71    binmode shift->{handle}, ':utf8';    binmode shift->{handle}, ':utf8';
72  } # set_utf8  } # set_utf8
# Line 207  sub start_error_list ($%) { Line 219  sub start_error_list ($%) {
219      } elsif ($opt{role} eq 'structure-errors') {      } elsif ($opt{role} eq 'structure-errors') {
220        $opt{id} ||= 'document-errors-list';        $opt{id} ||= 'document-errors-list';
221        delete $opt{role};        delete $opt{role};
222        } elsif ($opt{role} eq 'transfer-errors') {
223          $opt{id} ||= 'transfer-errors-list';
224          delete $opt{role};
225      }      }
226    }    }
227    
228    $self->start_tag ('dl', %opt);    $self->start_tag ('dl', %opt);
229    
230      delete $self->{has_error}; # reset
231  } # start_error_list  } # start_error_list
232    
233  sub end_error_list ($%) {  sub end_error_list ($%) {
234    my ($self, %opt) = @_;    my ($self, %opt) = @_;
235    
236      my $no_error_message = 'No error found.';
237    
238    if (defined $opt{role}) {    if (defined $opt{role}) {
239      if ($opt{role} eq 'parse-errors') {      if ($opt{role} eq 'parse-errors') {
       delete $opt{role};  
240        $self->end_tag ('dl');        $self->end_tag ('dl');
241        ## NOTE: For parse error list, the |add_source_to_parse_error_list|        ## NOTE: For parse error list, the |add_source_to_parse_error_list|
242        ## method is invoked at the end of |generate_source_string_section|,        ## method is invoked at the end of |generate_source_string_section|,
243        ## since that generation method is invoked after the error list        ## since that generation method is invoked after the error list
244        ## is generated.        ## is generated.
245          $no_error_message = 'No parse error found.';
246      } elsif ($opt{role} eq 'structure-errors') {      } elsif ($opt{role} eq 'structure-errors') {
       delete $opt{role};  
247        $self->end_tag ('dl');        $self->end_tag ('dl');
248        $self->add_source_to_parse_error_list ('document-errors-list');        $self->add_source_to_parse_error_list ('document-errors-list');
249          $no_error_message = 'No structural error found.';
250        } elsif ($opt{role} eq 'transfer-errors') {
251          $self->end_tag ('dl');
252          $no_error_message = 'No transfer error found.';
253      } else {      } else {
254        $self->end_tag ('dl');        $self->end_tag ('dl');
255      }      }
256    } else {    } else {
257      $self->end_tag ('dl');      $self->end_tag ('dl');
258    }    }
259    
260      unless ($self->{has_error}) {
261        $self->start_tag ('p', class => 'no-errors');
262        $self->nl_text ($no_error_message);
263      }
264  } # end_error_list  } # end_error_list
265    
266  sub add_source_to_parse_error_list ($$) {  sub add_source_to_parse_error_list ($$) {
# Line 314  sub xref ($$%) { Line 341  sub xref ($$%) {
341    $self->html ('</a>');    $self->html ('</a>');
342  } # xref  } # xref
343    
344    sub xref_text ($$%) {
345      my ($self, $content, %opt) = @_;
346      $self->html ('<a href="#' . $htescape->($self->input->id_prefix . $opt{target}) . '">');
347      $self->text ($content);
348      $self->html ('</a>');
349    } # xref
350    
351  sub link_to_webhacc ($$%) {  sub link_to_webhacc ($$%) {
352    my ($self, $content, %opt) = @_;    my ($self, $content, %opt) = @_;
353    $opt{url} = './?uri=' . $self->encode_url_component ($opt{url});    $opt{url} = './?uri=' . $self->encode_url_component ($opt{url});
# Line 367  my $get_object_path = sub ($) { Line 401  my $get_object_path = sub ($) {
401  sub node_link ($$) {  sub node_link ($$) {
402    my ($self, $node) = @_;    my ($self, $node) = @_;
403    if ($node->isa ('Message::IF::Node')) {    if ($node->isa ('Message::IF::Node')) {
404      $self->xref ($get_node_path->($node), target => 'node-' . refaddr $node);      $self->xref_text ($get_node_path->($node),
405                          target => 'node-' . refaddr $node);
406    } else {    } else {
407      $self->html ($get_object_path->($node));      $self->html ($get_object_path->($node));
408    }    }
# Line 416  sub nl_text ($$;%) { Line 451  sub nl_text ($$;%) {
451          $msg =~ s{<var>{text}</var>}{          $msg =~ s{<var>{text}</var>}{
452            defined $opt{text} ? $htescape->($opt{text}) : ''            defined $opt{text} ? $htescape->($opt{text}) : ''
453          }ge;          }ge;
454            $msg =~ s{<var>{value}</var>}{
455              defined $opt{value} ? $htescape->($opt{value}) : ''
456            }ge;
457          $msg =~ s{<var>{local-name}</var>}{          $msg =~ s{<var>{local-name}</var>}{
458            UNIVERSAL::can ($node, 'manakai_local_name')            UNIVERSAL::can ($node, 'manakai_local_name')
459              ? $htescape->($node->manakai_local_name) : ''              ? $htescape->($node->manakai_local_name) : ''
# Line 481  sub html_header ($) { Line 519  sub html_header ($) {
519  sub generate_input_section ($$) {  sub generate_input_section ($$) {
520    my ($out, $cgi) = @_;    my ($out, $cgi) = @_;
521    
522      require Encode;
523      my $decode = sub ($) {
524        if (defined $_[0]) {
525          return Encode::decode ('utf-8', $_[0]);
526        } else {
527          return undef;
528        }
529      }; # $decode
530    
531    my $options = sub ($) {    my $options = sub ($) {
532      my $context = shift;      my $context = shift;
533    
# Line 554  sub generate_input_section ($$) { Line 601  sub generate_input_section ($$) {
601        $out->nl_text ('Setting innerHTML');        $out->nl_text ('Setting innerHTML');
602        $out->text (': ');        $out->text (': ');
603        $out->start_tag ('input', name => 'e',        $out->start_tag ('input', name => 'e',
604                         value => scalar $cgi->get_parameter ('e'));                         value => $decode->(scalar $cgi->get_parameter ('e')));
605        $out->end_tag ('label');        $out->end_tag ('label');
606      }      }
607    
# Line 578  sub generate_input_section ($$) { Line 625  sub generate_input_section ($$) {
625    $out->start_tag ('input',    $out->start_tag ('input',
626                     name => 'uri',                     name => 'uri',
627                     type => 'url',                     type => 'url',
628                     value => $cgi->get_parameter ('uri'));                     value => $decode->(scalar $cgi->get_parameter ('uri')));
629    $out->end_tag ('label');    $out->end_tag ('label');
630    
631    $out->start_tag ('p');    $out->start_tag ('p');
# Line 591  sub generate_input_section ($$) { Line 638  sub generate_input_section ($$) {
638    $out->end_tag ('form');    $out->end_tag ('form');
639    $out->end_section;    $out->end_section;
640    
   $out->end_tag ('fieldset');  
   
641    ## TODO: File upload    ## TODO: File upload
642    
643    $out->start_section (id => 'input-text', title => 'By direct input',    $out->start_section (id => 'input-text', title => 'By direct input',
# Line 609  sub generate_input_section ($$) { Line 654  sub generate_input_section ($$) {
654    $out->start_tag ('br');    $out->start_tag ('br');
655    $out->start_tag ('textarea',    $out->start_tag ('textarea',
656                     name => 's');                     name => 's');
657    my $s = $cgi->get_parameter ('s');    my $s = $decode->($cgi->get_parameter ('s'));
658    $out->html ($htescape_value->($s)) if defined $s;    $out->html ($htescape_value->($s)) if defined $s;
659    $out->end_tag ('textarea');    $out->end_tag ('textarea');
660    $out->end_tag ('label');    $out->end_tag ('label');

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.19

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24