70 |
# my $modifier_sendmail = '/usr/sbin/sendmail -t -n'; # Your sendmail. |
# my $modifier_sendmail = '/usr/sbin/sendmail -t -n'; # Your sendmail. |
71 |
my $modifier_sendmail = ''; # If you don't need mail notification. |
my $modifier_sendmail = ''; # If you don't need mail notification. |
72 |
my $modifier_dir_data = './wikidata'; # Your data directory. |
my $modifier_dir_data = './wikidata'; # Your data directory. |
73 |
my $modifier_rss_title = "WalWiki $walversion"; |
my $modifier_rss_title = "SuikaWiki $walversion"; |
74 |
my $modifier_rss_link = 'http://suika.fam.cx/~wakaba/-temp/wiki2/wiki'; # Blank is not allowed. |
my $modifier_rss_link = 'http://suika.fam.cx/~wakaba/-temp/wiki2/wiki'; # Blank is not allowed. |
75 |
my $modifier_rss_description = 'This is WalWiki, yet another Wiki clone based on YukiWiki'; |
my $modifier_rss_description = 'This is SuikaWiki'; |
76 |
############################## |
############################## |
77 |
# |
# |
78 |
# You MAY modify following variables. |
# You MAY modify following variables. |
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 = '([^:]+):i:([^:].*)'; |
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 = ( |
my %embed_command = ( |
129 |
searched => '^\[\[#searched:([^\]]+)\]\]$', |
searched => '^\[\[#searched:([^\]]+)\]\]$', |
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}); |
my $content = $database{$form{mypage}}; |
209 |
&print_content($database{$form{mypage}}); |
my $lm = &get_info($form{mypage}, $info_LastModified); |
210 |
my ($r, $c) = get_search_result ($form{mypage}); |
&print_header($form{mypage}, -last_modified => $lm); |
211 |
|
wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); |
212 |
|
my $cf = 'SuikaWiki/0.9'; |
213 |
|
## Should be support at least: |
214 |
|
## - 'SuikaWiki/0.9' CRLF |
215 |
|
## - 'H2H/' ("0.9" / "1.0" / "1.1") CRLF |
216 |
|
## - "/*" WSP* 'W3C-CSS/' ("1.0" / "2.0") "*/" CRLF |
217 |
|
$cf = $1 if $content =~ s#^(?:/\*\s*|\#\?)?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:[^0-9.][^\x0D\x0A]*)?)[\x0D\x0A]+##s; |
218 |
|
if ($cf =~ m#^SuikaWiki/0.9(?:$|\s)#) { |
219 |
|
&print_content($content, content_format => $cf, last_modified => $lm); |
220 |
|
print &text_to_html (q([[#comment]])); |
221 |
|
} else { |
222 |
|
print "<pre>@{[&escape($content)]}</pre>"; |
223 |
|
} |
224 |
|
my ($r, $c) = get_search_result ($form{mypage}); |
225 |
if ($c) { |
if ($c) { |
226 |
print q{<h2>See also</h2>}; |
print q{<h2 id="SEE-ALSO">See also</h2>}; |
227 |
print $r; |
print $r; |
228 |
} |
} |
229 |
&print_footer($form{mypage}); |
my $r = wiki::referer::list_html ($form{mypage}); |
230 |
|
if ($r) { |
231 |
|
print qq(<div id="wikipage-referer"><h2>参照元</h2>\n$r</div>\n); |
232 |
|
} |
233 |
|
&print_footer($form{mypage}, $lm); |
234 |
|
} |
235 |
|
|
236 |
|
sub do_output_css { |
237 |
|
my $content = $database{$form{mypage}}; |
238 |
|
if ($content =~ m#^\s*/\*\s*W3C-CSS#) { |
239 |
|
print "Content-Type: text/css; charset=$charset\n"; |
240 |
|
print "\n"; |
241 |
|
print $content; |
242 |
|
} else { |
243 |
|
print "Status: 406 Unsupported Media Type\n"; |
244 |
|
&print_header('WikiPageIsNotCSS'); |
245 |
|
&print_content($database{WikiPageIsNotCSS}); |
246 |
|
&print_footer('WikiPageIsNotCSS'); |
247 |
|
} |
248 |
} |
} |
249 |
|
|
250 |
sub do_edit { |
sub do_edit { |
352 |
&update_recent_changes; |
&update_recent_changes; |
353 |
} |
} |
354 |
&set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen}); |
&set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen}); |
355 |
&print_header($CompletedSuccessfully, -goto => $url_cgi.'?'.&encode($form{mypage})); |
&print_header($CompletedSuccessfully, -goto => $url_cgi.'?'.&encode($form{mypage}).($form{comment_index}?"#x-comment-$form{comment_index}":'')); |
356 |
&print_message($resource{saved}); |
&print_message($resource{saved}); |
357 |
&print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}"); |
&print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}"); |
358 |
&print_footer($CompletedSuccessfully); |
&print_footer($CompletedSuccessfully); |
394 |
|| index ($page, $word) > 0 |
|| index ($page, $word) > 0 |
395 |
|| index ($word, $page) > 0 |
|| index ($word, $page) > 0 |
396 |
) { |
) { |
397 |
$r .= qq(<li><a href ="$url_cgi?@{[&encode($page)]}">@{[&escape($page)]}</a>@{[&escape(&get_subjectline($page))]}</li>); |
$r .= qq(<li><a href ="$url_cgi?@{[&encode($page)]}" class="wiki">@{[&escape($page)]}</a> <span class="wikipage-summary">@{[&escape(&get_subjectline($page))]}</span></li>); |
398 |
$counter++; |
$counter++; |
399 |
} |
} |
400 |
} |
} |
435 |
exit(0); |
exit(0); |
436 |
} |
} |
437 |
|
|
438 |
sub print_header { |
sub print_header ($;%) { |
439 |
my ($page,%option) = @_; |
my ($page, %option) = @_; |
440 |
my $bodyclass = "normal"; |
my $bodyclass = "normal"; |
441 |
if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) { |
if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) { |
442 |
$bodyclass = "frozen"; |
$bodyclass = "frozen"; |
443 |
} |
} |
444 |
if ($option{-goto}) { |
print qq{Refresh: 0; url="$option{-goto}"\n} if $option{-goto}; |
445 |
print qq{Refresh: 0; url="$option{-goto}"\n}; |
print qq{Last-Modified: $option{-last_modified}\n} if $option{-last_modified}; |
|
} |
|
446 |
my $cookedpage = &encode($page); |
my $cookedpage = &encode($page); |
447 |
my $escapedpage = &escape($page); |
my $escapedpage = &escape($page); |
448 |
print <<"EOD"; |
print <<"EOD"; |
457 |
<head> |
<head> |
458 |
<title>$escapedpage @{[&escape(&get_subjectline($page))]}</title> |
<title>$escapedpage @{[&escape(&get_subjectline($page))]}</title> |
459 |
<link rel="index" href="$url_cgi?$IndexPage"> |
<link rel="index" href="$url_cgi?$IndexPage"> |
460 |
|
<link rel="copyright" href="$url_cgi?$NAME_OF_WikiPageLicense"> |
461 |
<link rev="made" href="mailto:@{[&escape($modifier_mail)]}"> |
<link rev="made" href="mailto:@{[&escape($modifier_mail)]}"> |
462 |
<link rel="stylesheet" type="text/css" href="@{[&escape($url_stylesheet)]}"> |
<link rel="stylesheet" type="text/css" href="@{[&escape($url_stylesheet)]}"> |
463 |
</head> |
</head> |
465 |
EOD |
EOD |
466 |
&print_navigate_links ($page); |
&print_navigate_links ($page); |
467 |
print <<EOD; |
print <<EOD; |
468 |
<h1 class="header"><a |
<h1 class="header">@{[&escape($page)]} |
469 |
title="$resource{searchthispage}" |
<span class="wikipage-summary">@{[&escape(&get_subjectline($page))]}</span></h1> |
|
href="$url_cgi?mycmd=search;mymsg=$cookedpage">@{[&escape($page)]}</a>@{[&escape(&get_subjectline($page))]}</h1> |
|
470 |
EOD |
EOD |
471 |
} |
} |
472 |
|
|
509 |
} |
} |
510 |
|
|
511 |
sub print_footer { |
sub print_footer { |
512 |
my ($page) = @_; |
my ($page, $lm) = @_; |
513 |
$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) |
514 |
# Walrus mod (1) start |
# Walrus mod (1) start |
515 |
my $cvslog = '$Revision$ $Date$'; |
my $cvslog = '$Revision$ $Date$'; |
516 |
print_navigate_links ($page); |
print_navigate_links ($page); |
517 |
print <<"EOD"; |
print <<"EOD"; |
518 |
|
@{[ $lm ? qq(<div id="wikipage-last-modified">Last modified: $lm</div>) : '' ]} |
519 |
<div class="footer"> |
<div class="footer"> |
520 |
<p> |
<p> |
521 |
<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 /> |
570 |
return $s; |
return $s; |
571 |
} |
} |
572 |
|
|
573 |
sub print_content { |
sub print_content ($;$) { |
574 |
my ($rawcontent) = @_; |
my ($rawcontent, %option) = @_; |
575 |
print &text_to_html($rawcontent, toc=>1); |
print &text_to_html($rawcontent, toc=>1); |
576 |
} |
} |
577 |
|
|
585 |
push(@result, "<p>"); |
push(@result, "<p>"); |
586 |
foreach (@txt) { |
foreach (@txt) { |
587 |
chomp; |
chomp; |
588 |
if (/^\*\*\*\*\*(.*)/) { |
if (/^\*\*\*\*\*([^\x0D\x0A]*)/) { |
589 |
push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n)); |
push(@toc, qq(----- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
590 |
push(@result, splice(@saved), qq(<h6 id="i$tocnum">) . &inline($1) . '</h6>'); |
push(@result, splice(@saved), qq(<h6 id="i$tocnum">) . &inline($1) . '</h6>'); |
591 |
$tocnum++; |
$tocnum++; |
592 |
} elsif (/^\*\*\*\*(.*)/) { |
} elsif (/^\*\*\*\*([^\x0D\x0A]*)/) { |
593 |
push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n)); |
push(@toc, qq(---- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
594 |
push(@result, splice(@saved), qq(<h5 id="i$tocnum">) . &inline($1) . '</h5>'); |
push(@result, splice(@saved), qq(<h5 id="i$tocnum">) . &inline($1) . '</h5>'); |
595 |
$tocnum++; |
$tocnum++; |
596 |
} elsif (/^\*\*\*(.*)/) { |
} elsif (/^\*\*\*([^\x0D\x0A]*)/) { |
597 |
push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n)); |
push(@toc, qq(--- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
598 |
push(@result, splice(@saved), qq(<h4 id="i$tocnum">) . &inline($1) . '</h4>'); |
push(@result, splice(@saved), qq(<h4 id="i$tocnum">) . &inline($1) . '</h4>'); |
599 |
$tocnum++; |
$tocnum++; |
600 |
} elsif (/^\*\*(.*)/) { |
} elsif (/^\*\*([^\x0D\x0A]*)/) { |
601 |
# if (/^\*\*(.*)/) { |
# if (/^\*\*(.*)/) { |
602 |
# Walrus mod (6) end |
# Walrus mod (6) end |
603 |
push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n)); |
push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
604 |
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>'); |
605 |
$tocnum++; |
$tocnum++; |
606 |
} elsif (/^\*(.*)/) { |
} elsif (/^\*([^\x0D\x0A]*)/) { |
607 |
push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)]}</a>\n)); |
push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
608 |
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>'); |
609 |
$tocnum++; |
$tocnum++; |
610 |
#} elsif (/^----/) { |
} elsif (/^(={1,6})(.*)/) { |
|
# push(@result, splice(@saved), '<hr>'); |
|
|
} elsif (/^(={1,5})(.*)/) { |
|
611 |
&back_push('ol', length($1), \@saved, \@result); |
&back_push('ol', length($1), \@saved, \@result); |
612 |
push(@result, '<li>' . &inline($2) . '</li>'); |
push(@result, '<li>' . &inline($2) . '</li>'); |
613 |
} elsif (/^(-{1,5})(.*)/) { |
} elsif (/^(-{1,6})(.*)/) { |
614 |
&back_push('ul', length($1), \@saved, \@result); |
&back_push('ul', length($1), \@saved, \@result); |
615 |
push(@result, '<li>' . &inline($2) . '</li>'); |
push(@result, '<li>' . &inline($2) . '</li>'); |
616 |
} elsif (/^:([^:]+):(.*)/) { |
} elsif (/^:([^:]+):(.*)/) { |
626 |
} elsif (/^(\s+.*)$/) { |
} elsif (/^(\s+.*)$/) { |
627 |
&back_push('pre', 1, \@saved, \@result); |
&back_push('pre', 1, \@saved, \@result); |
628 |
#push(@result, &escape($1)); # Not &inline, but &escape |
#push(@result, &escape($1)); # Not &inline, but &escape |
629 |
push(@result, &inline($1)); # Not &inline, but &escape |
push(@result, &inline($1)); |
630 |
# } elsif (/^\,(.*)$/) { # Walrus del (BF) |
# } elsif (/^\,(.*)$/) { # Walrus del (BF) |
631 |
} elsif (/^\,(.*?)[\x0D\x0A]*$/) { # Walrus add (BF) |
} elsif (/^\,(.*?)[\x0D\x0A]*$/) { # Walrus add (BF) |
632 |
&back_push('table', 1, \@saved, \@result, ' border="1"'); |
&back_push('table', 1, \@saved, \@result, ' border="1"'); |
651 |
push(@result, join('', '<tr>', @value, '</tr>')); |
push(@result, join('', '<tr>', @value, '</tr>')); |
652 |
# XXXXX |
# XXXXX |
653 |
####### |
####### |
654 |
|
} elsif (/^\[INS\[/) { |
655 |
|
push(@result, "<ins>"); |
656 |
|
} elsif (/^\]INS\]/) { |
657 |
|
push(@result, "</ins>"); |
658 |
|
} elsif (/^\[DEL\[/) { |
659 |
|
push(@result, "<del>"); |
660 |
|
} elsif (/^\]DEL\]/) { |
661 |
|
push(@result, "</del>"); |
662 |
|
} elsif (/^\[PRE\[/) { |
663 |
|
push(@result, "<pre>"); |
664 |
|
} elsif (/^\]PRE\]/) { |
665 |
|
push(@result, "</pre>"); |
666 |
} else { |
} else { |
667 |
push(@result, &inline($_)); |
push(@result, &inline($_)); |
668 |
} |
} |
669 |
} |
} |
670 |
push(@result, splice(@saved)); |
push(@result, splice(@saved)); |
671 |
|
|
672 |
|
my $toc = ''; |
673 |
if ($option{toc}) { |
if ($option{toc}) { |
674 |
# Convert @toc (table of contents) to HTML. |
# Convert @toc (table of contents) to HTML. |
675 |
# This part is taken from Makio Tsukamoto's WalWiki. |
# This part is taken from Makio Tsukamoto's WalWiki. |
676 |
my (@tocsaved, @tocresult); |
my (@tocsaved, @tocresult); |
677 |
foreach (@toc) { |
foreach (@toc) { |
678 |
if (/^(-{1,3})(.*)/) { |
if (/^(-{1,6})(.*)$/) { |
679 |
&back_push('ul', length($1), \@tocsaved, \@tocresult); |
&back_push('ul', length($1), \@tocsaved, \@tocresult); |
680 |
push(@tocresult, '<li>' . $2 . '</li>'); |
push(@tocresult, '<li>' . $2 . '</li>'); |
681 |
} |
} |
682 |
} |
} |
683 |
push(@tocresult, splice(@tocsaved)); |
push(@tocresult, splice(@tocsaved)); |
684 |
return join("\n", @tocresult, @result); |
$toc = join("\n", @tocresult); |
685 |
} else { |
$toc = $toc ? qq(<div id="wikipage-toc">$toc</div>) : ''; |
|
return join("\n", @result); |
|
686 |
} |
} |
687 |
|
return $toc . join("\n", @result); |
688 |
} |
} |
689 |
|
|
690 |
sub back_push { |
sub back_push { |
709 |
$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 |
710 |
$line =~ s! |
$line =~ s! |
711 |
( |
( |
712 |
(?:<(?:mailto|http|https|ftp|urn):[\x21-\x7E]*)> |
(?:<(?:mailto|http|https|ftp|urn|news):[\x21-\x7E]*)> |
713 |
| |
| |
714 |
($bracket_name) # [[likethis]], [[#comment]], [[Friend:remotelink]] |
($bracket_name) # [[likethis]], [[#comment]], [[Friend:remotelink]] |
715 |
| |
| |
733 |
} elsif ($chunk =~ /^mailto:(.*)$/) { |
} elsif ($chunk =~ /^mailto:(.*)$/) { |
734 |
$name = $1; |
$name = $1; |
735 |
} |
} |
736 |
if ($use_autoimg and $name =~ /^(http|https|ftp|):.+\.(png|gif|jpe?g)/) { |
if ($use_autoimg and $name =~ /^(http|https|ftp):.+\.(png|gif|jpe?g)/) { |
737 |
$name = qq(<img src="$name">) ; |
$name = qq(<img src="$name">) ; |
738 |
} |
} |
739 |
$name = &unarmor_name($name); |
$name = &unarmor_name($name); |
740 |
# Walrus add (3) end |
# Walrus add (3) end |
741 |
if ($chunk =~ /^(http|https|ftp):/) { |
if ($chunk =~ /^(http|https|ftp|news):/) { |
742 |
# Walrus mod (3) start |
# Walrus mod (3) start |
743 |
# if ($use_autoimg and $chunk =~ /\.(gif|png|jpeg|jpg)$/) { |
# if ($use_autoimg and $chunk =~ /\.(gif|png|jpeg|jpg)$/) { |
744 |
# return qq(<a href="$chunk"><img src="$chunk"></a>); |
# return qq(<a href="$chunk"><img src="$chunk"></a>); |
776 |
} elsif ($database{$chunk}) { |
} elsif ($database{$chunk}) { |
777 |
my $subject = &escape(&get_subjectline($chunk, delimiter => '')); |
my $subject = &escape(&get_subjectline($chunk, delimiter => '')); |
778 |
# 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) |
779 |
return qq(<a title="$subject" href="$url_cgi?$cookedchunk">@{[&escape($name)]}</a>); # Walrus add (3) |
return qq(<a title="$subject" href="$url_cgi?$cookedchunk" class="wiki">@{[&escape($name)]}</a>); # Walrus add (3) |
780 |
} elsif ($page_command{$chunk}) { |
} elsif ($page_command{$chunk}) { |
781 |
# 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) |
782 |
return qq(<a title="$chunk" href="$url_cgi?$cookedchunk" class="wiki">@{[&escape($name)]}</a>); # Walrus add (3) |
return qq(<a title="$chunk" href="$url_cgi?$cookedchunk" class="wiki">@{[&escape($name)]}</a>); # Walrus add (3) |
871 |
|
|
872 |
# Get the subject of the page. |
# Get the subject of the page. |
873 |
my $subject = $database{$page}; |
my $subject = $database{$page}; |
874 |
|
$subject =~ s#^SuikaWiki/0.9[^\x0D\x0A]*[\x0D\x0A]+##s; |
875 |
$subject =~ s/\r?\n.*//s; |
$subject =~ s/\r?\n.*//s; |
876 |
return "$delim$subject"; |
return "$delim$subject".$option{tail}; |
877 |
} |
} |
878 |
} |
} |
879 |
|
|
979 |
} |
} |
980 |
$mymsg = &escape($form{mymsg}); |
$mymsg = &escape($form{mymsg}); |
981 |
} else { |
} else { |
982 |
$mymsg = &escape($mymsg); |
$mymsg = &escape($mymsg || $database{NewPageTemplate}); |
983 |
} |
} |
984 |
|
|
985 |
my $edit = $mode{admin} ? 'adminedit' : 'edit'; |
my $edit = $mode{admin} ? 'adminedit' : 'edit'; |
991 |
@{[ $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>) : "" ]} |
992 |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
993 |
<input type="hidden" name="mypage" value="$escapedmypage"> |
<input type="hidden" name="mypage" value="$escapedmypage"> |
994 |
<textarea cols="$cols" rows="$rows" name="mymsg" wrap="off" tabindex="1">$mymsg</textarea><br> |
<textarea cols="$cols" rows="$rows" name="mymsg" tabindex="1">$mymsg</textarea><br> |
995 |
@{[ |
@{[ |
996 |
$mode{admin} ? |
$mode{admin} ? |
997 |
qq( |
qq( |
1053 |
# not_wiki_name -> [[not_wiki_name]] |
# not_wiki_name -> [[not_wiki_name]] |
1054 |
sub armor_name { |
sub armor_name { |
1055 |
my ($name) = @_; |
my ($name) = @_; |
1056 |
if ($name =~ /^$wiki_name$/) { |
#if ($name =~ /^$wiki_name$/) { |
1057 |
return $name; |
# return $name; |
1058 |
} else { |
#} else { |
1059 |
return "[[$name]]"; |
return "[[$name]]"; |
1060 |
} |
#} |
1061 |
} |
} |
1062 |
|
|
1063 |
# unarmor_name: |
# unarmor_name: |
1230 |
sub do_comment { |
sub do_comment { |
1231 |
my ($content) = $database{$form{mypage}}; |
my ($content) = $database{$form{mypage}}; |
1232 |
my $datestr = &get_now; |
my $datestr = &get_now; |
1233 |
my $namestr = $form{myname} ? " ''[[$form{myname}]]'' : " : " "; |
my $namestr = " ''[[@{[$form{myname}||$DEFAULT_embed_comment_name]}]]'' : "; |
1234 |
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/) { |
1235 |
; |
# ; |
1236 |
} else { |
#} else { |
1237 |
$content =~ s/(\Q$embed_rcomment\E)/$1\n- $datestr$namestr$form{mymsg}/; |
# $content =~ s/(\Q$embed_rcomment\E)/$1\n- $datestr$namestr$form{mymsg}/; |
1238 |
|
#} |
1239 |
|
my $i = 1; my $o = 0; |
1240 |
|
$content =~ s{(\Q$embed_comment\E|\Q$embed_rcomment\E)}{ |
1241 |
|
my $embed = $1; |
1242 |
|
if ($i == $form{comment_index}) { |
1243 |
|
if ($embed eq $embed_comment) { |
1244 |
|
$embed = "- $datestr$namestr$form{mymsg}\n$embed"; $o = 1; |
1245 |
|
} else { |
1246 |
|
$embed .= "\n- $datestr$namestr$form{mymsg}"; $o = 1; |
1247 |
|
} |
1248 |
|
} |
1249 |
|
$i++; $embed; |
1250 |
|
}ge; |
1251 |
|
unless ($o) { |
1252 |
|
$content .= "- $datestr$namestr$form{mymsg}\n"; |
1253 |
} |
} |
1254 |
if ($form{mymsg}) { |
if ($form{mymsg}) { |
1255 |
$form{mymsg} = $content; |
$form{mymsg} = $content; |
1261 |
} |
} |
1262 |
} |
} |
1263 |
|
|
1264 |
|
my $CommentIndex = 0; |
1265 |
sub embedded_to_html { |
sub embedded_to_html { |
1266 |
my ($embedded) = @_; |
my ($embedded) = @_; |
1267 |
if ($embedded eq $embed_comment or $embedded eq $embed_rcomment) { |
if ($embedded eq $embed_comment or $embedded eq $embed_rcomment) { |
1268 |
my $lastmodified = &get_info($form{mypage}, $info_LastModified); |
my $lastmodified = &get_info($form{mypage}, $info_LastModified); |
1269 |
return <<"EOD"; |
return <<"EOD"; |
1270 |
<form action="$url_cgi" method="post"> |
<form action="$url_cgi" method="post" id="x-comment-@{[++$CommentIndex]}"> |
1271 |
<input type="hidden" name="mycmd" value="comment"> |
<input type="hidden" name="mycmd" value="comment"> |
1272 |
<input type="hidden" name="mypage" value="$form{mypage}"> |
<input type="hidden" name="mypage" value="$form{mypage}"> |
1273 |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
1274 |
<input type="hidden" name="mytouch" value="on"> |
<input type="hidden" name="mytouch" value="on"> |
1275 |
$resource{yourname} |
<input type="hidden" name="comment_index" value="$CommentIndex"> |
1276 |
|
$embed_comment_Name_Prompt |
1277 |
<input type="text" name="myname" value="" size="10"> |
<input type="text" name="myname" value="" size="10"> |
1278 |
<input type="text" name="mymsg" value="" size="40"> |
<input type="text" name="mymsg" value="" size="60"> |
1279 |
<input type="submit" value="$resource{commentbutton}"> |
<input type="submit" value="$resource{commentbutton}"> |
1280 |
</form> |
</form> |
1281 |
EOD |
EOD |
1327 |
# Walrus add (5) end |
# Walrus add (5) end |
1328 |
|
|
1329 |
sub code_convert { |
sub code_convert { |
1330 |
my ($contentref, $kanjicode) = @_; |
my ($contentref, $code) = (shift, shift || $kanjicode); |
1331 |
# &Jcode::convert($contentref, $kanjicode); # for Jcode.pm |
# &Jcode::convert($contentref, $code); # for Jcode.pm |
1332 |
&jcode::convert($contentref, $kanjicode); # for jcode.pl |
&jcode::convert($contentref, $code); # for jcode.pl |
1333 |
return $$contentref; |
return $$contentref; |
1334 |
} |
} |
1335 |
|
|
1468 |
} |
} |
1469 |
} |
} |
1470 |
|
|
1471 |
|
sub __get_database ($) { $database{ $_[0] } } |
1472 |
|
|
1473 |
|
package wiki::referer; |
1474 |
|
sub add ($$) { |
1475 |
|
my $page = shift; |
1476 |
|
my $uri = shift; |
1477 |
|
unless (ref $uri) { |
1478 |
|
require URI; |
1479 |
|
$uri = URI->new ($uri); |
1480 |
|
## Some schemes do not have query part. |
1481 |
|
eval q{ $uri->query (undef) if $uri->query =~ /^[0-9]{6,8}$/ }; |
1482 |
|
$uri->fragment (undef); |
1483 |
|
} |
1484 |
|
$uri = $uri->canonical; |
1485 |
|
return unless $uri; |
1486 |
|
for my $regex (&get_dont_record) { |
1487 |
|
return if $uri =~ /$regex/; |
1488 |
|
} |
1489 |
|
my %list = get ($page); |
1490 |
|
$list{ $uri }++; |
1491 |
|
set ($page, \%list); |
1492 |
|
} |
1493 |
|
sub get ($) { |
1494 |
|
my $page = shift; |
1495 |
|
split /"/, main::get_info ($page, 'Referer'); |
1496 |
|
} |
1497 |
|
sub set ($%) { |
1498 |
|
my $page = shift; |
1499 |
|
my $list = shift; |
1500 |
|
main::set_info ($page, Referer => join '"', %$list); |
1501 |
|
} |
1502 |
|
|
1503 |
|
sub get_dont_record () { |
1504 |
|
map {s/\$/\\\$/g; s/\@/\\\@/g; $_} |
1505 |
|
grep !/^#/, |
1506 |
|
split /[\x0D\x0A]+/, &main::__get_database ('RefererDontRecord'); |
1507 |
|
} |
1508 |
|
sub get_site_name () { |
1509 |
|
my @lines = grep /[^#]/, split /[\x0D\x0A]+/, &main::__get_database('RefererSiteName'); |
1510 |
|
my %item; |
1511 |
|
for (@lines) { |
1512 |
|
next if /^#/; |
1513 |
|
my ($uri, $name) = split /\s+/, $_, 2; |
1514 |
|
$uri =~ s/\$/\\\$/g; $uri =~ s/\@/\\\@/g; $uri =~ s/\//\\\//g; |
1515 |
|
$name =~ s![()/\\]!\\$1!g; $name =~ s/\$([0-9]+)/).__decode (\${$1}).q(/g; |
1516 |
|
$item{$uri} = qq(q($name)); |
1517 |
|
} |
1518 |
|
%item; |
1519 |
|
} |
1520 |
|
|
1521 |
|
sub list_html ($) { |
1522 |
|
my $page = shift; |
1523 |
|
my %list = get ($page); |
1524 |
|
my $r = ''; |
1525 |
|
my %name = get_site_name; |
1526 |
|
for my $uri (sort keys %list) { |
1527 |
|
my $title; |
1528 |
|
for my $regex (keys %name) { |
1529 |
|
if ($uri =~ /$regex/) { |
1530 |
|
$title = $uri; |
1531 |
|
eval qq{\$title =~ s/^.*$regex.*\$/$name{$regex}/e} or die $@; |
1532 |
|
last; |
1533 |
|
} |
1534 |
|
} |
1535 |
|
my $euri = main::escape ($uri); |
1536 |
|
if ($title) { |
1537 |
|
$r .= qq(<li>[$list{$uri}] <a href="$euri" title="URI: <$euri>">@{[main::escape ($title)]}</a></li>\n); |
1538 |
|
} else { |
1539 |
|
$r .= qq(<li>[$list{$uri}] <<a href="$euri">$euri</a>></li>\n); |
1540 |
|
} |
1541 |
|
} |
1542 |
|
$r ? qq(<ul>$r</ul>\n) : ''; |
1543 |
|
} |
1544 |
|
|
1545 |
|
sub __decode ($) { |
1546 |
|
my $s = shift; |
1547 |
|
$s =~ tr/+/ /; |
1548 |
|
$s =~ s/%([0-9A-Fa-f][0-9A-Fa-f])/chr hex $1/ge; |
1549 |
|
main::code_convert (\$s); |
1550 |
|
} |
1551 |
|
|
1552 |
1; |
1; |
1553 |
__END__ |
__END__ |
1554 |
=head1 NAME |
=head1 NAME |