16 |
return $s; |
return $s; |
17 |
}; |
}; |
18 |
|
|
19 |
|
my $htescape_value = sub ($) { |
20 |
|
my $s = $_[0]; |
21 |
|
$s =~ s/&/&/g; |
22 |
|
$s =~ s/</</g; |
23 |
|
$s =~ s/>/>/g; |
24 |
|
$s =~ s/"/"/g; |
25 |
|
return $s; |
26 |
|
}; |
27 |
|
|
28 |
sub new ($) { |
sub new ($) { |
29 |
require WebHACC::Input; |
require WebHACC::Input; |
30 |
return bless {nav => [], section_rank => 1, |
return bless {nav => [], section_rank => 1, |
84 |
|
|
85 |
sub start_tag ($$%) { |
sub start_tag ($$%) { |
86 |
my ($self, $tag_name, %opt) = @_; |
my ($self, $tag_name, %opt) = @_; |
87 |
$self->html ('<' . $htescape->($tag_name)); # escape for safety |
$self->html ('<' . $htescape_value->($tag_name)); # escape for safety |
88 |
if (exists $opt{id}) { |
if (exists $opt{id}) { |
89 |
my $id = $self->input->id_prefix . $opt{id}; |
my $id = $self->input->id_prefix . $opt{id}; |
90 |
$self->html (' id="' . $htescape->($id) . '"'); |
$self->html (' id="' . $htescape_value->($id) . '"'); |
91 |
delete $opt{id}; |
delete $opt{id}; |
92 |
} |
} |
93 |
for (keys %opt) { # for safety |
for (keys %opt) { # for safety |
94 |
$self->html (' ' . $htescape->($_) . '="' . $htescape->($opt{$_}) . '"'); |
$self->html (' ' . $htescape_value->($_) . '="' . |
95 |
|
$htescape_value->($opt{$_}) . '"'); |
96 |
} |
} |
97 |
$self->html ('>'); |
$self->html ('>'); |
98 |
} # start_tag |
} # start_tag |
99 |
|
|
100 |
sub end_tag ($$) { |
sub end_tag ($$) { |
101 |
shift->html ('</' . $htescape->(shift) . '>'); |
shift->html ('</' . $htescape_value->(shift) . '>'); |
102 |
} # end_tag |
} # end_tag |
103 |
|
|
104 |
sub start_section ($%) { |
sub start_section ($%) { |
306 |
return join '/', @r; |
return join '/', @r; |
307 |
}; # $get_node_path |
}; # $get_node_path |
308 |
|
|
309 |
|
my $get_object_path = sub ($) { |
310 |
|
my $node = shift; |
311 |
|
my @r; |
312 |
|
while (defined $node) { |
313 |
|
my $ref = ref $node; |
314 |
|
$ref =~ /([^:]+)$/; |
315 |
|
my $rs = $1; |
316 |
|
my $node_name = $node->node_name; |
317 |
|
if (defined $node_name) { |
318 |
|
$rs .= ' <code>' . $htescape->($node_name) . '</code>'; |
319 |
|
} |
320 |
|
$node = undef; |
321 |
|
unshift @r, $rs; |
322 |
|
} |
323 |
|
return join '/', @r; |
324 |
|
}; # $get_object_path |
325 |
|
|
326 |
sub node_link ($$) { |
sub node_link ($$) { |
327 |
my ($self, $node) = @_; |
my ($self, $node) = @_; |
328 |
$self->xref ($get_node_path->($node), target => 'node-' . refaddr $node); |
if ($node->isa ('Message::IF::Node')) { |
329 |
|
$self->xref ($get_node_path->($node), target => 'node-' . refaddr $node); |
330 |
|
} else { |
331 |
|
$self->html ($get_object_path->($node)); |
332 |
|
} |
333 |
} # node_link |
} # node_link |
334 |
|
|
335 |
{ |
{ |
523 |
$out->start_section (id => 'input', title => 'Input'); |
$out->start_section (id => 'input', title => 'Input'); |
524 |
|
|
525 |
$out->start_section (id => 'input-url', title => 'By URL'); |
$out->start_section (id => 'input-url', title => 'By URL'); |
526 |
$out->start_tag ('form', action => './', 'accept-charset' => 'utf-8', |
$out->start_tag ('form', action => './#result-summary', |
527 |
|
'accept-charset' => 'utf-8', |
528 |
method => 'get'); |
method => 'get'); |
529 |
$out->start_tag ('input', type => 'hidden', name => '_charset_'); |
$out->start_tag ('input', type => 'hidden', name => '_charset_'); |
530 |
|
|
552 |
## TODO: File upload |
## TODO: File upload |
553 |
|
|
554 |
$out->start_section (id => 'input-text', title => 'By direct input'); |
$out->start_section (id => 'input-text', title => 'By direct input'); |
555 |
$out->start_tag ('form', action => './', 'accept-charset' => 'utf-8', |
$out->start_tag ('form', action => './#result-summary', |
556 |
|
'accept-charset' => 'utf-8', |
557 |
method => 'post'); |
method => 'post'); |
558 |
$out->start_tag ('input', type => 'hidden', name => '_charset_'); |
$out->start_tag ('input', type => 'hidden', name => '_charset_'); |
559 |
|
|
565 |
$out->start_tag ('textarea', |
$out->start_tag ('textarea', |
566 |
name => 's'); |
name => 's'); |
567 |
my $s = $cgi->get_parameter ('s'); |
my $s = $cgi->get_parameter ('s'); |
568 |
$out->text ($s) if defined $s; |
$out->html ($htescape_value->($s)) if defined $s; |
569 |
$out->end_tag ('textarea'); |
$out->end_tag ('textarea'); |
570 |
$out->end_tag ('label'); |
$out->end_tag ('label'); |
571 |
|
|