| 83 |
my $file_conflict = "$modifier_dir_data/conflict.txt"; |
my $file_conflict = "$modifier_dir_data/conflict.txt"; |
| 84 |
my $file_format = "$modifier_dir_data/format.txt"; |
my $file_format = "$modifier_dir_data/format.txt"; |
| 85 |
my $url_cgi = 'wiki'; |
my $url_cgi = 'wiki'; |
| 86 |
my $url_stylesheet = 'wiki-style.css'; |
my $url_stylesheet = $url_cgi.'?mycmd=TEXT_CSS;mypage=WikiHTMLStyle'; |
| 87 |
my $icontag = '<img src="/icons/folder" alt="*" width="40" height="40" />'; |
my $icontag = '<img src="/icons/folder" alt="*" width="40" height="40" />'; |
| 88 |
my $maxrecent = 50; |
my $maxrecent = 50; |
| 89 |
my $cols = 80; |
my $cols = 80; |
| 110 |
my $CreatePage = 'CreatePage'; |
my $CreatePage = 'CreatePage'; |
| 111 |
my $ErrorPage = 'ErrorPage'; |
my $ErrorPage = 'ErrorPage'; |
| 112 |
my $RssPage = 'RssPage'; |
my $RssPage = 'RssPage'; |
| 113 |
|
my $NAME_OF_WikiPageLicense = 'WikiPageLicense'; |
| 114 |
my $AdminSpecialPage = 'Admin Special Page'; # must include spaces. |
my $AdminSpecialPage = 'Admin Special Page'; # must include spaces. |
| 115 |
############################## |
############################## |
| 116 |
# my $wiki_name = '\b([A-Z][a-z]+([A-Z][a-z]+)+)\b'; # Walrus del (2) |
# my $wiki_name = '\b([A-Z][a-z]+([A-Z][a-z]+)+)\b'; # Walrus del (2) |
| 118 |
my $bracket_name = '\[\[(\S+?)\]\]'; |
my $bracket_name = '\[\[(\S+?)\]\]'; |
| 119 |
my $embedded_name = '\[\[(#\S+?)\]\]'; |
my $embedded_name = '\[\[(#\S+?)\]\]'; |
| 120 |
my $interwiki_definition = '\[\[(\S+?)\ (\S+?)\]\]'; |
my $interwiki_definition = '\[\[(\S+?)\ (\S+?)\]\]'; |
| 121 |
my $interwiki_name = '([^:]+):([^:].*)'; |
my $interwiki_name = 'i:([^:]+):([^:].*)'; |
| 122 |
############################## |
############################## |
| 123 |
my $embed_comment = '[[#comment]]'; |
my $embed_comment = '[[#comment]]'; |
| 124 |
my $embed_rcomment = '[[#rcomment]]'; |
my $embed_rcomment = '[[#rcomment]]'; |
| 125 |
|
my $embed_comment_Name_Prompt = '名前:'; |
| 126 |
|
my $DEFAULT_embed_comment_name = '名無しさん'; |
| 127 |
my $embed_interwiki = '^\[\[#(box|text|password):(\S+)\]\]$'; # Walrus add (5) |
my $embed_interwiki = '^\[\[#(box|text|password):(\S+)\]\]$'; # Walrus add (5) |
| 128 |
|
my %embed_command = ( |
| 129 |
|
searched => '^\[\[#searched:([^\]]+)\]\]$', |
| 130 |
|
); |
| 131 |
############################## |
############################## |
| 132 |
my $info_LastModified = 'LastModified'; |
my $info_LastModified = 'LastModified'; |
| 133 |
my $info_IsFrozen = 'IsFrozen'; |
my $info_IsFrozen = 'IsFrozen'; |
| 164 |
); |
); |
| 165 |
my %command_do = ( |
my %command_do = ( |
| 166 |
read => \&do_read, |
read => \&do_read, |
| 167 |
|
TEXT_CSS => \&do_output_css, |
| 168 |
edit => \&do_edit, |
edit => \&do_edit, |
| 169 |
adminedit => \&do_adminedit, |
adminedit => \&do_adminedit, |
| 170 |
adminchangepasswordform => \&do_adminchangepasswordform, |
adminchangepasswordform => \&do_adminchangepasswordform, |
| 205 |
} |
} |
| 206 |
|
|
| 207 |
sub do_read { |
sub do_read { |
| 208 |
&print_header($form{mypage}); |
&print_header($form{mypage}); |
| 209 |
&print_content($database{$form{mypage}}); |
my $content = $database{$form{mypage}}; |
| 210 |
&print_footer($form{mypage}); |
my $cf = 'SuikaWiki/0.9'; |
| 211 |
|
$cf = $1 if $content =~ s#^(?:/\*\s*|\#\?)?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:\s[^\x0D\x0A]+)?)[\x0D\x0A]+##s; |
| 212 |
|
if ($cf =~ m#^SuikaWiki/0.9(?:$|\s)#) { |
| 213 |
|
&print_content($content, $cf); |
| 214 |
|
print &text_to_html (q([[#comment]])); |
| 215 |
|
} else { |
| 216 |
|
print "<pre>@{[&escape($content)]}</pre>"; |
| 217 |
|
} |
| 218 |
|
my ($r, $c) = get_search_result ($form{mypage}); |
| 219 |
|
if ($c) { |
| 220 |
|
print q{<h2 id="SEE-ALSO">See also</h2>}; |
| 221 |
|
print $r; |
| 222 |
|
} |
| 223 |
|
&print_footer($form{mypage}); |
| 224 |
|
} |
| 225 |
|
|
| 226 |
|
sub do_output_css { |
| 227 |
|
my $content = $database{$form{mypage}}; |
| 228 |
|
if ($content =~ m#^\s*/\*\s*W3C-CSS#) { |
| 229 |
|
print "Content-Type: text/css; charset=$charset\n"; |
| 230 |
|
print "\n"; |
| 231 |
|
print $content; |
| 232 |
|
} else { |
| 233 |
|
print "Status: 406 Unsupported Media Type\n"; |
| 234 |
|
&print_header('WikiPageIsNotCSS'); |
| 235 |
|
&print_content($database{WikiPageIsNotCSS}); |
| 236 |
|
&print_footer('WikiPageIsNotCSS'); |
| 237 |
|
} |
| 238 |
} |
} |
| 239 |
|
|
| 240 |
sub do_edit { |
sub do_edit { |
| 300 |
print qq(<ul>); |
print qq(<ul>); |
| 301 |
foreach my $page (sort keys %database) { |
foreach my $page (sort keys %database) { |
| 302 |
if (&is_editable($page)) { |
if (&is_editable($page)) { |
| 303 |
print qq(<li><a href="$url_cgi?@{[&encode($page)]}">$page</a>@{[&escape(&get_subjectline($page))]}</li>); |
print qq(<li><a href="$url_cgi?@{[&encode($page)]}">@{[&escape($page)]}</a>@{[&escape(&get_subjectline($page))]}</li>); |
| 304 |
# print qq(<li>@{[&get_info($page, $info_IsFrozen)]}</li>); |
# print qq(<li>@{[&get_info($page, $info_IsFrozen)]}</li>); |
| 305 |
# print qq(<li>@{[0 + &is_frozen($page)]}</li>); |
# print qq(<li>@{[0 + &is_frozen($page)]}</li>); |
| 306 |
} |
} |
| 342 |
&update_recent_changes; |
&update_recent_changes; |
| 343 |
} |
} |
| 344 |
&set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen}); |
&set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen}); |
| 345 |
&print_header($CompletedSuccessfully); |
&print_header($CompletedSuccessfully, -goto => $url_cgi.'?'.&encode($form{mypage})); |
| 346 |
&print_message($resource{saved}); |
&print_message($resource{saved}); |
| 347 |
&print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}"); |
&print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}"); |
| 348 |
&print_footer($CompletedSuccessfully); |
&print_footer($CompletedSuccessfully); |
| 366 |
} |
} |
| 367 |
|
|
| 368 |
sub do_search { |
sub do_search { |
| 369 |
my $word = &escape($form{mymsg}); |
my $word = $form{mymsg}; |
| 370 |
&print_header($SearchPage); |
&print_header($SearchPage); |
| 371 |
&print_searchform($word); |
&print_searchform(&escape($word)); |
| 372 |
my $counter = 0; |
print scalar get_search_result ($word, -output_not_found => 1); |
|
foreach my $page (sort keys %database) { |
|
|
next if $page =~ /^$RecentChanges$/; |
|
|
if ($database{$page} =~ /\Q$form{mymsg}\E/ or $page =~ /\Q$form{mymsg}\E/) { |
|
|
if ($counter == 0) { |
|
|
print qq|<ul>|; |
|
|
} |
|
|
print qq(<li><a href ="$url_cgi?@{[&encode($page)]}">$page</a>@{[&escape(&get_subjectline($page))]}</li>); |
|
|
$counter++; |
|
|
} |
|
|
} |
|
|
if ($counter == 0) { |
|
|
&print_message($resource{notfound}); |
|
|
} else { |
|
|
print qq|</ul>|; |
|
|
} |
|
| 373 |
&print_footer($SearchPage); |
&print_footer($SearchPage); |
| 374 |
} |
} |
| 375 |
|
|
| 376 |
|
sub get_search_result ($;%) { |
| 377 |
|
my $word = shift; |
| 378 |
|
my %option = @_; |
| 379 |
|
my $counter = 0; |
| 380 |
|
my $r = ''; |
| 381 |
|
foreach my $page (sort keys %database) { |
| 382 |
|
next if $page eq $RecentChanges; |
| 383 |
|
if ( index ($database{$page}, $word) > 0 |
| 384 |
|
|| index ($page, $word) > 0 |
| 385 |
|
|| index ($word, $page) > 0 |
| 386 |
|
) { |
| 387 |
|
$r .= qq(<li><a href ="$url_cgi?@{[&encode($page)]}" class="wiki">@{[&escape($page)]}</a>@{[&escape(&get_subjectline($page))]}</li>); |
| 388 |
|
$counter++; |
| 389 |
|
} |
| 390 |
|
} |
| 391 |
|
$r = qq|<ul>$r</ul>| if $r; |
| 392 |
|
get_message ($resource{notfound}) |
| 393 |
|
if $counter == 0 && $option{-output_not_found}; |
| 394 |
|
wantarray? ($r, $counter): $r; |
| 395 |
|
} |
| 396 |
|
|
| 397 |
sub do_create { |
sub do_create { |
| 398 |
&print_header($CreatePage); |
&print_header($CreatePage); |
| 399 |
print <<"EOD"; |
print <<"EOD"; |
| 426 |
} |
} |
| 427 |
|
|
| 428 |
sub print_header { |
sub print_header { |
| 429 |
my ($page) = @_; |
my ($page,%option) = @_; |
| 430 |
my $bodyclass = "normal"; |
my $bodyclass = "normal"; |
|
my $editable = 0; |
|
|
my $admineditable = 0; |
|
| 431 |
if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) { |
if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) { |
|
$editable = 0; |
|
|
$admineditable = 1; |
|
| 432 |
$bodyclass = "frozen"; |
$bodyclass = "frozen"; |
| 433 |
} elsif (&is_editable($page) and $form{mycmd} =~ /^(read|write)$/) { |
} |
| 434 |
$admineditable = 1; |
if ($option{-goto}) { |
| 435 |
$editable = 1; |
print qq{Refresh: 0; url="$option{-goto}"\n}; |
|
} else { |
|
|
$editable = 0; |
|
| 436 |
} |
} |
| 437 |
my $cookedpage = &encode($page); |
my $cookedpage = &encode($page); |
| 438 |
|
my $escapedpage = &escape($page); |
| 439 |
print <<"EOD"; |
print <<"EOD"; |
| 440 |
Content-type: text/html; charset=$charset |
Content-type: text/html; charset=$charset |
| 441 |
Content-Language: $lang |
Content-Language: $lang |
| 446 |
"http://www.w3.org/TR/html4/loose.dtd"> |
"http://www.w3.org/TR/html4/loose.dtd"> |
| 447 |
<html lang="$lang"> |
<html lang="$lang"> |
| 448 |
<head> |
<head> |
| 449 |
<title>$page @{[&escape(&get_subjectline($page))]}</title> |
<title>$escapedpage @{[&escape(&get_subjectline($page))]}</title> |
| 450 |
<link rel="index" href="$url_cgi?$IndexPage"> |
<link rel="index" href="$url_cgi?$IndexPage"> |
| 451 |
<link rev="made" href="mailto:$modifier_mail"> |
<link rel="copyright" href="$url_cgi?$NAME_OF_WikiPageLicense"> |
| 452 |
<link rel="stylesheet" type="text/css" href="$url_stylesheet"> |
<link rev="made" href="mailto:@{[&escape($modifier_mail)]}"> |
| 453 |
|
<link rel="stylesheet" type="text/css" href="@{[&escape($url_stylesheet)]}"> |
| 454 |
</head> |
</head> |
| 455 |
<body class="$bodyclass"> |
<body class="$bodyclass"> |
| 456 |
|
EOD |
| 457 |
|
&print_navigate_links ($page); |
| 458 |
|
print <<EOD; |
| 459 |
|
<h1 class="header"><a |
| 460 |
|
title="$resource{searchthispage}" |
| 461 |
|
href="$url_cgi?mycmd=search;mymsg=$cookedpage">@{[&escape($page)]}</a>@{[&escape(&get_subjectline($page))]}</h1> |
| 462 |
|
EOD |
| 463 |
|
} |
| 464 |
|
|
| 465 |
|
sub print_navigate_links (@) { |
| 466 |
|
my ($page) = @_; |
| 467 |
|
my $editable = 0; |
| 468 |
|
my $admineditable = 0; |
| 469 |
|
if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) { |
| 470 |
|
$editable = 0; |
| 471 |
|
$admineditable = 1; |
| 472 |
|
} elsif (&is_editable($page) and $form{mycmd} =~ /^(read|write)$/) { |
| 473 |
|
$admineditable = 1; |
| 474 |
|
$editable = 1; |
| 475 |
|
} else { |
| 476 |
|
$editable = 0; |
| 477 |
|
} |
| 478 |
|
my $cookedpage = &encode($page); |
| 479 |
|
print <<EOH; |
| 480 |
<div class="tools"> |
<div class="tools"> |
| 481 |
@{[ $admineditable |
@{[ $admineditable |
| 482 |
? 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">$resource{admineditbutton}</a> | ) |
| 483 |
: qq() |
: qq() |
| 484 |
]} |
]} |
| 485 |
@{[ $editable |
@{[ $editable |
| 486 |
? qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedpage">$resource{editbutton}</a> | ) |
? qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedpage" accesskey="E">$resource{editbutton} <kbd>E</kbd></a> | ) |
| 487 |
: qq() |
: qq() |
| 488 |
]} |
]} |
| 489 |
@{[ $admineditable |
@{[ $admineditable |
| 497 |
<a href="$url_cgi?$SearchPage">$resource{searchbutton}</a> | |
<a href="$url_cgi?$SearchPage">$resource{searchbutton}</a> | |
| 498 |
<a href="$url_cgi?$RecentChanges">$resource{recentchangesbutton}</a> |
<a href="$url_cgi?$RecentChanges">$resource{recentchangesbutton}</a> |
| 499 |
</div> |
</div> |
| 500 |
<h1 class="header"><a |
EOH |
|
title="$resource{searchthispage}" |
|
|
href="$url_cgi?mycmd=search;mymsg=$cookedpage">$page</a>@{[&escape(&get_subjectline($page))]}</h1> |
|
|
EOD |
|
| 501 |
} |
} |
| 502 |
|
|
| 503 |
sub print_footer { |
sub print_footer { |
| 504 |
my ($page) = @_; |
my ($page) = @_; |
| 505 |
$walrus_log = ($walrus_debugging) ? &text_to_html("----\n$walrus_log") : ''; # Walrus add (debug) |
$walrus_log = ($walrus_debugging) ? &text_to_html("----\n$walrus_log") : ''; # Walrus add (debug) |
| 506 |
# Walrus mod (1) start |
# Walrus mod (1) start |
| 507 |
print <<"EOD"; |
my $cvslog = '$Revision$ $Date$'; |
| 508 |
|
print_navigate_links ($page); |
| 509 |
|
print <<"EOD"; |
| 510 |
<div class="footer"> |
<div class="footer"> |
| 511 |
<p> |
<p> |
| 512 |
<a href="http://digit.que.ne.jp/work/">WalWiki</a> $walversion © 2000-2002 by <a href="http://digit.que.ne.jp/">Makio Tsukamoto</a>.<br /> |
<a href="http://digit.que.ne.jp/work/">WalWiki</a> $walversion © 2000-2002 by <a href="http://digit.que.ne.jp/">Makio Tsukamoto</a>.<br /> |
| 513 |
based on <a href="http://www.hyuki.com/yukiwiki/">YukiWiki</a> $version © 2000-2002 by <a href="http://www.hyuki.com/">Hiroshi Yuki</a>.<br /> |
based on <a href="http://www.hyuki.com/yukiwiki/">YukiWiki</a> $version © 2000-2002 by <a href="http://www.hyuki.com/">Hiroshi Yuki</a>.<br /> |
| 514 |
<a href="/gate/cvs/wakaba/wiki/" title="CVS Repository"> |
<a href="/gate/cvs/wakaba/wiki/" title="CVS Repository"> |
| 515 |
$Revision$ $Date$ |
$cvslog |
| 516 |
</a> |
</a> |
| 517 |
</p> |
</p> |
| 518 |
<div class="navigation"> |
<div class="navigation"> |
| 521 |
<a href="/search/" title="このサーバーの検索">検索</a>] |
<a href="/search/" title="このサーバーの検索">検索</a>] |
| 522 |
</div> |
</div> |
| 523 |
</div> |
</div> |
| 524 |
$walrus_log <!-- Walrus add (debug) --> |
$walrus_log |
| 525 |
</body> |
</body> |
| 526 |
</html> |
</html> |
| 527 |
EOD |
EOD |
| 544 |
sub escape { |
sub escape { |
| 545 |
my $s = shift; |
my $s = shift; |
| 546 |
$s =~ s|\r\n|\n|g; |
$s =~ s|\r\n|\n|g; |
| 547 |
$s =~ s|\&|&|g; |
$s =~ s|&|&|g; |
| 548 |
$s =~ s|<|<|g; |
$s =~ s|<|<|g; |
| 549 |
$s =~ s|>|>|g; |
$s =~ s|>|>|g; |
| 550 |
$s =~ s|"|"|g; |
$s =~ s|"|"|g; |
| 554 |
sub unescape { |
sub unescape { |
| 555 |
my $s = shift; |
my $s = shift; |
| 556 |
# $s =~ s|\n|\r\n|g; |
# $s =~ s|\n|\r\n|g; |
| 557 |
$s =~ s|\&|\&|g; |
$s =~ s|<|<|g; |
| 558 |
$s =~ s|\<|\<|g; |
$s =~ s|>|>|g; |
| 559 |
$s =~ s|\>|\>|g; |
$s =~ s|"|"|g; |
| 560 |
$s =~ s|\"|\"|g; |
$s =~ s|&|&|g; |
| 561 |
return $s; |
return $s; |
| 562 |
} |
} |
| 563 |
|
|
| 564 |
sub print_content { |
sub print_content ($;$) { |
| 565 |
my ($rawcontent) = @_; |
my ($rawcontent, $format) = @_; |
| 566 |
print &text_to_html($rawcontent, toc=>1); |
print &text_to_html($rawcontent, toc=>1); |
| 567 |
} |
} |
| 568 |
|
|
| 576 |
push(@result, "<p>"); |
push(@result, "<p>"); |
| 577 |
foreach (@txt) { |
foreach (@txt) { |
| 578 |
chomp; |
chomp; |
| 579 |
# Walrus mod (6) start |
if (/^\*\*\*\*\*([^\x0D\x0A]*)/) { |
| 580 |
if ($saved[0] eq '</html>') { |
push(@toc, qq(----- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
|
if (/<\/html>/i) { splice(@saved); } |
|
|
else { push (@result, &html_to_ignored_html($_)); } |
|
|
} elsif (/^<html>/i and &is_ignore_html($form{mypage})) { |
|
|
push(@result, splice(@saved)); |
|
|
push(@saved, '</html>'); |
|
|
if (/^\*\*\*\*\*(.*)/) { |
|
|
push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n)); |
|
| 581 |
push(@result, splice(@saved), qq(<h6 id="i$tocnum">) . &inline($1) . '</h6>'); |
push(@result, splice(@saved), qq(<h6 id="i$tocnum">) . &inline($1) . '</h6>'); |
| 582 |
$tocnum++; |
$tocnum++; |
| 583 |
} elsif (/^\*\*\*\*(.*)/) { |
} elsif (/^\*\*\*\*([^\x0D\x0A]*)/) { |
| 584 |
push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n)); |
push(@toc, qq(---- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
| 585 |
push(@result, splice(@saved), qq(<h5 id="i$tocnum">) . &inline($1) . '</h5>'); |
push(@result, splice(@saved), qq(<h5 id="i$tocnum">) . &inline($1) . '</h5>'); |
| 586 |
$tocnum++; |
$tocnum++; |
| 587 |
} elsif (/^\*\*\*(.*)/) { |
} elsif (/^\*\*\*([^\x0D\x0A]*)/) { |
| 588 |
push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n)); |
push(@toc, qq(--- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
| 589 |
push(@result, splice(@saved), qq(<h4 id="i$tocnum">) . &inline($1) . '</h4>'); |
push(@result, splice(@saved), qq(<h4 id="i$tocnum">) . &inline($1) . '</h4>'); |
| 590 |
$tocnum++; |
$tocnum++; |
| 591 |
} elsif (/^\*\*(.*)/) { |
} elsif (/^\*\*([^\x0D\x0A]*)/) { |
| 592 |
# if (/^\*\*(.*)/) { |
# if (/^\*\*(.*)/) { |
| 593 |
# Walrus mod (6) end |
# Walrus mod (6) end |
| 594 |
push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n)); |
push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
| 595 |
push(@result, splice(@saved), qq(<h3><a name="i$tocnum"> </a>) . &inline($1) . '</h3>'); |
push(@result, splice(@saved), qq(<h3><a name="i$tocnum"> </a>) . &inline($1) . '</h3>'); |
| 596 |
$tocnum++; |
$tocnum++; |
| 597 |
} elsif (/^\*(.*)/) { |
} elsif (/^\*([^\x0D\x0A]*)/) { |
| 598 |
push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)]}</a>\n)); |
push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
| 599 |
push(@result, splice(@saved), qq(<h2><a name="i$tocnum"> </a>) . &inline($1) . '</h2>'); |
push(@result, splice(@saved), qq(<h2><a name="i$tocnum"> </a>) . &inline($1) . '</h2>'); |
| 600 |
$tocnum++; |
$tocnum++; |
| 601 |
#} elsif (/^----/) { |
} elsif (/^(={1,6})(.*)/) { |
|
# push(@result, splice(@saved), '<hr>'); |
|
|
} elsif (/^(={1,5})(.*)/) { |
|
| 602 |
&back_push('ol', length($1), \@saved, \@result); |
&back_push('ol', length($1), \@saved, \@result); |
| 603 |
push(@result, '<li>' . &inline($2) . '</li>'); |
push(@result, '<li>' . &inline($2) . '</li>'); |
| 604 |
} elsif (/^(-{1,5})(.*)/) { |
} elsif (/^(-{1,6})(.*)/) { |
| 605 |
&back_push('ul', length($1), \@saved, \@result); |
&back_push('ul', length($1), \@saved, \@result); |
| 606 |
push(@result, '<li>' . &inline($2) . '</li>'); |
push(@result, '<li>' . &inline($2) . '</li>'); |
| 607 |
} elsif (/^:([^:]+):(.*)/) { |
} elsif (/^:([^:]+):(.*)/) { |
| 617 |
} elsif (/^(\s+.*)$/) { |
} elsif (/^(\s+.*)$/) { |
| 618 |
&back_push('pre', 1, \@saved, \@result); |
&back_push('pre', 1, \@saved, \@result); |
| 619 |
#push(@result, &escape($1)); # Not &inline, but &escape |
#push(@result, &escape($1)); # Not &inline, but &escape |
| 620 |
push(@result, &inline($1)); # Not &inline, but &escape |
push(@result, &inline($1)); |
| 621 |
# } elsif (/^\,(.*)$/) { # Walrus del (BF) |
# } elsif (/^\,(.*)$/) { # Walrus del (BF) |
| 622 |
} elsif (/^\,(.*?)[\x0D\x0A]*$/) { # Walrus add (BF) |
} elsif (/^\,(.*?)[\x0D\x0A]*$/) { # Walrus add (BF) |
| 623 |
&back_push('table', 1, \@saved, \@result, ' border="1"'); |
&back_push('table', 1, \@saved, \@result, ' border="1"'); |
| 642 |
push(@result, join('', '<tr>', @value, '</tr>')); |
push(@result, join('', '<tr>', @value, '</tr>')); |
| 643 |
# XXXXX |
# XXXXX |
| 644 |
####### |
####### |
| 645 |
|
} elsif (/^\[INS\[/) { |
| 646 |
|
push(@result, "<ins>"); |
| 647 |
|
} elsif (/^\]INS\]/) { |
| 648 |
|
push(@result, "</ins>"); |
| 649 |
|
} elsif (/^\[DEL\[/) { |
| 650 |
|
push(@result, "<del>"); |
| 651 |
|
} elsif (/^\]DEL\]/) { |
| 652 |
|
push(@result, "</del>"); |
| 653 |
|
} elsif (/^\[PRE\[/) { |
| 654 |
|
push(@result, "<pre>"); |
| 655 |
|
} elsif (/^\]PRE\]/) { |
| 656 |
|
push(@result, "</pre>"); |
| 657 |
} else { |
} else { |
| 658 |
push(@result, &inline($_)); |
push(@result, &inline($_)); |
| 659 |
} |
} |
| 665 |
# This part is taken from Makio Tsukamoto's WalWiki. |
# This part is taken from Makio Tsukamoto's WalWiki. |
| 666 |
my (@tocsaved, @tocresult); |
my (@tocsaved, @tocresult); |
| 667 |
foreach (@toc) { |
foreach (@toc) { |
| 668 |
if (/^(-{1,3})(.*)/) { |
if (/^(-{1,6})(.*)$/) { |
| 669 |
&back_push('ul', length($1), \@tocsaved, \@tocresult); |
&back_push('ul', length($1), \@tocsaved, \@tocresult); |
| 670 |
push(@tocresult, '<li>' . $2 . '</li>'); |
push(@tocresult, '<li>' . $2 . '</li>'); |
| 671 |
} |
} |
| 699 |
$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|(\d\d\d\d-\d\d-\d\d \(\w\w\w\) \d\d:\d\d:\d\d)|<span class="date">$1</span>|g; # Date |
| 700 |
$line =~ s! |
$line =~ s! |
| 701 |
( |
( |
| 702 |
(?:<(?:mailto|http|https|ftp|urn):[\x21-\x7E]*)> |
(?:<(?:mailto|http|https|ftp|urn|news):[\x21-\x7E]*)> |
| 703 |
| |
| |
| 704 |
($bracket_name) # [[likethis]], [[#comment]], [[Friend:remotelink]] |
($bracket_name) # [[likethis]], [[#comment]], [[Friend:remotelink]] |
| 705 |
| |
| |
| 716 |
sub make_link { |
sub make_link { |
| 717 |
my $chunk = shift; |
my $chunk = shift; |
| 718 |
# Walrus add (3) start |
# Walrus add (3) start |
| 719 |
|
$chunk =~ s/^<(.*)>$/$1/; |
| 720 |
my $name = $chunk; |
my $name = $chunk; |
|
$name =~ s/^<(.*)>$/$1/; |
|
| 721 |
if ($chunk =~ /^\[\[([^ ]+?) ([^ ]+?)\]\]$/ and $form{mypage} ne $InterWikiName) { |
if ($chunk =~ /^\[\[([^ ]+?) ([^ ]+?)\]\]$/ and $form{mypage} ne $InterWikiName) { |
| 722 |
($name, $chunk) = ($1, $2); |
($name, $chunk) = ($1, $2); |
| 723 |
} elsif ($chunk =~ /^mailto:(.*)$/) { |
} elsif ($chunk =~ /^mailto:(.*)$/) { |
| 724 |
$name = $1; |
$name = $1; |
| 725 |
} |
} |
| 726 |
if ($use_autoimg and $name =~ /^(http|https|ftp|):.+\.(png|gif|jpe?g)/) { |
if ($use_autoimg and $name =~ /^(http|https|ftp):.+\.(png|gif|jpe?g)/) { |
| 727 |
$name = qq(<img src="$name">) ; |
$name = qq(<img src="$name">) ; |
| 728 |
} |
} |
| 729 |
$name = &unarmor_name($name); |
$name = &unarmor_name($name); |
| 730 |
# Walrus add (3) end |
# Walrus add (3) end |
| 731 |
if ($chunk =~ /^(http|https|ftp):/) { |
if ($chunk =~ /^(http|https|ftp|news):/) { |
| 732 |
# Walrus mod (3) start |
# Walrus mod (3) start |
| 733 |
# if ($use_autoimg and $chunk =~ /\.(gif|png|jpeg|jpg)$/) { |
# if ($use_autoimg and $chunk =~ /\.(gif|png|jpeg|jpg)$/) { |
| 734 |
# return qq(<a href="$chunk"><img src="$chunk"></a>); |
# return qq(<a href="$chunk"><img src="$chunk"></a>); |
| 735 |
# } else { |
# } else { |
| 736 |
# return qq(<a href="$chunk">$chunk</a>); |
# return qq(<a href="$chunk">$chunk</a>); |
| 737 |
# } |
# } |
| 738 |
return qq(<a href="$chunk">$name</a>); |
return qq(<<a href="$chunk">$name</a>>); |
| 739 |
# Walrus mod (3) end |
# Walrus mod (3) end |
| 740 |
} elsif ($chunk =~ m#^urn:[0-9A-Za-z_:;/.-]+#) { |
} elsif ($chunk =~ m#^urn:[0-9A-Za-z_:;/.-]+#) { |
| 741 |
return qq|<<a href="/uri-res/N2L?${name}">$name</a>>|; |
return qq|<<a href="/uri-res/N2L?${name}">$name</a>>|; |
| 758 |
# $remoteurl =~ s/\b(euc|sjis|ykwk|asis)\(\$1\)/&interwiki_convert($1, $localname)/e; # Walrus del (4) |
# $remoteurl =~ s/\b(euc|sjis|ykwk|asis)\(\$1\)/&interwiki_convert($1, $localname)/e; # Walrus del (4) |
| 759 |
$remoteurl =~ s/\b(euc|sjis|ykwk|asis|isbn)\(\$1\)/&interwiki_convert($1, $localname)/e; # Walrus add (4) |
$remoteurl =~ s/\b(euc|sjis|ykwk|asis|isbn)\(\$1\)/&interwiki_convert($1, $localname)/e; # Walrus add (4) |
| 760 |
# return qq(<a href="$remoteurl">$chunk</a>); # Walrus del (3) |
# return qq(<a href="$remoteurl">$chunk</a>); # Walrus del (3) |
| 761 |
return qq(<a href="$remoteurl">$name</a>); # Walrus add (3) |
return qq(<a href="$remoteurl">@{[&escape($name)]}</a>); # Walrus add (3) |
| 762 |
} else { |
} else { |
| 763 |
# return $chunk; # Walrus del (3) |
# return $chunk; # Walrus del (3) |
| 764 |
return $name; # Walrus add (3) |
return &escape($name); # Walrus add (3) |
| 765 |
} |
} |
| 766 |
} elsif ($database{$chunk}) { |
} elsif ($database{$chunk}) { |
| 767 |
my $subject = &escape(&get_subjectline($chunk, delimiter => '')); |
my $subject = &escape(&get_subjectline($chunk, delimiter => '')); |
| 768 |
# return qq(<a title="$subject" href="$url_cgi?$cookedchunk">$chunk</a>); # Walrus del (3) |
# return qq(<a title="$subject" href="$url_cgi?$cookedchunk">$chunk</a>); # Walrus del (3) |
| 769 |
return qq(<a title="$subject" href="$url_cgi?$cookedchunk">$name</a>); # Walrus add (3) |
return qq(<a title="$subject" href="$url_cgi?$cookedchunk" class="wiki">@{[&escape($name)]}</a>); # Walrus add (3) |
| 770 |
} elsif ($page_command{$chunk}) { |
} elsif ($page_command{$chunk}) { |
| 771 |
# return qq(<a title="$chunk" href="$url_cgi?$cookedchunk">$chunk</a>); # Walrus del (3) |
# return qq(<a title="$chunk" href="$url_cgi?$cookedchunk">$chunk</a>); # Walrus del (3) |
| 772 |
return qq(<a title="$chunk" href="$url_cgi?$cookedchunk">$name</a>); # Walrus add (3) |
return qq(<a title="$chunk" href="$url_cgi?$cookedchunk" class="wiki">@{[&escape($name)]}</a>); # Walrus add (3) |
| 773 |
} else { |
} else { |
| 774 |
# return qq($chunk<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit&mypage=$cookedchunk">$editchar</a>); # Walrus del (3) |
return qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedchunk" class="wiki">@{[&escape($name)]}<span class="mark">$editchar</span></a>); |
|
return qq($name<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit&mypage=$cookedchunk">$editchar</a>); # Walrus add (3) |
|
| 775 |
} |
} |
| 776 |
} |
} |
| 777 |
} |
} |
| 778 |
|
|
|
# Walrus add (6) start |
|
|
sub is_ignore_html { |
|
|
my ($pagename) = @_; |
|
|
foreach (@ignore_html_page) { |
|
|
return 1 if ($pagename eq $_); |
|
|
} |
|
|
return 0; |
|
|
} |
|
|
# Walrus add (6) end |
|
|
|
|
|
# Walrus add (6) start |
|
|
sub html_to_ignored_html { |
|
|
my $str = shift(@_); |
|
|
my $text_regex = q{[^<]*}; |
|
|
my $tag_regex_ = q{[^"'<>]*(?:"[^"]*"[^"'<>]*|'[^']*'[^"'<>]*)*(?:>|(?=<)|$(?!\n))}; #'}}}} |
|
|
my $comment_tag_regex = '<!(?:--[^-]*-(?:[^-]+-)*?-(?:[^>-]*(?:-[^>-]+)*?)??)*(?:>|$(?!\n)|--.*$)'; |
|
|
my $tag_regex = qq{$comment_tag_regex|<$tag_regex_}; |
|
|
my $ignored = join('|', @ignore_html_tags); |
|
|
my $result = ''; |
|
|
while ($str =~ /($text_regex)($tag_regex)?/gso) { |
|
|
last if $1 eq '' and $2 eq ''; |
|
|
$result .= $1; |
|
|
my $tag_tmp = $2; |
|
|
$result .= ($tag_tmp =~ /^<\/?($ignored)(?![0-9A-Za-z])/i) ? $tag_tmp : &escape($tag_tmp); |
|
|
if ($tag_tmp =~ /^<(XMP|PLAINTEXT|SCRIPT)(?![0-9A-Za-z])/i) { |
|
|
$str =~ /(.*?)(?:<\/$1(?![0-9A-Za-z])$tag_regex_|$)/gsi; |
|
|
$result .= &escape($1); |
|
|
} |
|
|
} |
|
|
return $result; |
|
|
} |
|
|
# Walrus add (6) end |
|
|
|
|
| 779 |
sub print_message { |
sub print_message { |
| 780 |
my ($msg) = @_; |
my ($msg) = @_; |
| 781 |
print qq(<p><strong>$msg</strong></p>); |
print qq(<p><strong>$msg</strong></p>); |
| 782 |
} |
} |
| 783 |
|
|
| 784 |
|
sub get_message { |
| 785 |
|
my ($msg) = @_; |
| 786 |
|
qq(<p><strong>$msg</strong></p>); |
| 787 |
|
} |
| 788 |
|
|
| 789 |
sub init_form { |
sub init_form { |
| 790 |
if (param()) { |
if (param()) { |
| 791 |
foreach my $var (param()) { |
foreach my $var (param()) { |
| 861 |
|
|
| 862 |
# Get the subject of the page. |
# Get the subject of the page. |
| 863 |
my $subject = $database{$page}; |
my $subject = $database{$page}; |
| 864 |
|
$subject =~ s#^SuikaWiki/0.9[^\x0D\x0A]*[\x0D\x0A]+##s; |
| 865 |
$subject =~ s/\r?\n.*//s; |
$subject =~ s/\r?\n.*//s; |
| 866 |
return "$delim$subject"; |
return "$delim$subject"; |
| 867 |
} |
} |
| 969 |
} |
} |
| 970 |
$mymsg = &escape($form{mymsg}); |
$mymsg = &escape($form{mymsg}); |
| 971 |
} else { |
} else { |
| 972 |
$mymsg = &escape($mymsg); |
$mymsg = &escape($mymsg || $database{NewPageTemplate}); |
| 973 |
} |
} |
| 974 |
|
|
| 975 |
my $edit = $mode{admin} ? 'adminedit' : 'edit'; |
my $edit = $mode{admin} ? 'adminedit' : 'edit'; |
| 976 |
|
my $escapedmypage = &escape($form{mypage}); |
| 977 |
|
my $escapedmypassword = &escape($form{mypassword}); |
| 978 |
|
|
| 979 |
print <<"EOD"; |
print <<"EOD"; |
| 980 |
<form action="$url_cgi" method="post"> |
<form action="$url_cgi" method="post"> |
| 981 |
@{[ $mode{admin} ? qq($resource{frozenpassword} <input type="password" name="mypassword" value="$form{mypassword}" size="10"><br>) : "" ]} |
@{[ $mode{admin} ? qq($resource{frozenpassword} <input type="password" name="mypassword" value="$escapedmypassword" size="10"><br>) : "" ]} |
| 982 |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
| 983 |
<input type="hidden" name="mypage" value="$form{mypage}"> |
<input type="hidden" name="mypage" value="$escapedmypage"> |
| 984 |
<textarea cols="$cols" rows="$rows" name="mymsg" wrap="off">$mymsg</textarea><br> |
<textarea cols="$cols" rows="$rows" name="mymsg" tabindex="1">$mymsg</textarea><br> |
| 985 |
@{[ |
@{[ |
| 986 |
$mode{admin} ? |
$mode{admin} ? |
| 987 |
qq( |
qq( |
| 994 |
qq( |
qq( |
| 995 |
<input type="checkbox" name="mytouch" value="on" checked="checked">$resource{touch}<br> |
<input type="checkbox" name="mytouch" value="on" checked="checked">$resource{touch}<br> |
| 996 |
<input type="submit" name="mypreview_$edit" value="$resource{previewbutton}"> |
<input type="submit" name="mypreview_$edit" value="$resource{previewbutton}"> |
| 997 |
<input type="submit" name="mypreview_write" value="$resource{savebutton}"><br> |
<input type="submit" name="mypreview_write" value="$resource{savebutton}" accesskey="S"><kbd>S</kbd><br> |
| 998 |
) |
) |
| 999 |
]} |
]} |
| 1000 |
</form> |
</form> |
| 1043 |
# not_wiki_name -> [[not_wiki_name]] |
# not_wiki_name -> [[not_wiki_name]] |
| 1044 |
sub armor_name { |
sub armor_name { |
| 1045 |
my ($name) = @_; |
my ($name) = @_; |
| 1046 |
if ($name =~ /^$wiki_name$/) { |
#if ($name =~ /^$wiki_name$/) { |
| 1047 |
return $name; |
# return $name; |
| 1048 |
} else { |
#} else { |
| 1049 |
return "[[$name]]"; |
return "[[$name]]"; |
| 1050 |
} |
#} |
| 1051 |
} |
} |
| 1052 |
|
|
| 1053 |
# unarmor_name: |
# unarmor_name: |
| 1220 |
sub do_comment { |
sub do_comment { |
| 1221 |
my ($content) = $database{$form{mypage}}; |
my ($content) = $database{$form{mypage}}; |
| 1222 |
my $datestr = &get_now; |
my $datestr = &get_now; |
| 1223 |
my $namestr = $form{myname} ? " ''[[$form{myname}]]'' : " : " "; |
my $namestr = " ''[[@{[$form{myname}||$DEFAULT_embed_comment_name]}]]'' : "; |
| 1224 |
if ($content =~ s/(\Q$embed_comment\E)/- $datestr$namestr$form{mymsg}\n$1/) { |
#if ($content =~ s/(\Q$embed_comment\E)/- $datestr$namestr$form{mymsg}\n$1/) { |
| 1225 |
; |
# ; |
| 1226 |
} else { |
#} else { |
| 1227 |
$content =~ s/(\Q$embed_rcomment\E)/$1\n- $datestr$namestr$form{mymsg}/; |
# $content =~ s/(\Q$embed_rcomment\E)/$1\n- $datestr$namestr$form{mymsg}/; |
| 1228 |
|
#} |
| 1229 |
|
my $i = 0; my $o = 0; |
| 1230 |
|
$content =~ s{(\Q$embed_comment\E|\Q$embed_rcomment\E)}{ |
| 1231 |
|
my $embed = $1; |
| 1232 |
|
if ($i == $form{comment_index}) { |
| 1233 |
|
if ($embed eq $embed_comment) { |
| 1234 |
|
$embed = "- $datestr$namestr$form{mymsg}\n$embed"; $o = 1; |
| 1235 |
|
} else { |
| 1236 |
|
$embed .= "\n- $datestr$namestr$form{mymsg}"; $o = 1; |
| 1237 |
|
} |
| 1238 |
|
} |
| 1239 |
|
$i++; $embed; |
| 1240 |
|
}ge; |
| 1241 |
|
unless ($o) { |
| 1242 |
|
$content .= "- $datestr$namestr$form{mymsg}\n"; |
| 1243 |
} |
} |
| 1244 |
if ($form{mymsg}) { |
if ($form{mymsg}) { |
| 1245 |
$form{mymsg} = $content; |
$form{mymsg} = $content; |
| 1251 |
} |
} |
| 1252 |
} |
} |
| 1253 |
|
|
| 1254 |
|
my $_O_COMMENT_INDEX = 0; |
| 1255 |
sub embedded_to_html { |
sub embedded_to_html { |
| 1256 |
my ($embedded) = @_; |
my ($embedded) = @_; |
| 1257 |
if ($embedded eq $embed_comment or $embedded eq $embed_rcomment) { |
if ($embedded eq $embed_comment or $embedded eq $embed_rcomment) { |
| 1262 |
<input type="hidden" name="mypage" value="$form{mypage}"> |
<input type="hidden" name="mypage" value="$form{mypage}"> |
| 1263 |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
| 1264 |
<input type="hidden" name="mytouch" value="on"> |
<input type="hidden" name="mytouch" value="on"> |
| 1265 |
$resource{yourname} |
<input type="hidden" name="comment_index" value="@{[$_O_COMMENT_INDEX++]}"> |
| 1266 |
|
$embed_comment_Name_Prompt |
| 1267 |
<input type="text" name="myname" value="" size="10"> |
<input type="text" name="myname" value="" size="10"> |
| 1268 |
<input type="text" name="mymsg" value="" size="40"> |
<input type="text" name="mymsg" value="" size="60"> |
| 1269 |
<input type="submit" value="$resource{commentbutton}"> |
<input type="submit" value="$resource{commentbutton}"> |
| 1270 |
</form> |
</form> |
| 1271 |
EOD |
EOD |
| 1272 |
|
} elsif ($embedded =~ /$embed_command{searched}/) { |
| 1273 |
|
return get_search_result ($1); |
| 1274 |
# Walrus add (5) start |
# Walrus add (5) start |
| 1275 |
} elsif ($embedded =~ /$embed_interwiki/ and my $remoteurl = $interwiki{$2}) { |
} elsif ($embedded =~ /$embed_interwiki/ and my $remoteurl = $interwiki{$2}) { |
| 1276 |
$_ = &make_interwiki_box($1, $2); |
$_ = &make_interwiki_box($1, $2); |