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"; |
98 |
my $embed_interwiki = '^\[\[#(box|text|password):(\S+)\]\]$'; # Walrus add (5) |
my $embed_interwiki = '^\[\[#(box|text|password):(\S+)\]\]$'; # Walrus add (5) |
99 |
my %embed_command = ( |
my %embed_command = ( |
100 |
searched => '^\[\[#searched:([^\]]+)\]\]$', |
searched => '^\[\[#searched:([^\]]+)\]\]$', |
101 |
form => qw/\[\[\#form:'((?:[^'\\]|\\.)+)':'((?:[^'\\]|\\.)+)'(?::'((?:[^'\\]|\\.)*)')?\]\]/, |
form => qw/\[\[\#form(?:\(([A-Za-z0-9-]+)\))?:'((?:[^'\\]|\\.)*)':'((?:[^'\\]|\\.)*)'(?::'((?:[^'\\]|\\.)*)')?\]\]/, |
102 |
); |
); |
103 |
############################## |
############################## |
104 |
my $info_LastModified = 'LastModified'; |
my $info_LastModified = 'LastModified'; |
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 { |
220 |
my $content = $database{$form{mypage}}; |
my $content = $database{$form{mypage}}; |
221 |
if ($content =~ m#^\s*/\*\s*W3C-CSS#) { |
if ($content =~ m#^\s*/\*\s*W3C-CSS#) { |
222 |
my $lm = &get_info($form{mypage}, $info_LastModified); |
my $lm = &get_info($form{mypage}, $info_LastModified); |
223 |
|
print scalar make_navigate_links ($form{mypage}); |
224 |
print "Content-Type: text/css; charset=$charset\n"; |
print "Content-Type: text/css; charset=$charset\n"; |
225 |
print "Last-Modified: $lm\n"; |
print "Last-Modified: $lm\n"; |
226 |
print "\n"; |
print "\n"; |
235 |
|
|
236 |
sub id_and_name ($) { |
sub id_and_name ($) { |
237 |
my $name = shift; |
my $name = shift; |
238 |
if ($UA =~ m#Mozilla/[12]\.#) { |
if ($UA =~ m#Mozilla/[12]\.|Microsoft Internet Explorer#) { |
239 |
qq{id="$name"><a name="$name"></a}; |
qq{id="$name"><a name="$name"></a}; |
240 |
} else { |
} else { |
241 |
qq{id="$name"}; |
qq{id="$name"}; |
358 |
&update_recent_changes; |
&update_recent_changes; |
359 |
} |
} |
360 |
&set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen}); |
&set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen}); |
361 |
my $fragment; |
my $fragment = ''; |
362 |
|
$fragment .= qq(;after_edit_cmd=@{[&encode($form{after_edit_cmd})]}) if $form{after_edit_cmd}; |
363 |
if ($form{__comment_anchor_index}) { |
if ($form{__comment_anchor_index}) { |
364 |
$fragment = qq(anchor-$form{__comment_anchor_index}); |
$fragment .= qq(#anchor-$form{__comment_anchor_index}); |
365 |
} elsif ($form{__wikiform_anchor_index}) { |
} elsif ($form{__wikiform_anchor_index}) { |
366 |
$fragment = qq(wikiform-$form{__wikiform_anchor_index}); |
$fragment .= qq(#wikiform-$form{__wikiform_anchor_index}); |
367 |
} |
} |
368 |
&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)); |
369 |
&print_message($resource{saved}); |
&print_message($resource{saved}); |
370 |
&print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}"); |
&print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}"); |
371 |
&print_footer($CompletedSuccessfully); |
&print_footer($CompletedSuccessfully); |
471 |
} |
} |
472 |
$bodyclass .= " wiki-page-obsoleted" if $option{-content_format} =~ /obsoleted="yes"/; |
$bodyclass .= " wiki-page-obsoleted" if $option{-content_format} =~ /obsoleted="yes"/; |
473 |
if ($option{-goto}) { |
if ($option{-goto}) { |
474 |
if ($UA =~ m#Mozilla/[12]\.|Opera#) { |
if ($UA =~ m#Opera|MSIE 2\.#) { |
475 |
$option{-goto} =~ tr/;/&/; |
$option{-goto} =~ tr/;/&/ if $UA =~ m#Opera#; |
476 |
print qq{Refresh: 0; url=$option{-goto}\n}; |
print qq{Refresh: 0; url=$option{-goto}\n}; |
477 |
$option{-goto} = qq(<meta http-equiv="refresh" content="0; url=$option{-goto}">); |
$option{-goto} = qq(<meta http-equiv="refresh" content="0; url=$option{-goto}">); |
478 |
} else { |
} else { |
479 |
|
$option{-goto} =~ tr/;/&/ if $UA =~ m#Mozilla/[1-4]\.#; |
480 |
print qq{Refresh: 0; url="$option{-goto}"\n}; |
print qq{Refresh: 0; url="$option{-goto}"\n}; |
481 |
$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})]}"">); |
482 |
} |
} |
487 |
$meta_ct = qq{text/html; charset=@{[&x_charset($charset)]}}; |
$meta_ct = qq{text/html; charset=@{[&x_charset($charset)]}}; |
488 |
print qq{Content-Type: $meta_ct\n}; |
print qq{Content-Type: $meta_ct\n}; |
489 |
$meta_ct = qq{<meta http-equiv="content-type" content="$meta_ct">}; |
$meta_ct = qq{<meta http-equiv="content-type" content="$meta_ct">}; |
490 |
|
} elsif ($UA =~ m#Infomosaic#) { |
491 |
|
print qq{Content-Type: text/html\n}; |
492 |
} else { |
} else { |
493 |
print qq{Content-Type: text/html; charset=$charset\n}; |
print qq{Content-Type: text/html; charset=$charset\n}; |
494 |
} |
} |
495 |
my $cookedpage = &encode($page); |
my $cookedpage = &encode($page); |
496 |
my $escapedpage = &escape($page); |
my $escapedpage = &escape($page); |
497 |
|
my ($Links, $links) = &make_navigate_links ($page); |
498 |
|
print $Links; |
499 |
print <<"EOD"; |
print <<"EOD"; |
500 |
Content-Language: $lang |
Content-Language: $lang |
501 |
Content-Style-Type: text/css |
Content-Style-Type: text/css |
505 |
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
506 |
"http://www.w3.org/TR/html4/loose.dtd"> + RUBY --> |
"http://www.w3.org/TR/html4/loose.dtd"> + RUBY --> |
507 |
<html lang="$lang"> |
<html lang="$lang"> |
508 |
<head> |
<head profile="http://suika.fam.cx/~wakaba/-temp/wiki/wiki?WikiHTMLMetaProfile"> |
509 |
$meta_ct$option{-goto} |
$meta_ct$option{-goto} |
510 |
<title>$escapedpage</title> |
<title>$escapedpage</title> |
511 |
<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)]}"> |
|
512 |
@{[$option{-noindex} ? q(<meta name="ROBOTS" content="NOINDEX">) : '']} |
@{[$option{-noindex} ? q(<meta name="ROBOTS" content="NOINDEX">) : '']} |
513 |
|
$links |
514 |
</head> |
</head> |
515 |
<body class="$bodyclass"> |
<body class="$bodyclass"> |
516 |
EOD |
EOD |
568 |
<a href="$url_cgi?$RecentChanges" class="wiki">最新</a> |
<a href="$url_cgi?$RecentChanges" class="wiki">最新</a> |
569 |
</div> |
</div> |
570 |
EOH |
EOH |
571 |
<<EOH; ## temp |
} |
572 |
<a href="$url_cgi?$CreatePage" class="wiki">$resource{createbutton}</a> | |
|
573 |
<a href="$url_cgi?$IndexPage" class="wiki">$resource{indexbutton}</a> | |
sub make_navigate_links ($) { |
574 |
<!-- <a href="$url_cgi?$RssPage" class="wiki">$resource{rssbutton}</a> | --> |
my $page = shift; |
575 |
<a href="$url_cgi?$FrontPage" class="wiki">$FrontPage</a> | |
my @link; |
576 |
<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); |
577 |
<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); |
578 |
<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'}; |
579 |
</div> |
push @link, {rel=>'myself', href=>"$url_cgi?@{[&encode($page)]}", class=>'wiki'}; |
580 |
EOH |
push @link, {rel=>'index', href=>"$url_cgi?$IndexPage", class=>'wiki', title=>$resource{indexbutton}}; |
581 |
|
push @link, {rel=>'home', href=>"$url_cgi?$FrontPage", class=>'wiki', title=>$FrontPage}; |
582 |
|
push @link, {rel=>'News', href=>"$url_cgi?WikiNews", class=>'wiki', title=>'News on this wiki'}; |
583 |
|
push @link, {rel=>'News', href=>"$url_cgi?$RecentChanges", class=>"wiki", title=>$resource{recentchangesbutton}}; |
584 |
|
push @link, {rel=>'News', href=>"$url_cgi?$RssPage", class=>"wiki", title=>$resource{rssbutton}, type=>'application/xml'}; |
585 |
|
push @link, {rel=>'search', href=>"$url_cgi?$SearchPage", class=>'wiki', title=>$resource{searchbutton}}; |
586 |
|
push @link, {rel=>'help', href=>"$url_cgi?WikiHelp", class=>'wiki'}; |
587 |
|
push @link, {rel=>'copyright', href=>"$url_cgi?WikiPageLicense", class=>'wiki'}; |
588 |
|
my ($Links, $links) = ('', ''); |
589 |
|
for my $e (@link) { |
590 |
|
$links .= qq(<link); |
591 |
|
$Links .= qq(Link: <$e->{href}>); |
592 |
|
for my $attr (qw/rel rev href title class type hreflang charset/) { |
593 |
|
$links .= qq( $attr="@{[&escape($e->{$attr})]}") if $e->{$attr}; |
594 |
|
} |
595 |
|
for my $attr (qw/rel rev title/) { |
596 |
|
$Links .= qq(; $attr="@{[do{$e->{$attr} =~ s/([\\\"])/\\$1/g; $e->{$attr}}]}") if $e->{$attr}; |
597 |
|
} |
598 |
|
$links .= qq(>\n); |
599 |
|
$Links .= qq(\n); |
600 |
|
} |
601 |
|
wantarray ? ($Links, $links) : $Links; |
602 |
} |
} |
603 |
|
|
604 |
sub print_footer { |
sub print_footer { |
667 |
chomp; |
chomp; |
668 |
if (/^\*\*\*\*\*([^\x0D\x0A]*)/) { |
if (/^\*\*\*\*\*([^\x0D\x0A]*)/) { |
669 |
push(@toc, qq(----- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
push(@toc, qq(----- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
670 |
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>'); |
671 |
$tocnum++; |
$tocnum++; |
672 |
} elsif (/^\*\*\*\*([^\x0D\x0A]*)/) { |
} elsif (/^\*\*\*\*([^\x0D\x0A]*)/) { |
673 |
push(@toc, qq(---- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
push(@toc, qq(---- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
674 |
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>'); |
675 |
$tocnum++; |
$tocnum++; |
676 |
} elsif (/^\*\*\*([^\x0D\x0A]*)/) { |
} elsif (/^\*\*\*([^\x0D\x0A]*)/) { |
677 |
push(@toc, qq(--- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
push(@toc, qq(--- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
678 |
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>'); |
679 |
$tocnum++; |
$tocnum++; |
680 |
} elsif (/^\*\*([^\x0D\x0A]*)/) { |
} elsif (/^\*\*([^\x0D\x0A]*)/) { |
681 |
# if (/^\*\*(.*)/) { |
# if (/^\*\*(.*)/) { |
682 |
# Walrus mod (6) end |
# Walrus mod (6) end |
683 |
push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
684 |
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>'); |
685 |
$tocnum++; |
$tocnum++; |
686 |
} elsif (/^\*([^\x0D\x0A]*)/) { |
} elsif (/^\*([^\x0D\x0A]*)/) { |
687 |
push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
688 |
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>'); |
689 |
$tocnum++; |
$tocnum++; |
690 |
} elsif (/^(={1,6})(.*)/) { |
} elsif (/^(={1,6})(.*)/) { |
691 |
&back_push('ol', length($1), \@saved, \@result); |
&back_push('ol', length($1), \@saved, \@result); |
793 |
sub inline { |
sub inline { |
794 |
my ($line) = @_; |
my ($line) = @_; |
795 |
$line = &escape($line); |
$line = &escape($line); |
796 |
$line =~ s{$embed_command{form}}{&make_custom_form ($1, $2, $3)}ge; |
$line =~ s{$embed_command{form}}{&make_custom_form ($1, $2, $3, $4)}ge; |
797 |
$line =~ s{\[(INS|DEL|SUP|SUB|VAR|CODE|KBD|SAMP|DFN)(?:\(([A-Za-z0-9\x20-]+)\))?\[(.+?)\]\]}{<@{[lc $1]}@{[$2 ? qq( class="$2") : '']}>$3</@{[lc $1]}>}g; |
$line =~ s{\[(INS|DEL|SUP|SUB|VAR|CODE|KBD|SAMP|DFN)(?:\(([A-Za-z0-9\x20-]+)\))?\[(.+?)\]\]}{<@{[lc $1]}@{[$2 ? qq( class="$2") : '']}>$3</@{[lc $1]}>}g; |
798 |
$line =~ s:\[(WEAK)\[(.+?)\]\]:<span class="@{[lc $1]}">$2</span>:g; |
$line =~ s:\[(WEAK)\[(.+?)\]\]:<span class="@{[lc $1]}">$2</span>:g; |
799 |
$line =~ s:\[ABBR\[([^]]+)\] \[([^]]+)\]\]:<acronym title="$2">$1</acronym>:g; |
$line =~ s:\[ABBR\[([^]]+)\] \[([^]]+)\]\]:<acronym title="$2">$1</acronym>:g; |
876 |
} |
} |
877 |
|
|
878 |
my $FormIndex = 0; |
my $FormIndex = 0; |
879 |
sub make_custom_form ($$$) { |
sub make_custom_form ($$$$) { |
880 |
my ($definition, $template, $option) = @_; |
my ($wfname, $definition, $template, $option) = @_; |
|
$definition =~ s/\\(.)/$1/g; |
|
881 |
## $template and $option is currently not used in this procedure. |
## $template and $option is currently not used in this procedure. |
882 |
unless ($main::_EMBEDED) { |
unless ($main::_EMBEDED) { |
883 |
$FormIndex++; |
$FormIndex++; |
884 |
my $param = bless {}, 'SuikaWiki::Plugin'; |
if (length $definition) { |
885 |
my $lastmodified = &get_info($form{mypage}, $info_LastModified); |
my $param = bless {}, 'SuikaWiki::Plugin'; |
886 |
my $r = <<EOH; |
my $lastmodified = &get_info($form{mypage}, $info_LastModified); |
887 |
|
&load_formatter (qw/form_input form_option/); |
888 |
|
$definition = &unescape ($definition); |
889 |
|
$definition =~ s/\\(.)/$1/g; |
890 |
|
$definition .= ' %submit;' if $definition !~ /%submit/; |
891 |
|
$option = &unescape ($option); |
892 |
|
$option =~ s/\\(.)/$1/g; |
893 |
|
$fmt{form_option}->replace ($option, $param); |
894 |
|
my $target_page = $param->{output}->{page} || $form{mypage}; |
895 |
|
$param->{form_disabled} = 1 if $fixedpage{$target_page}; |
896 |
|
my $target_form = $param->{output}->{id}; |
897 |
|
my $r = <<EOH; |
898 |
<form method="post" action="$url_cgi" id="wikiform-$FormIndex" class="wikiform"> |
<form method="post" action="$url_cgi" id="wikiform-$FormIndex" class="wikiform"> |
899 |
<input type="hidden" name="mycmd" value="wikiform"> |
<input type="hidden" name="mycmd" value="@{[$param->{form_disabled}?'read':'wikiform']}"> |
900 |
<input type="hidden" name="mypage" value="@{[&escape($form{mypage})]}"> |
<input type="hidden" name="mypage" value="@{[&escape($target_page)]}"> |
901 |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
902 |
<input type="hidden" name="mytouch" value="on"> |
<input type="hidden" name="mytouch" value="on"> |
903 |
<input type="hidden" name="wikiform_index" value="$FormIndex"> |
<input type="hidden" name="@{[$target_form? qq(wikiform_targetform" value="@{[&escape($target_form)]}) : qq(wikiform_index" value="$FormIndex)]}"> |
904 |
EOH |
EOH |
905 |
$r .= qq(<a name="wikiform-$FormIndex"></a>) if $UA =~ m#Mozilla/[12]\.#; |
$r .= qq(<a name="wikiform-$FormIndex"></a>) if $UA =~ m#Mozilla/[12]\.#; |
906 |
$r .= $fmt{form_input}->replace (&unescape ($definition), $param); |
$r .= $fmt{form_input}->replace ($definition, $param); |
907 |
$r .= <<EOH; |
$r .= <<EOH; |
908 |
</form> |
</form> |
909 |
EOH |
EOH |
910 |
|
$r; |
911 |
|
} else { ## No input-interface WikiForm |
912 |
|
qq(<a id="wikiform-$FormIndex" name="wikiform-$FormIndex"><!-- #form --></a>); |
913 |
|
} |
914 |
} else { |
} else { |
915 |
q(<ins class="wiki-error"><strong>Warning</strong>: form in embeded page is currently not supported.</ins>); |
q(<ins class="wiki-error"><strong>Warning</strong>: form in embeded page is currently not supported.</ins>); |
916 |
} |
} |
1142 |
} else { |
} else { |
1143 |
$mymsg = &escape($mymsg || $database{NewPageTemplate}); |
$mymsg = &escape($mymsg || $database{NewPageTemplate}); |
1144 |
} |
} |
1145 |
|
my $magic = ''; |
1146 |
|
$magic = $1 if $mymsg =~ m/^([^\x0A\x0D]+)/s; |
1147 |
|
|
1148 |
my $edit = $mode{admin} ? 'adminedit' : 'edit'; |
my $edit = $mode{admin} ? 'adminedit' : 'edit'; |
1149 |
my $escapedmypage = &escape($form{mypage}); |
my $escapedmypage = &escape($form{mypage}); |
1150 |
my $escapedmypassword = &escape($form{mypassword}); |
my $escapedmypassword = &escape($form{mypassword}); |
1151 |
|
my $selected = 'read'; |
1152 |
|
if ($form{after_edit_cmd}) { |
1153 |
|
$selected = $form{after_edit_cmd}; |
1154 |
|
} elsif ($magic =~ /Config/ || $magic =~ /CSS/) { |
1155 |
|
$selected = 'edit'; |
1156 |
|
} |
1157 |
|
my $afteredit = <<EOH; |
1158 |
|
<select name="after_edit_cmd"> |
1159 |
|
<option value="read" label="View changed page"@{[$selected eq 'read' ? ' selected="selected"':'']}>read</option> |
1160 |
|
<option value="edit" label="Edit changed page"@{[$selected eq 'edit' ? ' selected="selected"':'']}>edit</option> |
1161 |
|
</select> |
1162 |
|
EOH |
1163 |
|
|
1164 |
print <<"EOD"; |
print <<"EOD"; |
1165 |
<form action="$url_cgi" method="post"> |
<form action="$url_cgi" method="post"> |
1166 |
<h2>$escapedmypageの編集</h2> |
<h2>$escapedmypageの編集</h2> |
1167 |
@{[ $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>) ]} |
1168 |
|
@{[ $mode{admin} ? qq($resource{frozenpassword} <input type="password" name="mypassword" value="$escapedmypassword" size="10">) : "" ]} [@{[do {my $n = 0; |
1169 |
|
$mymsg =~ s/(?:-+\s)?\[([0-9]+)\]/$n = $1 if $1 > $n; $&/mge; |
1170 |
|
++$n}]}]<br> |
1171 |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
1172 |
<input type="hidden" name="mypage" value="$escapedmypage"> |
<input type="hidden" name="mypage" value="$escapedmypage"> |
1173 |
<textarea cols="$cols" rows="$rows" name="mymsg" tabindex="1">$mymsg</textarea><br> |
<textarea cols="$cols" rows="$rows" name="mymsg" tabindex="1">$mymsg</textarea><br> |
1184 |
<input type="checkbox" name="mytouch" value="on" checked="checked">$resource{touch}<br> |
<input type="checkbox" name="mytouch" value="on" checked="checked">$resource{touch}<br> |
1185 |
<input type="submit" name="mypreview_$edit" value="$resource{previewbutton}"> |
<input type="submit" name="mypreview_$edit" value="$resource{previewbutton}"> |
1186 |
<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> |
1187 |
[@{[do {my $n = 0; |
$afteredit |
1188 |
$mymsg =~ s/(?:-+\s)?\[([0-9]+)\]/$n = $1 if $1 > $n; $&/mge; |
<br> |
|
++$n}]}]<br> |
|
1189 |
) |
) |
1190 |
]} |
]} |
1191 |
</form> |
</form> |
1264 |
sub init_resource { |
sub init_resource { |
1265 |
open(FILE, $file_resource) or &print_error("(resource)"); |
open(FILE, $file_resource) or &print_error("(resource)"); |
1266 |
while (<FILE>) { |
while (<FILE>) { |
1267 |
chomp; |
s/[\x0A\x0D]+$//g; |
1268 |
next if /^#/; |
next if /^#/; |
1269 |
my ($key, $value) = split(/=/, $_, 2); |
my ($key, $value) = split(/=/, $_, 2); |
1270 |
$resource{$key} = &code_convert(\$value, $kanjicode); |
$resource{$key} = &code_convert(\$value, $kanjicode); |
1327 |
$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]+)+$/; |
1328 |
&encode (&code_convert (\$p->{name}, $o->{charset} || 'shift_jis')); |
&encode (&code_convert (\$p->{name}, $o->{charset} || 'shift_jis')); |
1329 |
}; |
}; |
|
|
|
|
$fmt{form_input} = Message::Util::Formatter->new; |
|
|
for (@{$SuikaWiki::Plugin::List{wikiform_input}||[]}) { |
|
|
$_->load_formatter ($fmt{form_input}, type => 'wikiform_input'); |
|
|
} |
|
1330 |
} |
} |
1331 |
|
|
1332 |
|
|
1394 |
$namestr = qq( ''[[$namestr]]'': ); |
$namestr = qq( ''[[$namestr]]'': ); |
1395 |
} |
} |
1396 |
my $anchor = &get_new_anchor_index ($content); |
my $anchor = &get_new_anchor_index ($content); |
|
|
|
|
# $content =~ s/(?:-+\s)?\[([0-9]+)\]/$anchor = $1 if $1 > $anchor; $&/mge; |
|
|
# $anchor++; |
|
1397 |
my $i = 1; my $o = 0; |
my $i = 1; my $o = 0; |
1398 |
$content =~ s{(\Q$embed_comment\E|\Q$embed_rcomment\E)}{ |
$content =~ s{(\Q$embed_comment\E|\Q$embed_rcomment\E)}{ |
1399 |
my $embed = $1; |
my $embed = $1; |
1492 |
} |
} |
1493 |
} |
} |
1494 |
|
|
1495 |
sub do_wikiform { |
sub load_formatter (@) { |
1496 |
my $content = $database{$form{mypage}}; |
for my $t (@_) { |
|
my $anchor = &get_new_anchor_index ($content); |
|
|
for my $t (qw/form_template form_option/) { |
|
1497 |
unless ($fmt{$t}) { |
unless ($fmt{$t}) { |
1498 |
$fmt{$t} = Message::Util::Formatter->new; |
$fmt{$t} = Message::Util::Formatter->new; |
1499 |
for (@{$SuikaWiki::Plugin::List{'wiki'.$t}||[]}) { |
for (@{$SuikaWiki::Plugin::List{'wiki'.$t}||[]}) { |
1501 |
} |
} |
1502 |
} |
} |
1503 |
} |
} |
1504 |
|
} |
1505 |
|
|
1506 |
|
sub do_wikiform { |
1507 |
|
my $content = $database{$form{mypage}}; |
1508 |
|
my $anchor = &get_new_anchor_index ($content); |
1509 |
|
&load_formatter (qw/form_template form_option/); |
1510 |
my $write = 0; |
my $write = 0; |
1511 |
my $i = 1; |
my $i = 1; |
1512 |
$content =~ s{$embed_command{form}}{ |
$content =~ s{$embed_command{form}}{ |
1513 |
my ($embed, $template, $option) = ($&, $2, $3); |
my ($embed, $wfname, $template, $option) = ($&, $1, $3, $4); |
1514 |
$template =~ s/\\(.)/$1/g; |
if (($wfname && $wfname eq $form{wikiform_targetform}) |
1515 |
$option =~ s/\\(.)/$1/g; |
|| $i == $form{wikiform_index}) { |
1516 |
if ($i == $form{wikiform_index}) { |
$template =~ s/\\(.)/$1/g; |
1517 |
|
$option =~ s/\\(.)/$1/g; |
1518 |
my $param = bless {}, 'SuikaWiki::Plugin'; |
my $param = bless {}, 'SuikaWiki::Plugin'; |
1519 |
$param->{page} = $form{mypage}; |
$param->{page} = $form{mypage}; |
1520 |
$param->{form_index} = $i; |
$param->{form_index} = $i; |
1521 |
|
$param->{form_name} = $wfname; |
1522 |
$param->{anchor_index} = $anchor; |
$param->{anchor_index} = $anchor; |
1523 |
$param->{argv} = \%form; |
$param->{argv} = \%form; |
1524 |
$param->{default_name} = $1 if $content =~ /default-name="([^"]+)"/; |
$param->{default_name} = $1 if $content =~ /default-name="([^"]+)"/; |
1525 |
|
$param->{default_name} ||= $DEFAULT_embed_comment_name; |
1526 |
$fmt{form_option}->replace ($option, $param); |
$fmt{form_option}->replace ($option, $param); |
1527 |
my $t = $fmt{form_template}->replace ($template, $param); |
my $t = 1; |
1528 |
|
for (@{$param->{require}||[]}) { |
1529 |
|
(undef $t, last) unless length $param->{argv}->{'wikiform__'.$_}; |
1530 |
|
} |
1531 |
|
$t = $fmt{form_template}->replace ($template, $param) if $t; |
1532 |
if (length $t) { |
if (length $t) { |
1533 |
if ($param->{output}->{reverse}) { |
if ($param->{output}->{reverse}) { |
|
$embed = $t . "\n" . $embed; |
|
|
} else { |
|
1534 |
$embed .= "\n" . $t; |
$embed .= "\n" . $t; |
1535 |
|
} else { |
1536 |
|
$embed = $t . "\n" . $embed; |
1537 |
} |
} |
1538 |
$write = 1; |
$write = 1; |
1539 |
$form{__comment_anchor_index} = $anchor |
$form{__comment_anchor_index} = $anchor |
1540 |
unless $param->{anchor_index}; ## $anchor is used! |
if $param->{anchor_index_}; ## $anchor is used! |
1541 |
} |
} |
1542 |
|
$form{__wikiform_anchor_index} = $i; |
1543 |
|
undef $form{wikiform_targetform}; ## make sure never to match |
1544 |
|
undef $form{wikiform_index}; ## with WikiForm in rest of page |
1545 |
} |
} |
1546 |
$i++; $embed; |
$i++; $embed; |
1547 |
}ge; |
}ge; |
1550 |
#$content .= "\n" unless $content =~ /\n$/s; |
#$content .= "\n" unless $content =~ /\n$/s; |
1551 |
# |
# |
1552 |
} |
} |
|
$form{__wikiform_anchor_index} = $form{wikiform_index}; |
|
1553 |
if ($write) { |
if ($write) { |
1554 |
$form{mymsg} = $content; |
$form{mymsg} = $content; |
1555 |
$form{mytouch} = 'on'; |
$form{mytouch} = 'on'; |
1727 |
$count++; |
$count++; |
1728 |
} |
} |
1729 |
# print RSS information (as XML). |
# print RSS information (as XML). |
1730 |
|
print scalar &make_navigate_links ('RssPage'); |
1731 |
print <<"EOD" |
print <<"EOD" |
1732 |
Content-type: text/xml |
Content-type: application/xml |
1733 |
|
|
1734 |
@{[$rss->as_string]} |
@{[$rss->as_string]} |
1735 |
EOD |
EOD |
1747 |
sub __get_database ($) { $database{ $_[0] } } |
sub __get_database ($) { $database{ $_[0] } } |
1748 |
sub __set_database ($$) { $database{ $_[0] } = $_[1] } |
sub __set_database ($$) { $database{ $_[0] } = $_[1] } |
1749 |
|
|
1750 |
|
sub do_wikiplugininfo { |
1751 |
|
&print_header (q(WikiPluginInfo)); |
1752 |
|
print text_to_html (&SuikaWiki::Plugin::make_info_page); |
1753 |
|
&print_footer (q(WikiPluginInfo)); |
1754 |
|
} |
1755 |
|
|
1756 |
package wiki::referer; |
package wiki::referer; |
1757 |
sub add ($$) { |
sub add ($$) { |
1758 |
my $page = shift; |
my $page = shift; |
1818 |
} |
} |
1819 |
my $euri = main::escape ($uri); |
my $euri = main::escape ($uri); |
1820 |
if ($title) { |
if ($title) { |
1821 |
$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); |
1822 |
} else { |
} else { |
1823 |
$r .= qq(<li>[$list{$uri}] <<a href="$euri">$euri</a>></li>\n); |
$r .= qq(<li>[$list{$uri}] <<a href="$euri">$euri</a>></li>\n); |
1824 |
} |
} |
1856 |
} |
} |
1857 |
|
|
1858 |
package SuikaWiki::Plugin; |
package SuikaWiki::Plugin; |
1859 |
|
our $plugin_directory; # defined in top of this file. |
1860 |
our %List; |
our %List; |
1861 |
|
|
1862 |
sub escape ($$) { main::escape ($_[1]) } |
sub escape ($$) { main::escape ($_[1]) } |
1872 |
} |
} |
1873 |
} |
} |
1874 |
|
|
1875 |
use SuikaWiki::Plugin::WikiFormBasic; |
sub import_plugins () { |
1876 |
|
opendir PDIR, $plugin_directory; |
1877 |
|
my @plugin = grep {s/\.pm$//} readdir (PDIR); |
1878 |
|
closedir PDIR; |
1879 |
|
for (@plugin) { |
1880 |
|
eval qq{ use SuikaWiki::Plugin::$_ } unless /[^A-Za-z0-9_]/; |
1881 |
|
push @{$List{_all}}, qq(SuikaWiki::Plugin::$_); |
1882 |
|
} |
1883 |
|
} |
1884 |
|
|
1885 |
|
sub make_info_page () { |
1886 |
|
my $r = <<EOH; |
1887 |
|
EOH |
1888 |
|
unless ($List{_all}) { |
1889 |
|
$r .= qq('''No plugin is installed!'''\n); |
1890 |
|
} else { |
1891 |
|
my $index = 0; |
1892 |
|
for my $package (sort @{$List{_all}}) { |
1893 |
|
$index++; |
1894 |
|
my $prop = $package->property (); |
1895 |
|
$r .= <<EOH; |
1896 |
|
*$package |
1897 |
|
|
1898 |
|
[$index] '''$prop->{name}''' (Version $prop->{version}) |
1899 |
|
<$prop->{uri}> |
1900 |
|
|
1901 |
|
Provide: |
1902 |
|
@{[do{my $t = ''; for my $f (@{$prop->{provide}||[]}) { |
1903 |
|
$t .= qq(-''$f''\n); |
1904 |
|
for (sort grep m#^\Q$f\E/#, keys %{$prop->{partinfo}}) { |
1905 |
|
$t .= qq(--''$_'' -- $prop->{partinfo}->{$_}\n); |
1906 |
|
} |
1907 |
|
}$t}]} |
1908 |
|
|
1909 |
|
EOH |
1910 |
|
} |
1911 |
|
} |
1912 |
|
$r; |
1913 |
|
} |
1914 |
|
|
1915 |
|
&import_plugins (); |
1916 |
|
|
1917 |
|
package main; |
1918 |
|
&main; |
1919 |
|
exit 0; |
1920 |
|
|
1921 |
1; |
1; |
1922 |
__END__ |
__END__ |