56 |
sub code ($$) { |
sub code ($$) { |
57 |
my ($Info, $code) = @_; |
my ($Info, $code) = @_; |
58 |
for (keys %{$Info->{const}}) { |
for (keys %{$Info->{const}}) { |
59 |
$code =~ s/\$$_\b/literal $Info->{const}->{$_}/ge; |
$code =~ s/\$$_\b/$Info->{const}->{$_}/ge; |
60 |
} |
} |
61 |
$code =~ s/__FUNCPACK__/$Info->{module_name}/g; |
$code =~ s/__FUNCPACK__/$Info->{module_name}/g; |
62 |
$code; |
$code; |
227 |
my $flag = '//'; |
my $flag = '//'; |
228 |
$flag .= 'f' if $opt{IsFragment}; |
$flag .= 'f' if $opt{IsFragment}; |
229 |
$flag .= 'p' if $opt{IsPlaceholder}; |
$flag .= 'p' if $opt{IsPlaceholder}; |
230 |
if ($Converter->{$opt{Type}.$flag}) { |
my $type = $opt{Type} ? |
231 |
$converter = $Converter->{$opt{Type}.$flag}; |
$opt{Type} . |
232 |
|
SuikaWiki::Format::Definition->__get_param_string |
233 |
|
($opt{Type_param}) : undef; |
234 |
|
if ($Converter->{$type.$flag}) { |
235 |
|
$converter = $Converter->{$type.$flag}; |
236 |
} elsif ($Converter->{$opt{Name}.'/'.$opt{Version}.$flag}) { |
} elsif ($Converter->{$opt{Name}.'/'.$opt{Version}.$flag}) { |
237 |
$converter = $Converter->{'/'.$opt{Name}.'/'.$opt{Version}.$flag}; |
$converter = $Converter->{'/'.$opt{Name}.'/'.$opt{Version}.$flag}; |
238 |
} |
} |
239 |
return $converter->{Main}->($self, $source, \%opt) if $converter; |
return ($converter->{$opt{return_type} or 'Main'} or |
240 |
|
CORE::die "Buggy implementation: $type $opt{Name}/$opt{Version}$flag/@{[$opt{return_type} or 'Main']} not defined") |
241 |
|
->($self, $source, \%opt) |
242 |
|
if $converter; |
243 |
$self->SUPER::convert ($source, %opt); |
$self->SUPER::convert ($source, %opt); |
244 |
} |
} |
245 |
EOH |
EOH |
258 |
$r .= code $Info, $_->get_attribute_value ('Main'); |
$r .= code $Info, $_->get_attribute_value ('Main'); |
259 |
$r .= line $Info, reset => 1; |
$r .= line $Info, reset => 1; |
260 |
$r .= qq(}\n); |
$r .= qq(}\n); |
261 |
|
} elsif ($_->local_name eq 'HeadSummary') { |
262 |
|
$r .= q(sub headsummary {)."\n".q(my ($self, $source, %opt) = @_;); |
263 |
|
$r .= line $Info, node_path => qq(Format[module-name()=$module_name]/HeadSummary); |
264 |
|
$r .= code $Info, $_->get_attribute_value ('Main'); |
265 |
|
$r .= line $Info, reset => 1; |
266 |
|
$r .= qq(}\n); |
267 |
} elsif ($_->local_name eq 'NextIndex') { |
} elsif ($_->local_name eq 'NextIndex') { |
268 |
my $name = $_->get_attribute_value ('Name', default => ''); |
my $name = $_->get_attribute_value ('Name', default => ''); |
269 |
$r .= q(sub next_index_for_).$name |
$r .= q(sub next_index_for_).$name |
306 |
$flag .= 'p' and $def{IsPlaceholder} = 1 |
$flag .= 'p' and $def{IsPlaceholder} = 1 |
307 |
if $src->get_attribute_value ('IsPlaceholder'); |
if $src->get_attribute_value ('IsPlaceholder'); |
308 |
|
|
309 |
$def{Main} = $src->get_attribute_value ('Main'); |
for (qw/Main ToString ToOctetStream/) { |
310 |
$def{Main} = line ($Info, node_path => '//Converter/Main') |
my $def = $src->get_attribute_value ($_); |
311 |
. $def{Main} |
next unless $def; |
312 |
. line ($Info, reset => 1); |
$def{$_} = line ($Info, node_path => '//Converter/'.$_) |
313 |
if ($def{Main} =~ /\$r\b/) { |
. $def |
314 |
$def{Main} = 'my $r;'."\n".$def{Main}."\n".'$r'; |
. line ($Info, reset => 1); |
315 |
} |
if ($def{$_} =~ /\$r\b/) { |
316 |
$def{Main} = barecode code $Info, |
$def{$_} = 'my $r;'."\n".$def{$_}."\n".'$r'; |
317 |
'sub {my ($self, $source, $opt) = @_;' |
} |
318 |
. $def{Main} . '}'; |
$def{$_} = barecode code $Info, |
319 |
|
'sub {my ($self, $source, $opt) = @_;' |
320 |
|
. $def{$_} . '}'; |
321 |
|
} |
322 |
|
|
323 |
my $r = list %def; |
my $r = list %def; |
324 |
if ($def{Type}) { |
if ($def{Type}) { |
351 |
sub register_plugin_const ($$) { |
sub register_plugin_const ($$) { |
352 |
my ($src, $Info) = @_; |
my ($src, $Info) = @_; |
353 |
for (@{$src->child_nodes}) { |
for (@{$src->child_nodes}) { |
354 |
$Info->{const}->{$_->local_name} = $_->value; |
$Info->{const}->{$_->local_name} = literal_or_code $Info, $_->value; |
355 |
} |
} |
356 |
} |
} |
357 |
|
|
421 |
@{[change_package $Info, $ViewProp->{pack_name}]} |
@{[change_package $Info, $ViewProp->{pack_name}]} |
422 |
our \@ISA = q#SuikaWiki::View::template#; |
our \@ISA = q#SuikaWiki::View::template#; |
423 |
EOH |
EOH |
424 |
|
|
425 |
|
my $use = $src->get_attribute ('Use'); |
426 |
|
if (ref $use) { |
427 |
|
$r .= line $Info, node_path => "ViewDefinition[Mode='$ViewProp->{Name}']/Use"; |
428 |
|
$r .= $use->inner_text . "\n\n"; |
429 |
|
} |
430 |
|
|
431 |
for (@{$src->child_nodes}) { |
for (@{$src->child_nodes}) { |
432 |
if ($_->local_name eq 'template') { |
if ($_->local_name eq 'template') { |
433 |
$r .= make_view_template_method ($_, $Info, $ViewProp); |
$r .= make_view_template_method ($_, $Info, $ViewProp); |
468 |
|
|
469 |
\$opt2->{template} = @{[literal $src->get_attribute ('body', make_new_node => 1)->inner_text]}; |
\$opt2->{template} = @{[literal $src->get_attribute ('body', make_new_node => 1)->inner_text]}; |
470 |
\$opt2->{o} = bless { |
\$opt2->{o} = bless { |
|
## Compatible options for SuikaWiki 2 WikiPlugin interface |
|
|
param => \\\%main::form, |
|
|
page => \$main::form{mypage}, |
|
|
#toc => [], |
|
|
#magic |
|
|
#content |
|
|
#use_anchor_name |
|
|
media => {@{[hash |
|
|
type => ($src->get_attribute ('media-type',make_new_node=>1)->inner_text |
|
|
|| 'application/octet-stream'), |
|
|
charset => ($src->get_attribute ('use-media-type-charset',make_new_node=>1) |
|
|
->inner_text || 0), |
|
|
## In fact, this value is not referred from any SuikaWiki 2 WikiPlugin rule. |
|
|
#expires => ($src->get_attribute ('expires',make_new_node=>1)->inner_text |
|
|
# || 0) |
|
|
]}}, |
|
471 |
## SuikaWiki 3 WikiPlugin interface |
## SuikaWiki 3 WikiPlugin interface |
472 |
wiki => \$self->{view}->{wiki}, |
wiki => \$self->{view}->{wiki}, |
473 |
plugin => \$self->{view}->{wiki}->{plugin}, |
plugin => \$self->{view}->{wiki}->{plugin}, |
491 |
qq{\$opt2->{output}->set_expires (delta => @{[0 + $x]});}; |
qq{\$opt2->{output}->set_expires (delta => @{[0 + $x]});}; |
492 |
} |
} |
493 |
}]} |
}]} |
494 |
|
\$opt2->{output}->{entity}->{body_is_octet_stream} = @{[ |
495 |
|
$src->get_attribute ('body')->get_attribute_value ('is-octet-stream', default_value => 0) |
496 |
|
or 0 |
497 |
|
]}; |
498 |
|
|
499 |
\$self->{view}->{wiki}->init_db; |
\$self->{view}->{wiki}->init_db; |
500 |
\$self->main_pre (\$opt, \$opt2); |
\$self->main_pre (\$opt, \$opt2); |
532 |
"FormattingRule[name()='@{[list $type]}/$name']/".$codename->[0]) |
"FormattingRule[name()='@{[list $type]}/$name']/".$codename->[0]) |
533 |
. $main; |
. $main; |
534 |
|
|
535 |
$main = q{my ($f, $rule_name, $p, $o, %opt) = @_;}."\n".$main |
if ( $main =~ /\$f\b/ |
|
if $main =~ /\$f\b/ |
|
536 |
or $main =~ /\$rule_name\b/ |
or $main =~ /\$rule_name\b/ |
537 |
or $main =~ /\$[opr]\b/ |
or $main =~ /\$[opr]\b/ |
538 |
or $main =~ /[%\$]opt\b/; |
or $main =~ /[%\$]opt\b/ |
539 |
|
or $main =~ /\$param_(?:name|value)\n/) { |
540 |
|
if ($codename->[0] ne 'Attribute') { |
541 |
|
$main = q{my ($f, $rule_name, $p, $o, %opt) = @_;}."\n".$main; |
542 |
|
} else { |
543 |
|
$main = q{my ($f, $rule_name, $p, $o, $param_name => $param_value, %opt) = @_;}."\n".$main; |
544 |
|
} |
545 |
|
} |
546 |
if ($main =~ /\$r\b/) { |
if ($main =~ /\$r\b/) { |
547 |
warn qq(Rule @{[list $type]}/$name: Use of \$r is deprecated); |
warn qq(Rule @{[list $type]}/$name: Use of \$r is deprecated); |
548 |
$main = q{my $r = '';} . "\n" . $main . "\n" |
$main = q{my $r = '';} . "\n" . $main . "\n" |