117 |
my $bracket_name = '\[\[(\S+?)\]\]'; |
my $bracket_name = '\[\[(\S+?)\]\]'; |
118 |
my $embedded_name = '\[\[(#\S+?)\]\]'; |
my $embedded_name = '\[\[(#\S+?)\]\]'; |
119 |
my $interwiki_definition = '\[\[(\S+?)\ (\S+?)\]\]'; |
my $interwiki_definition = '\[\[(\S+?)\ (\S+?)\]\]'; |
120 |
my $interwiki_name = '([^:]+):([^:].*)'; |
my $interwiki_name = '([^:]+):i:([^:].*)'; |
121 |
############################## |
############################## |
122 |
my $embed_comment = '[[#comment]]'; |
my $embed_comment = '[[#comment]]'; |
123 |
my $embed_rcomment = '[[#rcomment]]'; |
my $embed_rcomment = '[[#rcomment]]'; |
124 |
my $embed_interwiki = '^\[\[#(box|text|password):(\S+)\]\]$'; # Walrus add (5) |
my $embed_interwiki = '^\[\[#(box|text|password):(\S+)\]\]$'; # Walrus add (5) |
125 |
|
my %embed_command = ( |
126 |
|
searched => '^\[\[#searched:([^\]]+)\]\]$', |
127 |
|
); |
128 |
############################## |
############################## |
129 |
my $info_LastModified = 'LastModified'; |
my $info_LastModified = 'LastModified'; |
130 |
my $info_IsFrozen = 'IsFrozen'; |
my $info_IsFrozen = 'IsFrozen'; |
203 |
sub do_read { |
sub do_read { |
204 |
&print_header($form{mypage}); |
&print_header($form{mypage}); |
205 |
&print_content($database{$form{mypage}}); |
&print_content($database{$form{mypage}}); |
206 |
|
my ($r, $c) = get_search_result ($form{mypage}); |
207 |
|
if ($c) { |
208 |
|
print q{<h2>See also</h2>}; |
209 |
|
print $r; |
210 |
|
} |
211 |
&print_footer($form{mypage}); |
&print_footer($form{mypage}); |
212 |
} |
} |
213 |
|
|
316 |
&update_recent_changes; |
&update_recent_changes; |
317 |
} |
} |
318 |
&set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen}); |
&set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen}); |
319 |
&print_header($CompletedSuccessfully); |
&print_header($CompletedSuccessfully, -goto => $url_cgi.'?'.&encode($form{mypage})); |
320 |
&print_message($resource{saved}); |
&print_message($resource{saved}); |
321 |
&print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}"); |
&print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}"); |
322 |
&print_footer($CompletedSuccessfully); |
&print_footer($CompletedSuccessfully); |
340 |
} |
} |
341 |
|
|
342 |
sub do_search { |
sub do_search { |
343 |
my $word = &escape($form{mymsg}); |
my $word = $form{mymsg}; |
344 |
&print_header($SearchPage); |
&print_header($SearchPage); |
345 |
&print_searchform($word); |
&print_searchform(&escape($word)); |
346 |
my $counter = 0; |
print get_search_result ($word, -output_not_found => 1); |
347 |
foreach my $page (sort keys %database) { |
print "foo"; |
|
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>|; |
|
|
} |
|
348 |
&print_footer($SearchPage); |
&print_footer($SearchPage); |
349 |
} |
} |
350 |
|
|
351 |
|
sub get_search_result ($;%) { |
352 |
|
my $word = shift; |
353 |
|
my %option = @_; |
354 |
|
my $counter = 0; |
355 |
|
my $r = ''; |
356 |
|
foreach my $page (sort keys %database) { |
357 |
|
next if $page eq $RecentChanges; |
358 |
|
if ( index ($database{$page}, $word) > 0 |
359 |
|
|| index ($page, $word) > 0 |
360 |
|
|| index ($word, $page) > 0 |
361 |
|
) { |
362 |
|
$r .= qq(<li><a href ="$url_cgi?@{[&escape(&encode($page))]}">@{[&escape($page)]}</a>@{[&escape(&get_subjectline($page))]}</li>); |
363 |
|
$counter++; |
364 |
|
} |
365 |
|
} |
366 |
|
$r = qq|<ul>$r</ul>| if $r; |
367 |
|
get_message ($resource{notfound}) |
368 |
|
if $counter == 0 && $option{-output_not_found}; |
369 |
|
wantarray? ($r, $counter): $r; |
370 |
|
} |
371 |
|
|
372 |
sub do_create { |
sub do_create { |
373 |
&print_header($CreatePage); |
&print_header($CreatePage); |
374 |
print <<"EOD"; |
print <<"EOD"; |
401 |
} |
} |
402 |
|
|
403 |
sub print_header { |
sub print_header { |
404 |
my ($page) = @_; |
my ($page,%option) = @_; |
405 |
my $bodyclass = "normal"; |
my $bodyclass = "normal"; |
|
my $editable = 0; |
|
|
my $admineditable = 0; |
|
406 |
if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) { |
if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) { |
|
$editable = 0; |
|
|
$admineditable = 1; |
|
407 |
$bodyclass = "frozen"; |
$bodyclass = "frozen"; |
408 |
} elsif (&is_editable($page) and $form{mycmd} =~ /^(read|write)$/) { |
} |
409 |
$admineditable = 1; |
if ($option{-goto}) { |
410 |
$editable = 1; |
print qq{Refresh: 0; url="$option{-goto}"\n}; |
|
} else { |
|
|
$editable = 0; |
|
411 |
} |
} |
412 |
my $cookedpage = &encode($page); |
my $cookedpage = &encode($page); |
413 |
print <<"EOD"; |
print <<"EOD"; |
420 |
"http://www.w3.org/TR/html4/loose.dtd"> |
"http://www.w3.org/TR/html4/loose.dtd"> |
421 |
<html lang="$lang"> |
<html lang="$lang"> |
422 |
<head> |
<head> |
423 |
<title>$page @{[&escape(&get_subjectline($page))]}</title> |
<title>@{[&escape($page.' '.&get_subjectline($page))]}</title> |
424 |
<link rel="index" href="$url_cgi?$IndexPage"> |
<link rel="index" href="$url_cgi?$IndexPage"> |
425 |
<link rev="made" href="mailto:$modifier_mail"> |
<link rev="made" href="mailto:$modifier_mail"> |
426 |
<link rel="stylesheet" type="text/css" href="$url_stylesheet"> |
<link rel="stylesheet" type="text/css" href="$url_stylesheet"> |
427 |
</head> |
</head> |
428 |
<body class="$bodyclass"> |
<body class="$bodyclass"> |
429 |
|
EOD |
430 |
|
&print_navigate_links ($page); |
431 |
|
print <<EOD; |
432 |
|
<h1 class="header"><a |
433 |
|
title="$resource{searchthispage}" |
434 |
|
href="$url_cgi?mycmd=search;mymsg=$cookedpage">@{[&escape($page)]}</a>@{[&escape(&get_subjectline($page))]}</h1> |
435 |
|
EOD |
436 |
|
} |
437 |
|
|
438 |
|
sub print_navigate_links (@) { |
439 |
|
my ($page) = @_; |
440 |
|
my $editable = 0; |
441 |
|
my $admineditable = 0; |
442 |
|
if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) { |
443 |
|
$editable = 0; |
444 |
|
$admineditable = 1; |
445 |
|
} elsif (&is_editable($page) and $form{mycmd} =~ /^(read|write)$/) { |
446 |
|
$admineditable = 1; |
447 |
|
$editable = 1; |
448 |
|
} else { |
449 |
|
$editable = 0; |
450 |
|
} |
451 |
|
my $cookedpage = &encode($page); |
452 |
|
print <<EOH; |
453 |
<div class="tools"> |
<div class="tools"> |
454 |
@{[ $admineditable |
@{[ $admineditable |
455 |
? 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> | ) |
456 |
: qq() |
: qq() |
457 |
]} |
]} |
458 |
@{[ $editable |
@{[ $editable |
459 |
? 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> | ) |
460 |
: qq() |
: qq() |
461 |
]} |
]} |
462 |
@{[ $admineditable |
@{[ $admineditable |
470 |
<a href="$url_cgi?$SearchPage">$resource{searchbutton}</a> | |
<a href="$url_cgi?$SearchPage">$resource{searchbutton}</a> | |
471 |
<a href="$url_cgi?$RecentChanges">$resource{recentchangesbutton}</a> |
<a href="$url_cgi?$RecentChanges">$resource{recentchangesbutton}</a> |
472 |
</div> |
</div> |
473 |
<h1 class="header"><a |
EOH |
|
title="$resource{searchthispage}" |
|
|
href="$url_cgi?mycmd=search;mymsg=$cookedpage">$page</a>@{[&escape(&get_subjectline($page))]}</h1> |
|
|
EOD |
|
474 |
} |
} |
475 |
|
|
476 |
sub print_footer { |
sub print_footer { |
477 |
my ($page) = @_; |
my ($page) = @_; |
478 |
$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) |
479 |
# Walrus mod (1) start |
# Walrus mod (1) start |
480 |
my $cvslog = '$Revision$ $Date$'; |
my $cvslog = '$Revision$ $Date$'; |
481 |
print <<"EOD"; |
print_navigate_links ($page); |
482 |
|
print <<"EOD"; |
483 |
<div class="footer"> |
<div class="footer"> |
484 |
<p> |
<p> |
485 |
<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 /> |
517 |
sub escape { |
sub escape { |
518 |
my $s = shift; |
my $s = shift; |
519 |
$s =~ s|\r\n|\n|g; |
$s =~ s|\r\n|\n|g; |
520 |
$s =~ s|\&|&|g; |
$s =~ s|&|&|g; |
521 |
$s =~ s|<|<|g; |
$s =~ s|<|<|g; |
522 |
$s =~ s|>|>|g; |
$s =~ s|>|>|g; |
523 |
$s =~ s|"|"|g; |
$s =~ s|"|"|g; |
527 |
sub unescape { |
sub unescape { |
528 |
my $s = shift; |
my $s = shift; |
529 |
# $s =~ s|\n|\r\n|g; |
# $s =~ s|\n|\r\n|g; |
530 |
$s =~ s|\&|\&|g; |
$s =~ s|<|<|g; |
531 |
$s =~ s|\<|\<|g; |
$s =~ s|>|>|g; |
532 |
$s =~ s|\>|\>|g; |
$s =~ s|"|"|g; |
533 |
$s =~ s|\"|\"|g; |
$s =~ s|&|&|g; |
534 |
return $s; |
return $s; |
535 |
} |
} |
536 |
|
|
785 |
print qq(<p><strong>$msg</strong></p>); |
print qq(<p><strong>$msg</strong></p>); |
786 |
} |
} |
787 |
|
|
788 |
|
sub get_message { |
789 |
|
my ($msg) = @_; |
790 |
|
qq(<p><strong>$msg</strong></p>); |
791 |
|
} |
792 |
|
|
793 |
sub init_form { |
sub init_form { |
794 |
if (param()) { |
if (param()) { |
795 |
foreach my $var (param()) { |
foreach my $var (param()) { |
981 |
<form action="$url_cgi" method="post"> |
<form action="$url_cgi" method="post"> |
982 |
@{[ $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="$form{mypassword}" size="10"><br>) : "" ]} |
983 |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
984 |
<input type="hidden" name="mypage" value="$form{mypage}"> |
<input type="hidden" name="mypage" value="@{[&escape($form{mypage})]}"> |
985 |
<textarea cols="$cols" rows="$rows" name="mymsg" wrap="off">$mymsg</textarea><br> |
<textarea cols="$cols" rows="$rows" name="mymsg" wrap="off" tabindex="1">$mymsg</textarea><br> |
986 |
@{[ |
@{[ |
987 |
$mode{admin} ? |
$mode{admin} ? |
988 |
qq( |
qq( |
995 |
qq( |
qq( |
996 |
<input type="checkbox" name="mytouch" value="on" checked="checked">$resource{touch}<br> |
<input type="checkbox" name="mytouch" value="on" checked="checked">$resource{touch}<br> |
997 |
<input type="submit" name="mypreview_$edit" value="$resource{previewbutton}"> |
<input type="submit" name="mypreview_$edit" value="$resource{previewbutton}"> |
998 |
<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> |
999 |
) |
) |
1000 |
]} |
]} |
1001 |
</form> |
</form> |
1253 |
<input type="submit" value="$resource{commentbutton}"> |
<input type="submit" value="$resource{commentbutton}"> |
1254 |
</form> |
</form> |
1255 |
EOD |
EOD |
1256 |
|
} elsif ($embedded =~ /$embed_command{searched}/) { |
1257 |
|
return get_search_result ($1); |
1258 |
# Walrus add (5) start |
# Walrus add (5) start |
1259 |
} elsif ($embedded =~ /$embed_interwiki/ and my $remoteurl = $interwiki{$2}) { |
} elsif ($embedded =~ /$embed_interwiki/ and my $remoteurl = $interwiki{$2}) { |
1260 |
$_ = &make_interwiki_box($1, $2); |
$_ = &make_interwiki_box($1, $2); |