206 |
$r .= qq{\$SuikaWiki::Format::Definition::Class{@{[literal $type.'//']}} = '$module_name';\n}; |
$r .= qq{\$SuikaWiki::Format::Definition::Class{@{[literal $type.'//']}} = '$module_name';\n}; |
207 |
} |
} |
208 |
|
|
209 |
$r .= line $Info, line_no => __LINE__ + 2, realfile => __FILE__; |
my $convert = line $Info, line_no => __LINE__ + 2, realfile => __FILE__; |
210 |
$r .= <<'EOH'; |
$convert .= <<'EOH'; |
211 |
our $Converter; |
our $Converter; |
212 |
sub convert ($$;%) { |
sub convert ($$;%) { |
213 |
my ($self, $source, %opt) = @_; |
my ($self, $source, %opt) = @_; |
225 |
} |
} |
226 |
EOH |
EOH |
227 |
|
|
|
my $reset = 0; |
|
228 |
for (@{$src->child_nodes}) { |
for (@{$src->child_nodes}) { |
229 |
if ($_->local_name eq 'Converter') { |
if ($_->local_name eq 'Converter') { |
230 |
$r .= line $Info, reset => 1 unless $reset; |
if ($convert) { |
231 |
|
$r .= $convert; |
232 |
|
$r .= line $Info, reset => 1; |
233 |
|
undef $convert; |
234 |
|
} |
235 |
$r .= make_format_converter ($_, $Info); |
$r .= make_format_converter ($_, $Info); |
|
$reset = 1; |
|
236 |
} elsif ($_->local_name eq 'Use') { |
} elsif ($_->local_name eq 'Use') { |
237 |
$r .= line $Info, node_path => qq(Format[module-name()=$module_name]/Use); |
$r .= line $Info, node_path => qq(Format[module-name()=$module_name]/Use); |
238 |
$r .= $_->inner_text; |
$r .= $_->inner_text; |
|
$reset = 0; |
|
239 |
} |
} |
240 |
} |
} |
|
$r .= line $Info, reset => 1 unless $reset; |
|
|
|
|
241 |
$r; |
$r; |
242 |
} |
} |
243 |
|
|
378 |
EOH |
EOH |
379 |
for (@{$src->child_nodes}) { |
for (@{$src->child_nodes}) { |
380 |
if ($_->local_name eq 'template') { |
if ($_->local_name eq 'template') { |
381 |
$r .= make_view_template_method ($_, $Info); |
$r .= make_view_template_method ($_, $Info, $ViewProp); |
382 |
} elsif ($_->local_name eq 'method') { |
} elsif ($_->local_name eq 'method') { |
383 |
my $method_name = $_->get_attribute_value ('Name'); |
my $method_name = $_->get_attribute_value ('Name'); |
384 |
$r .= ({ |
$r .= ({ |
385 |
main => q(sub main ($$) {)."\n".q(my ($self, $opt) = @_;)."\n", |
main => q(sub main ($$) {)."\n".q(my ($self, $opt, $opt2) = @_;)."\n", |
386 |
main_pre => q(sub main_pre ($$$) {)."\n".q(my ($self, $opt, $opt2) = @_;)."\n", |
main_pre => q(sub main_pre ($$$) {)."\n".q(my ($self, $opt, $opt2) = @_;)."\n", |
387 |
main_post => q(sub main_post ($$$) {)."\n".q(my ($self, $opt, $opt2) = @_;)."\n", |
main_post => q(sub main_post ($$$) {)."\n".q(my ($self, $opt, $opt2) = @_;)."\n", |
388 |
}->{$method_name} |
}->{$method_name} |
400 |
} |
} |
401 |
|
|
402 |
sub make_view_template_method ($$) { |
sub make_view_template_method ($$) { |
403 |
my ($src, $info) = @_; |
my ($src, $Info, $ViewProp) = @_; |
404 |
my $r = <<EOH; |
my $r = <<EOH; |
405 |
|
|
406 |
sub main (\$\$\$) { |
sub main (\$\$\$) { |
419 |
## Compatible options for SuikaWiki 2 WikiPlugin interface |
## Compatible options for SuikaWiki 2 WikiPlugin interface |
420 |
param => \\\%main::form, |
param => \\\%main::form, |
421 |
page => \$main::form{mypage}, |
page => \$main::form{mypage}, |
422 |
toc => [], |
#toc => [], |
423 |
#magic |
#magic |
424 |
#content |
#content |
425 |
#use_anchor_name |
#use_anchor_name |
440 |
@{[do{my $x=$src->get_attribute('http-status-code',make_new_node=>1)->inner_text; |
@{[do{my $x=$src->get_attribute('http-status-code',make_new_node=>1)->inner_text; |
441 |
$x?q{$opt2->{output}->{status_code} = }.(0 + $x).q{;}:q{}}]} |
$x?q{$opt2->{output}->{status_code} = }.(0 + $x).q{;}:q{}}]} |
442 |
@{[do{my $x=$src->get_attribute('http-status-phrase',make_new_node=>1)->inner_text; |
@{[do{my $x=$src->get_attribute('http-status-phrase',make_new_node=>1)->inner_text; |
443 |
$x?q{$opt2->{output}->{reason_phrase} = }.literal($x).q{;}:q{}}]} |
$x?q{$opt2->{output}->{status_phrase} = }.literal($x).q{;}:q{}}]} |
444 |
\$opt2->{output}->{entity}->{media_type} = @{[literal |
\$opt2->{output}->{entity}->{media_type} = @{[literal |
445 |
$src->get_attribute ('media-type',make_new_node=>1) |
$src->get_attribute ('media-type',make_new_node=>1) |
446 |
->inner_text || 'application/octet-stream']}; |
->inner_text || 'application/octet-stream']}; |
459 |
\$self->{view}->{wiki}->init_db; |
\$self->{view}->{wiki}->init_db; |
460 |
\$self->main_pre (\$opt, \$opt2); |
\$self->main_pre (\$opt, \$opt2); |
461 |
|
|
462 |
my \$fmt = SuikaWiki::Plugin->formatter ('view'); |
use Message::Util::Error; |
463 |
\$opt2->{output}->{entity}->{body} |
try { |
464 |
= \$fmt->replace (\$opt2->{template}, param => \$opt2->{o}); |
\$opt2->{output}->{entity}->{body} |
465 |
|
= SuikaWiki::Plugin->formatter ('view') |
466 |
|
->replace (\$opt2->{template}, param => \$opt2->{o}); |
467 |
|
} \$self->{view}->{wiki}->{config}->{catch}->{ @{[ |
468 |
|
$ViewProp->{Name} eq '-error' ? 'formatter_view_error' |
469 |
|
: 'formatter_view' ]} }; |
470 |
\$opt2->{output}->output (output => 'http-cgi'); |
\$opt2->{output}->output (output => 'http-cgi'); |
471 |
|
|
472 |
\$self->main_post (\$opt, \$opt2); |
\$self->main_post (\$opt, \$opt2); |