50 |
# |
# |
51 |
# You MAY modify following variables. |
# You MAY modify following variables. |
52 |
# |
# |
53 |
|
$SuikaWiki::Plugin::plugin_directory = q(./SuikaWiki/Plugin/); |
54 |
my $file_touch = "$modifier_dir_data/touched.txt"; |
my $file_touch = "$modifier_dir_data/touched.txt"; |
55 |
my $file_resource = "$modifier_dir_data/resource.txt"; |
my $file_resource = "$modifier_dir_data/resource.txt"; |
56 |
my $file_FrontPage = "$modifier_dir_data/frontpage.txt"; |
my $file_FrontPage = "$modifier_dir_data/frontpage.txt"; |
119 |
$CompletedSuccessfully => 1, |
$CompletedSuccessfully => 1, |
120 |
#$FrontPage => 1, |
#$FrontPage => 1, |
121 |
WikiUserAgentList => 1, |
WikiUserAgentList => 1, |
122 |
|
WikiPluginInfo => 1, |
123 |
); |
); |
124 |
my %form; |
my %form; |
125 |
my %database; |
my %database; |
135 |
$RssPage => 'rss', |
$RssPage => 'rss', |
136 |
$AdminChangePassword => 'adminchangepasswordform', |
$AdminChangePassword => 'adminchangepasswordform', |
137 |
#$FrontPage => 'FrontPage', |
#$FrontPage => 'FrontPage', |
138 |
|
WikiPluginInfo => 'x_WikiPluginInfo', |
139 |
); |
); |
140 |
my %command_do = ( |
my %command_do = ( |
141 |
read => \&do_read, |
read => \&do_read, |
157 |
diff => \&do_diff, |
diff => \&do_diff, |
158 |
interwikibox => \&do_interwiki_box, # Walrus add (5) |
interwikibox => \&do_interwiki_box, # Walrus add (5) |
159 |
wikiform => \&do_wikiform, |
wikiform => \&do_wikiform, |
160 |
|
x_WikiPluginInfo => \&do_wikiplugininfo, |
161 |
); |
); |
162 |
############################## |
############################## |
163 |
my $walversion = '2.0.beta1.wal.1'; # Walrus add (1) |
my $walversion = '2.0.beta1.wal.1'; # Walrus add (1) |
164 |
############################## |
############################## |
165 |
# &test_convert; |
# &test_convert; |
166 |
my $UA = ''; ## User agent name |
my $UA = ''; ## User agent name |
|
&main; |
|
|
exit(0); |
|
167 |
############################## |
############################## |
168 |
|
|
169 |
sub main { |
sub main { |
217 |
} |
} |
218 |
|
|
219 |
sub do_output_css { |
sub do_output_css { |
220 |
|
wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); |
221 |
|
wiki::useragent::add ($ENV{HTTP_USER_AGENT}); |
222 |
my $content = $database{$form{mypage}}; |
my $content = $database{$form{mypage}}; |
223 |
if ($content =~ m#^\s*/\*\s*W3C-CSS#) { |
if ($content =~ m#^\s*/\*\s*W3C-CSS#) { |
224 |
my $lm = &get_info($form{mypage}, $info_LastModified); |
my $lm = &get_info($form{mypage}, $info_LastModified); |
225 |
|
print scalar make_navigate_links ($form{mypage}); |
226 |
print "Content-Type: text/css; charset=$charset\n"; |
print "Content-Type: text/css; charset=$charset\n"; |
227 |
print "Last-Modified: $lm\n"; |
print "Last-Modified: $lm\n"; |
228 |
print "\n"; |
print "\n"; |
237 |
|
|
238 |
sub id_and_name ($) { |
sub id_and_name ($) { |
239 |
my $name = shift; |
my $name = shift; |
240 |
if ($UA =~ m#Mozilla/[12]\.#) { |
if ($UA =~ m#Mozilla/[12]\.|Microsoft Internet Explorer#) { |
241 |
qq{id="$name"><a name="$name"></a}; |
qq{id="$name"><a name="$name"></a}; |
242 |
} else { |
} else { |
243 |
qq{id="$name"}; |
qq{id="$name"}; |
314 |
} |
} |
315 |
|
|
316 |
sub do_index { |
sub do_index { |
317 |
|
wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); |
318 |
|
wiki::useragent::add ($ENV{HTTP_USER_AGENT}); |
319 |
&print_header($IndexPage); |
&print_header($IndexPage); |
320 |
print qq(<ul>); |
print qq(<ul>); |
321 |
foreach my $page (sort keys %database) { |
foreach my $page (sort keys %database) { |
326 |
} |
} |
327 |
} |
} |
328 |
print qq(</ul>); |
print qq(</ul>); |
329 |
|
my ($r, $c) = get_search_result ($form{mypage}); |
330 |
|
if ($c) { |
331 |
|
print qq{<h2 @{[&id_and_name('wikipage-see-also')]}>See also</h2>}; |
332 |
|
print $r; |
333 |
|
} |
334 |
|
my $rl = wiki::referer::list_html ($form{mypage}); |
335 |
|
if ($rl) { |
336 |
|
print qq(<div @{[&id_and_name('wikipage-referer')]}><h2>??????</h2>\n$rl</div>\n); |
337 |
|
} |
338 |
&print_footer($IndexPage); |
&print_footer($IndexPage); |
339 |
} |
} |
340 |
|
|
371 |
&update_recent_changes; |
&update_recent_changes; |
372 |
} |
} |
373 |
&set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen}); |
&set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen}); |
374 |
my $fragment; |
my $fragment = ''; |
375 |
|
$fragment .= qq(;after_edit_cmd=@{[&encode($form{after_edit_cmd})]}) if $form{after_edit_cmd}; |
376 |
if ($form{__comment_anchor_index}) { |
if ($form{__comment_anchor_index}) { |
377 |
$fragment = qq(anchor-$form{__comment_anchor_index}); |
$fragment .= qq(#anchor-$form{__comment_anchor_index}); |
378 |
} elsif ($form{__wikiform_anchor_index}) { |
} elsif ($form{__wikiform_anchor_index}) { |
379 |
$fragment = qq(wikiform-$form{__wikiform_anchor_index}); |
$fragment .= qq(#wikiform-$form{__wikiform_anchor_index}); |
380 |
} |
} |
381 |
&print_header($CompletedSuccessfully, -noindex => 1, -goto => $url_cgi.'?mycmd=read;mypage='.&encode($form{mypage}).qq(;x-param=@{[time.[0..9]->[rand 10]]}).($fragment?'#'.$fragment:'')); |
&print_header($CompletedSuccessfully, -noindex => 1, -goto => $url_cgi.'?mycmd='.&encode($form{after_edit_cmd}||'read').';mypage='.&encode($form{mypage}).qq(;x-param=@{[time.[0..9]->[rand 10]]}$fragment)); |
382 |
&print_message($resource{saved}); |
&print_message($resource{saved}); |
383 |
&print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}"); |
&print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}"); |
384 |
&print_footer($CompletedSuccessfully); |
&print_footer($CompletedSuccessfully); |
484 |
} |
} |
485 |
$bodyclass .= " wiki-page-obsoleted" if $option{-content_format} =~ /obsoleted="yes"/; |
$bodyclass .= " wiki-page-obsoleted" if $option{-content_format} =~ /obsoleted="yes"/; |
486 |
if ($option{-goto}) { |
if ($option{-goto}) { |
487 |
if ($UA =~ m#Mozilla/[12]\.|Opera#) { |
if ($UA =~ m#Opera|MSIE 2\.#) { |
488 |
$option{-goto} =~ tr/;/&/; |
$option{-goto} =~ tr/;/&/ if $UA =~ m#Opera#; |
489 |
print qq{Refresh: 0; url=$option{-goto}\n}; |
print qq{Refresh: 0; url=$option{-goto}\n}; |
490 |
$option{-goto} = qq(<meta http-equiv="refresh" content="0; url=$option{-goto}">); |
$option{-goto} = qq(<meta http-equiv="refresh" content="0; url=$option{-goto}">); |
491 |
} else { |
} else { |
492 |
|
$option{-goto} =~ tr/;/&/ if $UA =~ m#Mozilla/[1-4]\.#; |
493 |
print qq{Refresh: 0; url="$option{-goto}"\n}; |
print qq{Refresh: 0; url="$option{-goto}"\n}; |
494 |
$option{-goto} = qq(<meta http-equiv="refresh" content="0; url="@{[&escape($option{-goto})]}"">); |
$option{-goto} = qq(<meta http-equiv="refresh" content="0; url="@{[&escape($option{-goto})]}"">); |
495 |
} |
} |
500 |
$meta_ct = qq{text/html; charset=@{[&x_charset($charset)]}}; |
$meta_ct = qq{text/html; charset=@{[&x_charset($charset)]}}; |
501 |
print qq{Content-Type: $meta_ct\n}; |
print qq{Content-Type: $meta_ct\n}; |
502 |
$meta_ct = qq{<meta http-equiv="content-type" content="$meta_ct">}; |
$meta_ct = qq{<meta http-equiv="content-type" content="$meta_ct">}; |
503 |
|
} elsif ($UA =~ m#Infomosaic#) { |
504 |
|
print qq{Content-Type: text/html\n}; |
505 |
} else { |
} else { |
506 |
print qq{Content-Type: text/html; charset=$charset\n}; |
print qq{Content-Type: text/html; charset=$charset\n}; |
507 |
} |
} |
508 |
my $cookedpage = &encode($page); |
my $cookedpage = &encode($page); |
509 |
my $escapedpage = &escape($page); |
my $escapedpage = &escape($page); |
510 |
|
my ($Links, $links) = &make_navigate_links ($page); |
511 |
|
print $Links; |
512 |
print <<"EOD"; |
print <<"EOD"; |
513 |
Content-Language: $lang |
Content-Language: $lang |
514 |
Content-Style-Type: text/css |
Content-Style-Type: text/css |
518 |
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
519 |
"http://www.w3.org/TR/html4/loose.dtd"> + RUBY --> |
"http://www.w3.org/TR/html4/loose.dtd"> + RUBY --> |
520 |
<html lang="$lang"> |
<html lang="$lang"> |
521 |
<head> |
<head profile="http://suika.fam.cx/~wakaba/-temp/wiki/wiki?WikiHTMLMetaProfile"> |
522 |
$meta_ct$option{-goto} |
$meta_ct$option{-goto} |
523 |
<title>$escapedpage</title> |
<title>$escapedpage</title> |
524 |
<link rel="index" href="$url_cgi?$IndexPage"> |
@{[($UA !~ m#Mozilla/[1-4]\.# || $UA =~ m#MSIE (?:[4-9]\.|\d\d)#) ? qq(<link rel="stylesheet" type="text/css" href="@{[&escape($url_stylesheet)]}">) : '']} |
|
<link rel="help" href="$url_cgi?WikiHelp"> |
|
|
<link rel="copyright" href="$url_cgi?$NAME_OF_WikiPageLicense"> |
|
|
<link rel="stylesheet" type="text/css" href="@{[&escape($url_stylesheet)]}"> |
|
525 |
@{[$option{-noindex} ? q(<meta name="ROBOTS" content="NOINDEX">) : '']} |
@{[$option{-noindex} ? q(<meta name="ROBOTS" content="NOINDEX">) : '']} |
526 |
|
$links |
527 |
</head> |
</head> |
528 |
<body class="$bodyclass"> |
<body class="$bodyclass"> |
529 |
EOD |
EOD |
560 |
print <<EOH; |
print <<EOH; |
561 |
<div class="tools"> |
<div class="tools"> |
562 |
@{[ $admineditable |
@{[ $admineditable |
563 |
? qq(<a title="$resource{admineditthispage}" href="$url_cgi?mycmd=adminedit;mypage=$cookedpage">$resource{admineditbutton}</a> | ) |
? qq(<a title="$resource{admineditthispage}" href="$url_cgi?mycmd=adminedit;mypage=$cookedpage" class="wiki-cmd">$resource{admineditbutton}</a> | ) |
564 |
: qq() |
: qq() |
565 |
]} |
]} |
566 |
@{[ $editable |
@{[ $editable |
567 |
? #qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedpage" accesskey="E">$resource{editbutton} <kbd>E</kbd></a> | ) |
? #qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedpage" accesskey="E">$resource{editbutton} <kbd>E</kbd></a> | ) |
568 |
qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedpage" accesskey="E">編集</a> | ) |
qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedpage" accesskey="E" class="wiki-cmd">編集</a> | ) |
569 |
: qq() |
: qq() |
570 |
]} |
]} |
571 |
<a href="$url_cgi?mycmd=read;mypage=$cookedpage;x-param=@{[time.[0..9]->[rand 10]]}">表示</a> | |
<a href="$url_cgi?mycmd=read;mypage=$cookedpage;x-param=@{[time.[0..9]->[rand 10]]}" class="wiki-cmd">表示</a> | |
572 |
@{[ $admineditable |
@{[ $admineditable |
573 |
? qq(<a href="$url_cgi?mycmd=diff;mypage=$cookedpage">$resource{diffbutton}</a> | ) |
? qq(<a href="$url_cgi?mycmd=diff;mypage=$cookedpage" class="wiki-cmd">$resource{diffbutton}</a> | ) |
574 |
: qq() |
: qq() |
575 |
]} |
]} |
576 |
<a href="$url_cgi?$CreatePage" class="wiki">新規</a> | |
<a href="$url_cgi?$CreatePage" class="wiki">新規</a> | |
581 |
<a href="$url_cgi?$RecentChanges" class="wiki">最新</a> |
<a href="$url_cgi?$RecentChanges" class="wiki">最新</a> |
582 |
</div> |
</div> |
583 |
EOH |
EOH |
584 |
<<EOH; ## temp |
} |
585 |
<a href="$url_cgi?$CreatePage" class="wiki">$resource{createbutton}</a> | |
|
586 |
<a href="$url_cgi?$IndexPage" class="wiki">$resource{indexbutton}</a> | |
sub make_navigate_links ($) { |
587 |
<!-- <a href="$url_cgi?$RssPage" class="wiki">$resource{rssbutton}</a> | --> |
my $page = shift; |
588 |
<a href="$url_cgi?$FrontPage" class="wiki">$FrontPage</a> | |
my @link; |
589 |
<a href="$url_cgi?$SearchPage" class="wiki">$resource{searchbutton}</a> | |
push @link, {rel=>'edit', href=>"$url_cgi?mycmd=edit;mypage=@{[&encode($page)]}", class=>"wiki-command", title=>$resource{editbutton}} if &is_editable ($page) && !&is_frozen ($page); |
590 |
<a href="$url_cgi?mycmd=RandomJump;x-param=@{[time.[0..9]->[rand 10]]}" class="wiki randomlink">どこか</a> | |
push @link, {rel=>'edit', href=>"$url_cgi?mycmd=adminedit;mypage=@{[&encode($page)]}", class=>"wiki-command", title=>$resource{admineditbutton}} if &is_editable ($page) || &is_frozen ($page); |
591 |
<a href="$url_cgi?$RecentChanges" class="wiki">$resource{recentchangesbutton}</a> |
push @link, {rel=>'view', href=>"$url_cgi?mycmd=read;mypage=@{[&encode($page)]};x-p=@{[time.[0..9]->[rand 10]]}", class=>'wiki-command', title=>'View latest version of this page'}; |
592 |
</div> |
push @link, {rel=>'myself', href=>"$url_cgi?@{[&encode($page)]}", class=>'wiki'}; |
593 |
EOH |
push @link, {rel=>'index', href=>"$url_cgi?$IndexPage", class=>'wiki', title=>$resource{indexbutton}}; |
594 |
|
push @link, {rel=>'home', href=>"$url_cgi?$FrontPage", class=>'wiki', title=>$FrontPage}; |
595 |
|
push @link, {rel=>'News', href=>"$url_cgi?WikiNews", class=>'wiki', title=>'News on this wiki'}; |
596 |
|
push @link, {rel=>'News', href=>"$url_cgi?$RecentChanges", class=>"wiki", title=>$resource{recentchangesbutton}}; |
597 |
|
push @link, {rel=>'News', href=>"$url_cgi?$RssPage", class=>"wiki", title=>$resource{rssbutton}, type=>'application/xml'}; |
598 |
|
push @link, {rel=>'search', href=>"$url_cgi?$SearchPage", class=>'wiki', title=>$resource{searchbutton}}; |
599 |
|
push @link, {rel=>'help', href=>"$url_cgi?WikiHelp", class=>'wiki'}; |
600 |
|
push @link, {rel=>'copyright', href=>"$url_cgi?WikiPageLicense", class=>'wiki'}; |
601 |
|
push @link, {rel=>'jump', href=>q(javascript:var%20WikiName=prompt('Please%20input%20the%20WikiName:','','Jump%20to%20SuikaWiki');if(WikiName)%7B_content.location.href='http://suika.fam.cx/%7Ewakaba/-temp/wiki/wiki%3F'+encodeURIComponent(WikiName)%7D), class=>'wiki-cmd', title=>'Jump to...'}; |
602 |
|
push @link, {rel=>'jump', href=>q(javascript:var%20WikiName=prompt('Please%20input%20the%20WikiName:','','Jump%20to%20SuikaWiki');if(WikiName)%7B_content.location.href='http://suika.fam.cx/%7Ewakaba/-temp/wiki/wiki%3Fmycmd=edit;mypage='+encodeURIComponent(WikiName)%7D), class=>'wiki-cmd', title=>'Jump to (edit)...'}; |
603 |
|
push @link, {rel=>'lucky', href=>"$url_cgi?mycmd=RandomJump;x-param=@{[time.[0..9]->[rand 10]]}", class=>'wiki randomlink', title=>'Somewhere'}; |
604 |
|
my ($Links, $links) = ('', ''); |
605 |
|
for my $e (@link) { |
606 |
|
$links .= qq(<link); |
607 |
|
$Links .= qq(Link: <$e->{href}>); |
608 |
|
for my $attr (qw/rel rev href title class type hreflang charset/) { |
609 |
|
$links .= qq( $attr="@{[&escape($e->{$attr})]}") if $e->{$attr}; |
610 |
|
} |
611 |
|
for my $attr (qw/rel rev title/) { |
612 |
|
$Links .= qq(; $attr="@{[do{$e->{$attr} =~ s/([\\\"])/\\$1/g; $e->{$attr}}]}") if $e->{$attr}; |
613 |
|
} |
614 |
|
$links .= qq(>\n); |
615 |
|
$Links .= qq(\n); |
616 |
|
} |
617 |
|
wantarray ? ($Links, $links) : $Links; |
618 |
} |
} |
619 |
|
|
620 |
sub print_footer { |
sub print_footer { |
683 |
chomp; |
chomp; |
684 |
if (/^\*\*\*\*\*([^\x0D\x0A]*)/) { |
if (/^\*\*\*\*\*([^\x0D\x0A]*)/) { |
685 |
push(@toc, qq(----- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
push(@toc, qq(----- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
686 |
push(@result, splice(@saved), qq(<h6 id="i$tocnum">) . &inline($1) . '</h6>'); |
push(@result, splice(@saved), qq(<h6 @{[&id_and_name("i$tocnum")]}>) . &inline($1) . '</h6>'); |
687 |
$tocnum++; |
$tocnum++; |
688 |
} elsif (/^\*\*\*\*([^\x0D\x0A]*)/) { |
} elsif (/^\*\*\*\*([^\x0D\x0A]*)/) { |
689 |
push(@toc, qq(---- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
push(@toc, qq(---- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
690 |
push(@result, splice(@saved), qq(<h5 id="i$tocnum">) . &inline($1) . '</h5>'); |
push(@result, splice(@saved), qq(<h5 @{[&id_and_name("i$tocnum")]}>) . &inline($1) . '</h5>'); |
691 |
$tocnum++; |
$tocnum++; |
692 |
} elsif (/^\*\*\*([^\x0D\x0A]*)/) { |
} elsif (/^\*\*\*([^\x0D\x0A]*)/) { |
693 |
push(@toc, qq(--- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
push(@toc, qq(--- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
694 |
push(@result, splice(@saved), qq(<h4 id="i$tocnum">) . &inline($1) . '</h4>'); |
push(@result, splice(@saved), qq(<h4 @{[&id_and_name("i$tocnum")]}>) . &inline($1) . '</h4>'); |
695 |
$tocnum++; |
$tocnum++; |
696 |
} elsif (/^\*\*([^\x0D\x0A]*)/) { |
} elsif (/^\*\*([^\x0D\x0A]*)/) { |
697 |
# if (/^\*\*(.*)/) { |
# if (/^\*\*(.*)/) { |
698 |
# Walrus mod (6) end |
# Walrus mod (6) end |
699 |
push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
700 |
push(@result, splice(@saved), qq(<h3><a name="i$tocnum"> </a>) . &inline($1) . '</h3>'); |
push(@result, splice(@saved), qq(<h3 @{[&id_and_name("i$tocnum")]}>) . &inline($1) . '</h3>'); |
701 |
$tocnum++; |
$tocnum++; |
702 |
} elsif (/^\*([^\x0D\x0A]*)/) { |
} elsif (/^\*([^\x0D\x0A]*)/) { |
703 |
push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
704 |
push(@result, splice(@saved), qq(<h2><a name="i$tocnum"> </a>) . &inline($1) . '</h2>'); |
push(@result, splice(@saved), qq(<h2 @{[&id_and_name("i$tocnum")]}>) . &inline($1) . '</h2>'); |
705 |
$tocnum++; |
$tocnum++; |
706 |
} elsif (/^(={1,6})(.*)/) { |
} elsif (/^(={1,6})(.*)/) { |
707 |
&back_push('ol', length($1), \@saved, \@result); |
&back_push('ol', length($1), \@saved, \@result); |
892 |
} |
} |
893 |
|
|
894 |
my $FormIndex = 0; |
my $FormIndex = 0; |
895 |
sub make_custom_form ($$$) { |
sub make_custom_form ($$$$) { |
896 |
my ($wfname, $definition, $template, $option) = @_; |
my ($wfname, $definition, $template, $option) = @_; |
897 |
## $template and $option is currently not used in this procedure. |
## $template and $option is currently not used in this procedure. |
898 |
unless ($main::_EMBEDED) { |
unless ($main::_EMBEDED) { |
900 |
if (length $definition) { |
if (length $definition) { |
901 |
my $param = bless {}, 'SuikaWiki::Plugin'; |
my $param = bless {}, 'SuikaWiki::Plugin'; |
902 |
my $lastmodified = &get_info($form{mypage}, $info_LastModified); |
my $lastmodified = &get_info($form{mypage}, $info_LastModified); |
903 |
|
&load_formatter (qw/form_input form_option/); |
904 |
|
$definition = &unescape ($definition); |
905 |
$definition =~ s/\\(.)/$1/g; |
$definition =~ s/\\(.)/$1/g; |
|
$definition .= ' %submit;' if $definition !~ /%submit/; |
|
|
unless ($fmt{form_option}) { |
|
|
$fmt{form_option} = Message::Util::Formatter->new; |
|
|
for (@{$SuikaWiki::Plugin::List{wikiform_option}||[]}) { |
|
|
$_->load_formatter ($fmt{form_option}, type => 'wikiform_option'); |
|
|
} |
|
|
} |
|
906 |
$option = &unescape ($option); |
$option = &unescape ($option); |
907 |
$option =~ s/\\(.)/$1/g; |
$option =~ s/\\(.)/$1/g; |
908 |
$fmt{form_option}->replace ($option, $param); |
$fmt{form_option}->replace ($option, $param); |
909 |
|
$definition .= ' %submit;' if $definition !~ /%submit/ && !$param->{output}->{nosubmit}; |
910 |
|
my $target_page = $param->{output}->{page} || $form{mypage}; |
911 |
|
$param->{form_disabled} = 1 if $fixedpage{$target_page}; |
912 |
my $target_form = $param->{output}->{id}; |
my $target_form = $param->{output}->{id}; |
913 |
my $r = <<EOH; |
my $r = <<EOH; |
914 |
<form method="post" action="$url_cgi" id="wikiform-$FormIndex" class="wikiform"> |
<form method="post" action="$url_cgi" id="wikiform-$FormIndex" class="wikiform"> |
915 |
<input type="hidden" name="mycmd" value="wikiform"> |
<input type="hidden" name="mycmd" value="@{[$param->{form_disabled}?'read':'wikiform']}"> |
916 |
<input type="hidden" name="mypage" value="@{[&escape($form{mypage})]}"> |
<input type="hidden" name="mypage" value="@{[&escape($target_page)]}"> |
917 |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
918 |
<input type="hidden" name="mytouch" value="on"> |
<input type="hidden" name="mytouch" value="on"> |
919 |
<input type="hidden" name="@{[$target_form? qq(wikiform_targetform" value="@{[&escape($target_form)]}) : qq(wikiform_index" value="$FormIndex)]}"> |
<input type="hidden" name="@{[$target_form? qq(wikiform_targetform" value="@{[&escape($target_form)]}) : qq(wikiform_index" value="$FormIndex)]}"> |
920 |
EOH |
EOH |
921 |
$r .= qq(<a name="wikiform-$FormIndex"></a>) if $UA =~ m#Mozilla/[12]\.#; |
$r .= qq(<a name="wikiform-$FormIndex"></a>) if $UA =~ m#Mozilla/[12]\.#; |
922 |
$r .= $fmt{form_input}->replace (&unescape ($definition), $param); |
$r .= $fmt{form_input}->replace ($definition, $param); |
923 |
$r .= <<EOH; |
$r .= <<EOH; |
924 |
</form> |
</form> |
925 |
EOH |
EOH |
1158 |
} else { |
} else { |
1159 |
$mymsg = &escape($mymsg || $database{NewPageTemplate}); |
$mymsg = &escape($mymsg || $database{NewPageTemplate}); |
1160 |
} |
} |
1161 |
|
my $magic = ''; |
1162 |
|
$magic = $1 if $mymsg =~ m/^([^\x0A\x0D]+)/s; |
1163 |
|
|
1164 |
my $edit = $mode{admin} ? 'adminedit' : 'edit'; |
my $edit = $mode{admin} ? 'adminedit' : 'edit'; |
1165 |
my $escapedmypage = &escape($form{mypage}); |
my $escapedmypage = &escape($form{mypage}); |
1166 |
my $escapedmypassword = &escape($form{mypassword}); |
my $escapedmypassword = &escape($form{mypassword}); |
1167 |
|
my $selected = 'read'; |
1168 |
|
if ($form{after_edit_cmd}) { |
1169 |
|
$selected = $form{after_edit_cmd}; |
1170 |
|
} elsif ($magic =~ /Config/ || $magic =~ /CSS/) { |
1171 |
|
$selected = 'edit'; |
1172 |
|
} |
1173 |
|
my $afteredit = <<EOH; |
1174 |
|
<select name="after_edit_cmd"> |
1175 |
|
<option value="read" label="View changed page"@{[$selected eq 'read' ? ' selected="selected"':'']}>read</option> |
1176 |
|
<option value="edit" label="Edit changed page"@{[$selected eq 'edit' ? ' selected="selected"':'']}>edit</option> |
1177 |
|
</select> |
1178 |
|
EOH |
1179 |
|
|
1180 |
print <<"EOD"; |
print <<"EOD"; |
1181 |
<form action="$url_cgi" method="post"> |
<form action="$url_cgi" method="post"> |
1182 |
<h2>$escapedmypageの編集</h2> |
<h2>$escapedmypageの編集</h2> |
1183 |
@{[ $mode{admin} ? qq($resource{frozenpassword} <input type="password" name="mypassword" value="$escapedmypassword" size="10"><br>) : "" ]} |
@{[ $mode{conflict} ? '' : qq(<input type="submit" name="mypreview_write" value="$resource{savebutton}"><kbd>S</kbd>) ]} |
1184 |
|
@{[ $mode{admin} ? qq($resource{frozenpassword} <input type="password" name="mypassword" value="$escapedmypassword" size="10">) : "" ]} [@{[do {my $n = 0; |
1185 |
|
$mymsg =~ s/(?:-+\s)?\[([0-9]+)\]/$n = $1 if $1 > $n; $&/mge; |
1186 |
|
++$n}]}]<br> |
1187 |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
1188 |
<input type="hidden" name="mypage" value="$escapedmypage"> |
<input type="hidden" name="mypage" value="$escapedmypage"> |
1189 |
<textarea cols="$cols" rows="$rows" name="mymsg" tabindex="1">$mymsg</textarea><br> |
<textarea cols="$cols" rows="$rows" name="mymsg" tabindex="1">$mymsg</textarea><br> |
1200 |
<input type="checkbox" name="mytouch" value="on" checked="checked">$resource{touch}<br> |
<input type="checkbox" name="mytouch" value="on" checked="checked">$resource{touch}<br> |
1201 |
<input type="submit" name="mypreview_$edit" value="$resource{previewbutton}"> |
<input type="submit" name="mypreview_$edit" value="$resource{previewbutton}"> |
1202 |
<input type="submit" name="mypreview_write" value="$resource{savebutton}" accesskey="S"><kbd>S</kbd> |
<input type="submit" name="mypreview_write" value="$resource{savebutton}" accesskey="S"><kbd>S</kbd> |
1203 |
[@{[do {my $n = 0; |
$afteredit |
1204 |
$mymsg =~ s/(?:-+\s)?\[([0-9]+)\]/$n = $1 if $1 > $n; $&/mge; |
<br> |
|
++$n}]}]<br> |
|
1205 |
) |
) |
1206 |
]} |
]} |
1207 |
</form> |
</form> |
1280 |
sub init_resource { |
sub init_resource { |
1281 |
open(FILE, $file_resource) or &print_error("(resource)"); |
open(FILE, $file_resource) or &print_error("(resource)"); |
1282 |
while (<FILE>) { |
while (<FILE>) { |
1283 |
chomp; |
s/[\x0A\x0D]+$//g; |
1284 |
next if /^#/; |
next if /^#/; |
1285 |
my ($key, $value) = split(/=/, $_, 2); |
my ($key, $value) = split(/=/, $_, 2); |
1286 |
$resource{$key} = &code_convert(\$value, $kanjicode); |
$resource{$key} = &code_convert(\$value, $kanjicode); |
1331 |
$fmt{interwiki}->{encoded} = sub { |
$fmt{interwiki}->{encoded} = sub { |
1332 |
my ($o, $p) = @_; |
my ($o, $p) = @_; |
1333 |
if ($o->{except}) { |
if ($o->{except}) { |
1334 |
$o->{except} =~ tr/\x00-\x20\x22\x23%\x2D<>^[\x5C]`{|}\x7F-\xFF//d; |
$o->{except} =~ tr/\x00-\x20\x22%\x2D<>^[\x5C]`{|}\x7F-\xFF//d; |
1335 |
} |
} |
1336 |
my $s = &code_convert (\$p->{name}, $o->{charset} || 'iso-2022-7bit'); |
my $s = &code_convert (\$p->{name}, $o->{charset} || 'iso-2022-7bit'); |
1337 |
$s =~ s/([^$o->{except}A-Za-z0-9_-])/sprintf '%%%02X', unpack 'C', $1/ge; |
$s =~ s/([^$o->{except}A-Za-z0-9_-])/sprintf '%%%02X', unpack 'C', $1/ge; |
1343 |
$s = qq([[$s]]) if $s !~ /^[A-Z][a-z]+(?:[A-Z][a-z]+)+$/; |
$s = qq([[$s]]) if $s !~ /^[A-Z][a-z]+(?:[A-Z][a-z]+)+$/; |
1344 |
&encode (&code_convert (\$p->{name}, $o->{charset} || 'shift_jis')); |
&encode (&code_convert (\$p->{name}, $o->{charset} || 'shift_jis')); |
1345 |
}; |
}; |
|
|
|
|
$fmt{form_input} = Message::Util::Formatter->new; |
|
|
for (@{$SuikaWiki::Plugin::List{wikiform_input}||[]}) { |
|
|
$_->load_formatter ($fmt{form_input}, type => 'wikiform_input'); |
|
|
} |
|
1346 |
} |
} |
1347 |
|
|
1348 |
|
|
1508 |
} |
} |
1509 |
} |
} |
1510 |
|
|
1511 |
sub do_wikiform { |
sub load_formatter (@) { |
1512 |
my $content = $database{$form{mypage}}; |
for my $t (@_) { |
|
my $anchor = &get_new_anchor_index ($content); |
|
|
for my $t (qw/form_template form_option/) { |
|
1513 |
unless ($fmt{$t}) { |
unless ($fmt{$t}) { |
1514 |
$fmt{$t} = Message::Util::Formatter->new; |
$fmt{$t} = Message::Util::Formatter->new; |
1515 |
for (@{$SuikaWiki::Plugin::List{'wiki'.$t}||[]}) { |
for (@{$SuikaWiki::Plugin::List{'wiki'.$t}||[]}) { |
1517 |
} |
} |
1518 |
} |
} |
1519 |
} |
} |
1520 |
|
} |
1521 |
|
|
1522 |
|
sub do_wikiform { |
1523 |
|
my $content = $database{$form{mypage}}; |
1524 |
|
my $anchor = &get_new_anchor_index ($content); |
1525 |
|
&load_formatter (qw/form_template form_option/); |
1526 |
my $write = 0; |
my $write = 0; |
1527 |
my $i = 1; |
my $i = 1; |
1528 |
$content =~ s{$embed_command{form}}{ |
$content =~ s{$embed_command{form}}{ |
1542 |
$fmt{form_option}->replace ($option, $param); |
$fmt{form_option}->replace ($option, $param); |
1543 |
my $t = 1; |
my $t = 1; |
1544 |
for (@{$param->{require}||[]}) { |
for (@{$param->{require}||[]}) { |
1545 |
(undef $t, last) unless length $param->{argv}->{'wikiform__'.$_}; |
(undef $t, last) unless length $param->{argv}->{'wikiform__'.$_}; |
1546 |
} |
} |
1547 |
$t = $fmt{form_template}->replace ($template, $param) if $t; |
$t = $fmt{form_template}->replace ($template, $param) if $t; |
1548 |
if (length $t) { |
if (length $t) { |
1743 |
$count++; |
$count++; |
1744 |
} |
} |
1745 |
# print RSS information (as XML). |
# print RSS information (as XML). |
1746 |
|
print scalar &make_navigate_links ('RssPage'); |
1747 |
print <<"EOD" |
print <<"EOD" |
1748 |
Content-type: text/xml |
Content-type: application/xml |
1749 |
|
|
1750 |
@{[$rss->as_string]} |
@{[$rss->as_string]} |
1751 |
EOD |
EOD |
1763 |
sub __get_database ($) { $database{ $_[0] } } |
sub __get_database ($) { $database{ $_[0] } } |
1764 |
sub __set_database ($$) { $database{ $_[0] } = $_[1] } |
sub __set_database ($$) { $database{ $_[0] } = $_[1] } |
1765 |
|
|
1766 |
|
sub do_wikiplugininfo { |
1767 |
|
&print_header (q(WikiPluginInfo)); |
1768 |
|
print text_to_html (&SuikaWiki::Plugin::make_info_page); |
1769 |
|
&print_footer (q(WikiPluginInfo)); |
1770 |
|
} |
1771 |
|
|
1772 |
package wiki::referer; |
package wiki::referer; |
1773 |
sub add ($$) { |
sub add ($$) { |
1774 |
my $page = shift; |
my $page = shift; |
1834 |
} |
} |
1835 |
my $euri = main::escape ($uri); |
my $euri = main::escape ($uri); |
1836 |
if ($title) { |
if ($title) { |
1837 |
$r .= qq(<li>[$list{$uri}] <a href="$euri" title="URI: <$euri>">@{[main::escape ($title)]}</a></li>\n); |
$r .= qq(<li>[$list{$uri}] <a href="$euri" title="URI: <$euri>">@{[main::escape ($title)]}</a></li>\n); |
1838 |
} else { |
} else { |
1839 |
$r .= qq(<li>[$list{$uri}] <<a href="$euri">$euri</a>></li>\n); |
$r .= qq(<li>[$list{$uri}] <<a href="$euri">$euri</a>></li>\n); |
1840 |
} |
} |
1854 |
sub add ($) { |
sub add ($) { |
1855 |
my $s = shift; |
my $s = shift; |
1856 |
return unless length $s; |
return unless length $s; |
1857 |
$s =~ s/([\x00-\x08\x0A-\x1F\x25\x7F-\xFF])/sprintf '%%%02X', unpack 'C', $1/g; |
$s =~ s/([\x00-\x08\x0A-\x1F\x25\x7F-\xFF])/sprintf '%%%02X', unpack 'C', $1/ge; |
1858 |
my %ua; |
my %ua; |
1859 |
for (split /\n/, &main::__get_database('WikiUserAgentList')) { |
for (split /\n/, &main::__get_database('WikiUserAgentList')) { |
1860 |
if (/^-\[(\d+)\] (.+)$/) { |
if (/^-\[(\d+)\] (.+)$/) { |
1872 |
} |
} |
1873 |
|
|
1874 |
package SuikaWiki::Plugin; |
package SuikaWiki::Plugin; |
1875 |
|
our $plugin_directory; # defined in top of this file. |
1876 |
our %List; |
our %List; |
1877 |
|
|
1878 |
sub escape ($$) { main::escape ($_[1]) } |
sub escape ($$) { main::escape ($_[1]) } |
1888 |
} |
} |
1889 |
} |
} |
1890 |
|
|
1891 |
use SuikaWiki::Plugin::WikiFormBasic; |
sub import_plugins () { |
1892 |
|
opendir PDIR, $plugin_directory; |
1893 |
|
my @plugin = grep {s/\.pm$//} readdir (PDIR); |
1894 |
|
closedir PDIR; |
1895 |
|
for (@plugin) { |
1896 |
|
eval qq{ use SuikaWiki::Plugin::$_ } unless /[^A-Za-z0-9_]/; |
1897 |
|
push @{$List{_all}}, qq(SuikaWiki::Plugin::$_); |
1898 |
|
} |
1899 |
|
} |
1900 |
|
|
1901 |
|
sub make_info_page () { |
1902 |
|
my $r = <<EOH; |
1903 |
|
EOH |
1904 |
|
unless ($List{_all}) { |
1905 |
|
$r .= qq('''No plugin is installed!'''\n); |
1906 |
|
} else { |
1907 |
|
my $index = 0; |
1908 |
|
for my $package (sort @{$List{_all}}) { |
1909 |
|
$index++; |
1910 |
|
my $prop = $package->property (); |
1911 |
|
$r .= <<EOH; |
1912 |
|
*$package |
1913 |
|
|
1914 |
|
[$index] '''$prop->{name}''' (Version $prop->{version}) |
1915 |
|
<$prop->{uri}> |
1916 |
|
|
1917 |
|
Provide: |
1918 |
|
@{[do{my $t = ''; for my $f (@{$prop->{provide}||[]}) { |
1919 |
|
$t .= qq(-''$f''\n); |
1920 |
|
for (sort grep m#^\Q$f\E/#, keys %{$prop->{partinfo}}) { |
1921 |
|
$t .= qq(--''$_'' -- $prop->{partinfo}->{$_}\n); |
1922 |
|
} |
1923 |
|
}$t}]} |
1924 |
|
|
1925 |
|
EOH |
1926 |
|
} |
1927 |
|
} |
1928 |
|
$r; |
1929 |
|
} |
1930 |
|
|
1931 |
|
&import_plugins (); |
1932 |
|
|
1933 |
|
package main; |
1934 |
|
&main; |
1935 |
|
exit 0; |
1936 |
|
|
1937 |
1; |
1; |
1938 |
__END__ |
__END__ |