225 |
-content_format => $cf, -noindex => $cf =~ /obsoleted="yes"/); |
-content_format => $cf, -noindex => $cf =~ /obsoleted="yes"/); |
226 |
&print_content ($content, content_format => $cf, last_modified => $lm, |
&print_content ($content, content_format => $cf, last_modified => $lm, |
227 |
-toc => \@toc); |
-toc => \@toc); |
228 |
print &text_to_html (q([[#comment]])); |
print &text_to_html (q([[#comment]])) unless $cf =~ /obsoleted="yes"/; |
229 |
} else { |
} else { |
230 |
&print_header($form{mypage}, -last_modified => $lm); |
&print_header($form{mypage}, -last_modified => $lm); |
231 |
print "<pre>@{[&escape($content)]}</pre>"; |
print "<pre>@{[&escape($content)]}</pre>"; |
266 |
} else { |
} else { |
267 |
&print_editform($database{$page}, &get_info($page, $info_LastModified), admin=>0); |
&print_editform($database{$page}, &get_info($page, $info_LastModified), admin=>0); |
268 |
} |
} |
269 |
|
wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); |
270 |
|
my ($r, $c) = get_search_result ($form{mypage}); |
271 |
|
my $rl = wiki::referer::list_html ($form{mypage}); |
272 |
|
if ($c) { |
273 |
|
print q{<h2 id="wikipage-see-also">See also</h2>}; |
274 |
|
print $r; |
275 |
|
} |
276 |
|
if ($rl) { |
277 |
|
print qq(<div id="wikipage-referer"><h2>参照元</h2>\n$rl</div>\n); |
278 |
|
} |
279 |
&print_footer($page); |
&print_footer($page); |
280 |
} |
} |
281 |
|
|
398 |
my $word = $form{mymsg}; |
my $word = $form{mymsg}; |
399 |
&print_header($SearchPage); |
&print_header($SearchPage); |
400 |
&print_searchform(&escape($word)); |
&print_searchform(&escape($word)); |
401 |
print scalar get_search_result ($word, -output_not_found => 1); |
print scalar get_search_result ($word, -output_not_found => 1, -match_myself => 1); |
402 |
&print_footer($SearchPage); |
&print_footer($SearchPage); |
403 |
} |
} |
404 |
|
|
405 |
sub get_search_result ($;%) { |
sub get_search_result ($;%) { |
406 |
my $word = shift; |
my $word = shift; |
407 |
my %option = @_; |
my %option = @_; |
408 |
my $counter = 0; |
my @r; |
409 |
my $r = ''; |
foreach my $page (keys %database) { |
410 |
foreach my $page (sort keys %database) { |
next if $page eq $RecentChanges || ($page eq $word && !$option{-match_myself}); |
|
next if $page eq $RecentChanges; |
|
411 |
my $content = $database{$page}; |
my $content = $database{$page}; |
412 |
$content =~ s/^\#\?[^\x0A\x0D]+//s; |
my $cf = 'SuikaWiki/0.9'; |
413 |
if ( index ($content, $word) > 0 |
$cf = $1 if $content =~ s/^\#\?([^\x0A\x0D]+)//s; |
414 |
|| index ($page, $word) > 0 |
next if $cf =~ /obsoleted="yes"/; |
415 |
|| index ($word, $page) > 0 |
if (index ($page, $word) > -1) { |
416 |
) { |
my $c = $content =~ s/\Q$word\E/$word/g; |
417 |
$r .= qq(<li><a href ="$url_cgi?@{[&encode($page)]}" class="wiki">@{[&escape($page)]}</a> <span class="wikipage-summary">@{[&escape(&get_subjectline($page))]}</span></li>); |
push @r, [$page, $c+20]; |
418 |
$counter++; |
} elsif (index ($word, $page) > -1) { |
419 |
|
my $c = $content =~ s/\Q$word\E/$word/g; |
420 |
|
push @r, [$page, $c+10]; |
421 |
|
} elsif (my $c = $content =~ s/\Q$word\E/$word/g) { |
422 |
|
push @r, [$page, $c]; |
423 |
} |
} |
424 |
} |
} |
425 |
$r = qq|<ul>$r</ul>| if $r; |
my $em = sub { my $s = shift; $s =~ s#(\Q$word\E)#<em>$1</em>#g; $s }; |
426 |
get_message ($resource{notfound}) |
my $r = join "\n", map {qq(<li>[$_->[1]] <a href ="$url_cgi?@{[&encode($_->[0])]}" class="wiki">@{[&$em(&escape($_->[0]))]}</a> <span class="wikipage-summary">@{[&$em(&escape(&get_subjectline($_->[0])))]}</span></li>)} sort {$b->[1] <=> $a->[1] || $a->[0] cmp $b->[0]} @r; |
427 |
if $counter == 0 && $option{-output_not_found}; |
$r = qq|<ul class="search-result">$r</ul>| if $r; |
428 |
wantarray? ($r, $counter): $r; |
get_message ($resource{notfound}) if @r == 0 && $option{-output_not_found}; |
429 |
|
wantarray? ($r, scalar @r): $r; |
430 |
} |
} |
431 |
|
|
432 |
sub do_create { |
sub do_create { |
493 |
<head> |
<head> |
494 |
<title>$escapedpage</title> |
<title>$escapedpage</title> |
495 |
<link rel="index" href="$url_cgi?$IndexPage"> |
<link rel="index" href="$url_cgi?$IndexPage"> |
496 |
|
<link rel="help" href="$url_cgi?WikiHelp"> |
497 |
<link rel="copyright" href="$url_cgi?$NAME_OF_WikiPageLicense"> |
<link rel="copyright" href="$url_cgi?$NAME_OF_WikiPageLicense"> |
|
<link rev="made" href="mailto:@{[&escape($modifier_mail)]}"> |
|
498 |
<link rel="stylesheet" type="text/css" href="@{[&escape($url_stylesheet)]}"> |
<link rel="stylesheet" type="text/css" href="@{[&escape($url_stylesheet)]}"> |
499 |
@{[$option{-noindex} ? q(<meta name="ROBOTS" content="NOINDEX">) : '']} |
@{[$option{-noindex} ? q(<meta name="ROBOTS" content="NOINDEX">) : '']} |
500 |
</head> |
</head> |
665 |
} elsif (/^:([^:]+):(.*)/) { |
} elsif (/^:([^:]+):(.*)/) { |
666 |
&back_push('dl', 1, \@saved, \@result); |
&back_push('dl', 1, \@saved, \@result); |
667 |
push(@result, '<dt>' . &inline($1) . '</dt>', '<dd>' . &inline($2) . '</dd>'); |
push(@result, '<dt>' . &inline($1) . '</dt>', '<dd>' . &inline($2) . '</dd>'); |
668 |
} elsif (/^(>{1,5})(.*)/) { |
} elsif (/^(?!>>\d)(>{1,5})(.*)/) { |
669 |
&back_push('blockquote', length($1), \@saved, \@result); |
&back_push('blockquote', length($1), \@saved, \@result); |
670 |
|
push @result, "<p>"; |
671 |
push(@result, &inline($2)); |
push(@result, &inline($2)); |
672 |
|
unshift @saved, "</p>"; |
673 |
} elsif (/^\s*$/) { |
} elsif (/^\s*$/) { |
674 |
push(@result, splice(@saved)); |
push(@result, splice(@saved)); |
|
unshift(@saved, "</p>"); |
|
675 |
push(@result, "<p>"); |
push(@result, "<p>"); |
676 |
|
unshift(@saved, "</p>"); |
677 |
} elsif (/^(\s+.*)$/) { |
} elsif (/^(\s+.*)$/) { |
678 |
&back_push('pre', 1, \@saved, \@result); |
&back_push('pre', 1, \@saved, \@result); |
679 |
#push(@result, &escape($1)); # Not &inline, but &escape |
#push(@result, &escape($1)); # Not &inline, but &escape |
733 |
$toc = join("\n", @tocresult); |
$toc = join("\n", @tocresult); |
734 |
$toc = $toc ? qq(<div id="wikipage-toc">$toc</div>) : ''; |
$toc = $toc ? qq(<div id="wikipage-toc">$toc</div>) : ''; |
735 |
} |
} |
736 |
return $toc . join("\n", @result); |
$toc .= join("\n", @result); |
737 |
|
$toc =~ s#<p>\n</p>##g; |
738 |
|
$toc =~ s#[\x0D\x0A]+</#</#g; |
739 |
|
$toc =~ s#<pre>\n#<pre>#g; |
740 |
|
$toc; |
741 |
} |
} |
742 |
|
|
743 |
sub back_push { |
sub back_push { |
757 |
sub inline { |
sub inline { |
758 |
my ($line) = @_; |
my ($line) = @_; |
759 |
$line = &escape($line); |
$line = &escape($line); |
760 |
$line =~ s:\[(INS|DEL|SUP|SUB)\[(.+?)\]\]:<@{[lc $1]}>$2</@{[lc $1]}>:g; |
$line =~ s{\[(INS|DEL|SUP|SUB|VAR|CODE|KBD)(?:\(([A-Za-z0-9\x20-]+)\))?\[(.+?)\]\]}{<@{[lc $1]}@{[$2 ? qq( class="$2") : '']}>$3</@{[lc $1]}>}g; |
761 |
$line =~ s:\[ABBR\[(.+?)\] \[(.+?)\]\]:<acronym title="$2">$1</acronym>:g; |
$line =~ s:\[(WEAK)\[(.+?)\]\]:<span class="@{[lc $1]}">$2</span>:g; |
762 |
$line =~ s:\[RUBY\[(.+?)\] \[(.+?)\]\]:<ruby><rb>$1</rb><rp>(</rp><rt>$2</rt><rp>)</rp></ruby>:g; |
$line =~ s:\[ABBR\[([^]]+)\] \[([^]]+)\]\]:<acronym title="$2">$1</acronym>:g; |
763 |
$line =~ s%\[Q\[(.+?)\](?: \[<([\x21-\x5A\x5E-\x7E]+)>\])?\]%「<q@{[$2?qq( cite="$2"):'']}>$1</q>」%g; |
$line =~ s:\[RUBYB\[([^]]+)\] \[([^]]+)\] \[([^]]+)\]\]:<span class="ruby"><ruby class="rb"><rb>$1</rb><rp>(</rp><rt>$2</rt><rp>)</rp></ruby><span class="rp"> (</span><span class="rt-below">$3</span><span class="rp">) </span></span>:g; |
764 |
$line =~ s|'''([^']+?)'''|<strong>$1</strong>|g; |
$line =~ s:\[RUBY\[([^]]+)\] \[([^]]+)\]\]:<ruby><rb>$1</rb><rp>(</rp><rt>$2</rt><rp>)</rp></ruby>:g; |
765 |
$line =~ s|''([^']+?)''|<em>$1</em>|g; |
$line =~ s:\[RUBYB\[([^]]+)\] \[([^]]+)\]\]:<span class="ruby"><span class="rb">$1</span><span class="rp"> (</span><span class="rt-below">$2</span><span class="rp">) </span></span>:g; |
766 |
$line =~ s|(\d\d\d\d-\d\d-\d\d \(\w\w\w\) \d\d:\d\d:\d\d)|<span class="date">$1</span>|g; # Date |
$line =~ s%\[Q\[([^]]+)\](?: \[<([\x21-\x5A\x5E-\x7E]+)>\])?\]%「<q@{[$2?qq( cite="$2"):'']}>$1</q>」%g; |
767 |
|
$line =~ s|'''([^']+)'''|<strong>$1</strong>|g; |
768 |
|
$line =~ s|''([^']+)''|<em>$1</em>|g; |
769 |
$line =~ s! |
$line =~ s! |
770 |
( |
( |
771 |
(?:<(?:mailto|http|https|ftp|urn|news):[\x21-\x7E]*)> |
(?:<(?:mailto|http|https|ftp|urn|news):[\x21-\x7E]*)> |
772 |
| |
| |
773 |
(?:$bracket_name)) # [[likethis]], [[#comment]], [[Friend:remotelink]] |
(?:$bracket_name)) # [[likethis]], [[#comment]], [[Friend:remotelink]] |
774 |
|\[\[([^[]+?)]>>([0-9]+)] |
|\[\[([^[]+?)]>>([0-9]+)] # [[WikiName]>>1] |
775 |
|>>([0-9]+) |
|>>([0-9]+) |
776 |
! |
! |
777 |
my ($l, $page,$anchor, $anum) = ($1, $3,$4, 0+$5); |
my ($l, $page,$anchor, $anum) = ($1, $3,$4, 0+$5); |
878 |
if (param()) { |
if (param()) { |
879 |
foreach my $var (param()) { |
foreach my $var (param()) { |
880 |
$form{$var} = param($var); |
$form{$var} = param($var); |
881 |
} |
} |
|
} else { |
|
|
$ENV{QUERY_STRING} = $FrontPage; |
|
882 |
} |
} |
883 |
|
if ($main::ENV{QUERY_STRING} && $main::ENV{QUERY_STRING} !~ /[&;]/) { |
884 |
my $query = &decode($ENV{QUERY_STRING}); |
my $query = &decode($main::ENV{QUERY_STRING}); |
885 |
if ($page_command{$query}) { |
if ($page_command{$query}) { |
886 |
$form{mycmd} = $page_command{$query}; |
$form{mycmd} = $page_command{$query}; |
887 |
$form{mypage} = $query; |
$form{mypage} = $query; |
888 |
} elsif ($query =~ /^($wiki_name)$/) { |
} else { |
|
$form{mycmd} = 'read'; |
|
|
$form{mypage} = $1; |
|
|
} elsif ($database{$query}) { |
|
|
$form{mycmd} = 'read'; |
|
889 |
$form{mypage} = $query; |
$form{mypage} = $query; |
890 |
|
$form{mycmd} = $database{$form{mypage}} ? 'read' : 'edit'; |
891 |
|
} |
892 |
} |
} |
893 |
|
$form{mypage} ||= 'HomePage'; |
894 |
|
|
895 |
# mypreview_edit -> do_edit, with preview. |
# mypreview_edit -> do_edit, with preview. |
896 |
# mypreview_adminedit -> do_adminedit, with preview. |
# mypreview_adminedit -> do_adminedit, with preview. |
902 |
} |
} |
903 |
} |
} |
904 |
|
|
905 |
# |
# |
906 |
# $form{mycmd} is frozen here. |
# $form{mycmd} is frozen here. |
907 |
# |
# |
908 |
|
|
909 |
$form{mymsg} = &code_convert(\$form{mymsg}, $kanjicode); |
$form{mymsg} = &code_convert(\$form{mymsg}, $kanjicode); |
910 |
$form{myname} = &code_convert(\$form{myname}, $kanjicode); |
$form{myname} = &code_convert(\$form{myname}, $kanjicode); |
1063 |
|
|
1064 |
print <<"EOD"; |
print <<"EOD"; |
1065 |
<form action="$url_cgi" method="post"> |
<form action="$url_cgi" method="post"> |
1066 |
|
<h2>$escapedmypageの編集</h2> |
1067 |
@{[ $mode{admin} ? qq($resource{frozenpassword} <input type="password" name="mypassword" value="$escapedmypassword" size="10"><br>) : "" ]} |
@{[ $mode{admin} ? qq($resource{frozenpassword} <input type="password" name="mypassword" value="$escapedmypassword" size="10"><br>) : "" ]} |
1068 |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
1069 |
<input type="hidden" name="mypage" value="$escapedmypage"> |
<input type="hidden" name="mypage" value="$escapedmypage"> |
1080 |
qq( |
qq( |
1081 |
<input type="checkbox" name="mytouch" value="on" checked="checked">$resource{touch}<br> |
<input type="checkbox" name="mytouch" value="on" checked="checked">$resource{touch}<br> |
1082 |
<input type="submit" name="mypreview_$edit" value="$resource{previewbutton}"> |
<input type="submit" name="mypreview_$edit" value="$resource{previewbutton}"> |
1083 |
<input type="submit" name="mypreview_write" value="$resource{savebutton}" accesskey="S"><kbd>S</kbd><br> |
<input type="submit" name="mypreview_write" value="$resource{savebutton}" accesskey="S"><kbd>S</kbd> |
1084 |
|
[@{[do {my $n = 0; |
1085 |
|
$mymsg =~ s/(?:-+\s)?\[([0-9]+)\]/$n = $1 if $1 > $n; $&/mge; |
1086 |
|
++$n}]}]<br> |
1087 |
) |
) |
1088 |
]} |
]} |
1089 |
</form> |
</form> |
1090 |
EOD |
EOD |
1091 |
unless ($mode{conflict}) { |
unless ($mode{conflict}) { |
1092 |
# Show the format rule. |
# Show the format rule. |
1093 |
open(FILE, $file_format) or &print_error("($file_format)"); |
my $help = $database{'WikiEditHelp'}; |
1094 |
my $content = join('', <FILE>); |
$help =~ s!^\#\?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:[^0-9.\x0D\x0A][^\x0D\x0A]*)?)[\x0D\x0A]+!!s; |
1095 |
&code_convert(\$content, $kanjicode); |
print &text_to_html ($help, toc => 0); |
1096 |
close(FILE); |
# open(FILE, $file_format) or &print_error("($file_format)"); |
1097 |
print &text_to_html($content, toc=>0); |
# my $content = join('', <FILE>); |
1098 |
|
# &code_convert(\$content, $kanjicode); |
1099 |
|
# close(FILE); |
1100 |
|
# print &text_to_html($content, toc=>0); |
1101 |
} |
} |
1102 |
} |
} |
1103 |
|
|
1312 |
|
|
1313 |
sub do_comment { |
sub do_comment { |
1314 |
my ($content) = $database{$form{mypage}}; |
my ($content) = $database{$form{mypage}}; |
1315 |
my $datestr = &get_now; |
my $default_name; ## this code does not strict. |
1316 |
my $namestr = $form{myname} || $DEFAULT_embed_comment_name; |
$default_name = $1 if $content =~ /default-name="([^"]+)"/; |
1317 |
|
my $datestr = '[WEAK['.&get_now.']]'; |
1318 |
|
my $namestr = $form{myname} || $default_name || $DEFAULT_embed_comment_name; |
1319 |
|
($namestr = '', $datestr = '') if $form{myname} eq 'nodate'; |
1320 |
if ($namestr =~ /^(?:>>)?[0-9]/) { |
if ($namestr =~ /^(?:>>)?[0-9]/) { |
1321 |
$namestr = qq( ''$namestr'': ); |
$namestr = qq( ''$namestr'': ); |
1322 |
} else { |
} elsif (length $namestr) { |
1323 |
$namestr = qq( ''[[$namestr]]'': ); |
$namestr = qq( ''[[$namestr]]'': ); |
1324 |
} |
} |
1325 |
my $anchor = 0; |
my $anchor = 0; |
1338 |
$i++; $embed; |
$i++; $embed; |
1339 |
}ge; |
}ge; |
1340 |
unless ($o) { |
unless ($o) { |
1341 |
|
$content = "#?SuikaWiki/0.9\n\n" unless $content; |
1342 |
|
$content .= "\n" unless $content =~ /\n$/s; |
1343 |
$content .= "- [$anchor] $datestr$namestr$form{mymsg}\n"; |
$content .= "- [$anchor] $datestr$namestr$form{mymsg}\n"; |
1344 |
} |
} |
1345 |
$form{__comment_anchor_index} = $anchor; |
$form{__comment_anchor_index} = $anchor; |
1346 |
if ($form{mymsg}) { |
if ($form{mymsg} || $form{myname}) { |
1347 |
$form{mymsg} = $content; |
$form{mymsg} = $content; |
1348 |
$form{mytouch} = 'on'; |
$form{mytouch} = 'on'; |
1349 |
&do_write; |
&do_write; |
1360 |
unless ($main::_EMBEDED) { |
unless ($main::_EMBEDED) { |
1361 |
my $lastmodified = &get_info($form{mypage}, $info_LastModified); |
my $lastmodified = &get_info($form{mypage}, $info_LastModified); |
1362 |
return <<"EOD"; |
return <<"EOD"; |
1363 |
<form action="$url_cgi" method="post" id="x-comment-@{[++$CommentIndex]}"> |
<form action="$url_cgi" method="post" id="x-comment-@{[++$CommentIndex]}" class="comment"><p> |
1364 |
<input type="hidden" name="mycmd" value="comment"> |
<input type="hidden" name="mycmd" value="comment"> |
1365 |
<input type="hidden" name="mypage" value="$form{mypage}"> |
<input type="hidden" name="mypage" value="$form{mypage}"> |
1366 |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
1367 |
<input type="hidden" name="mytouch" value="on"> |
<input type="hidden" name="mytouch" value="on"> |
1368 |
<input type="hidden" name="comment_index" value="$CommentIndex"> |
<input type="hidden" name="comment_index" value="$CommentIndex"> |
1369 |
$embed_comment_Name_Prompt |
$embed_comment_Name_Prompt |
1370 |
<input type="text" name="myname" value="" size="10"> |
<input type="text" name="myname" value="" size="10" class="comment-name"> |
1371 |
<input type="text" name="mymsg" value="" size="60"> |
<input type="text" name="mymsg" value="" size="60" class="comment-msg"> |
1372 |
<input type="submit" value="$resource{commentbutton}"> |
<input type="submit" value="$resource{commentbutton}" class="comment-submit"> |
1373 |
</form> |
</p></form> |
1374 |
EOD |
EOD |
1375 |
} else { |
} else { |
1376 |
return <<"EOD"; |
return <<"EOD"; |
1385 |
EOD |
EOD |
1386 |
} |
} |
1387 |
} elsif ($embedded =~ /$embed_command{searched}/) { |
} elsif ($embedded =~ /$embed_command{searched}/) { |
1388 |
return get_search_result ($1); |
return get_search_result ($1, -match_myself => 1); |
1389 |
# Walrus add (5) start |
# Walrus add (5) start |
1390 |
} elsif ($embedded =~ /$embed_interwiki/ and my $remoteurl = $interwiki{$2}) { |
} elsif ($embedded =~ /$embed_interwiki/ and my $remoteurl = $interwiki{$2}) { |
1391 |
$_ = &make_interwiki_box($1, $2); |
$_ = &make_interwiki_box($1, $2); |
1403 |
} elsif (length $content) { |
} elsif (length $content) { |
1404 |
$r = "<pre>@{[&escape ($content)]}</pre>"; |
$r = "<pre>@{[&escape ($content)]}</pre>"; |
1405 |
} else { |
} else { |
1406 |
$r = &text_to_html ("[[$name]]", content_format => 'SuikaWiki/0.9'); |
$r = &text_to_html ("[INS[\n埋め込まれている [[$name]] はまだ書かれていません。\n]INS]\n", content_format => 'SuikaWiki/0.9'); |
1407 |
} |
} |
1408 |
} else { ## nested #EMBED |
} else { ## nested #EMBED |
1409 |
$r = &text_to_html ("[INS[\n[[$name]] の埋め込みは (入り組んでいるので) 解決されませんでした。\n]INS]\n", content_format => 'SuikaWiki/0.9'); |
$r = &text_to_html ("[INS[\n[[$name]] の埋め込みは (入り組んでいるので) 解決されませんでした。\n]INS]\n", content_format => 'SuikaWiki/0.9'); |
1410 |
} |
} |
1411 |
return qq(<blockquote title="@{[&escape($name)]}">$r</blockquote>); |
return qq(<blockquote title="@{[&escape($name)]}">$r<div class="cite-note">『<cite><a href="$url_cgi?@{[&encode($name)]}" class="wiki">@{[&escape($name)]}</a></cite>』</div></blockquote>); |
1412 |
} elsif ($embedded =~ /^\[\[\#randomlink:(.+)\]\]$/) { |
} elsif ($embedded =~ /^\[\[\#randomlink:(.+)\]\]$/) { |
1413 |
return qq(<a href="$url_cgi?mycmd=RandomJump;x-param=@{[time.[0..9]->[rand 10]]}" class="wiki randomlink">$1</a>); |
return qq(<a href="$url_cgi?mycmd=RandomJump;x-param=@{[time.[0..9]->[rand 10]]}" class="wiki randomlink">$1</a>); |
1414 |
} else { |
} else { |