97 |
my $embed_interwiki = '^\[\[#(box|text|password):(\S+)\]\]$'; # Walrus add (5) |
my $embed_interwiki = '^\[\[#(box|text|password):(\S+)\]\]$'; # Walrus add (5) |
98 |
my %embed_command = ( |
my %embed_command = ( |
99 |
searched => '^\[\[#searched:([^\]]+)\]\]$', |
searched => '^\[\[#searched:([^\]]+)\]\]$', |
100 |
|
form => qw/\[\[\#form(?:\(([A-Za-z0-9-]+)\))?:'((?:[^'\\]|\\.)*)':'((?:[^'\\]|\\.)*)'(?::'((?:[^'\\]|\\.)*)')?\]\]/, |
101 |
); |
); |
102 |
############################## |
############################## |
103 |
my $info_LastModified = 'LastModified'; |
my $info_LastModified = 'LastModified'; |
153 |
rss => \&do_rss, |
rss => \&do_rss, |
154 |
diff => \&do_diff, |
diff => \&do_diff, |
155 |
interwikibox => \&do_interwiki_box, # Walrus add (5) |
interwikibox => \&do_interwiki_box, # Walrus add (5) |
156 |
|
wikiform => \&do_wikiform, |
157 |
); |
); |
158 |
############################## |
############################## |
|
my @ignore_html_page = ('FrontPage'); # Walrus add (6) |
|
|
my @ignore_html_tags = ('a', 'br', 'img'); # Walrus add (6) |
|
159 |
my $walversion = '2.0.beta1.wal.1'; # Walrus add (1) |
my $walversion = '2.0.beta1.wal.1'; # Walrus add (1) |
160 |
############################## |
############################## |
161 |
# &test_convert; |
# &test_convert; |
162 |
my $UA = ''; |
my $UA = ''; ## User agent name |
163 |
&main; |
&main; |
164 |
exit(0); |
exit(0); |
165 |
############################## |
############################## |
232 |
|
|
233 |
sub id_and_name ($) { |
sub id_and_name ($) { |
234 |
my $name = shift; |
my $name = shift; |
235 |
if ($UA =~ m#Mozilla/2#) { |
if ($UA =~ m#Mozilla/[12]\.#) { |
236 |
qq{id="$name"><a name="$name"></a}; |
qq{id="$name"><a name="$name"></a}; |
237 |
} else { |
} else { |
238 |
qq{id="$name"}; |
qq{id="$name"}; |
355 |
&update_recent_changes; |
&update_recent_changes; |
356 |
} |
} |
357 |
&set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen}); |
&set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen}); |
358 |
&print_header($CompletedSuccessfully, -noindex => 1, -goto => $url_cgi.'?mycmd=read;mypage='.&encode($form{mypage}).qq(;x-param=@{[time.[0..9]->[rand 10]]}).($form{__comment_anchor_index}?"#anchor-$form{__comment_anchor_index}":'')); |
my $fragment; |
359 |
|
if ($form{__comment_anchor_index}) { |
360 |
|
$fragment = qq(anchor-$form{__comment_anchor_index}); |
361 |
|
} elsif ($form{__wikiform_anchor_index}) { |
362 |
|
$fragment = qq(wikiform-$form{__wikiform_anchor_index}); |
363 |
|
} |
364 |
|
&print_header($CompletedSuccessfully, -noindex => 1, -goto => $url_cgi.'?mycmd=read;mypage='.&encode($form{mypage}).qq(;x-param=@{[time.[0..9]->[rand 10]]}).($fragment?'#'.$fragment:'')); |
365 |
&print_message($resource{saved}); |
&print_message($resource{saved}); |
366 |
&print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}"); |
&print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}"); |
367 |
&print_footer($CompletedSuccessfully); |
&print_footer($CompletedSuccessfully); |
467 |
} |
} |
468 |
$bodyclass .= " wiki-page-obsoleted" if $option{-content_format} =~ /obsoleted="yes"/; |
$bodyclass .= " wiki-page-obsoleted" if $option{-content_format} =~ /obsoleted="yes"/; |
469 |
if ($option{-goto}) { |
if ($option{-goto}) { |
470 |
if ($UA =~ m#Mozilla/2|Opera#) { |
if ($UA =~ m#Mozilla/[12]\.|Opera#) { |
471 |
$option{-goto} =~ tr/;/&/; |
$option{-goto} =~ tr/;/&/; |
472 |
print qq{Refresh: 0; url=$option{-goto}\n}; |
print qq{Refresh: 0; url=$option{-goto}\n}; |
473 |
|
$option{-goto} = qq(<meta http-equiv="refresh" content="0; url=$option{-goto}">); |
474 |
} else { |
} else { |
475 |
print qq{Refresh: 0; url="$option{-goto}"\n}; |
print qq{Refresh: 0; url="$option{-goto}"\n}; |
476 |
|
$option{-goto} = qq(<meta http-equiv="refresh" content="0; url="@{[&escape($option{-goto})]}"">); |
477 |
} |
} |
478 |
} |
} |
479 |
print qq{Last-Modified: $option{-last_modified}\n} if $option{-last_modified}; |
print qq{Last-Modified: $option{-last_modified}\n} if $option{-last_modified}; |
497 |
"http://www.w3.org/TR/html4/loose.dtd"> + RUBY --> |
"http://www.w3.org/TR/html4/loose.dtd"> + RUBY --> |
498 |
<html lang="$lang"> |
<html lang="$lang"> |
499 |
<head> |
<head> |
500 |
$meta_ct |
$meta_ct$option{-goto} |
501 |
<title>$escapedpage</title> |
<title>$escapedpage</title> |
502 |
<link rel="index" href="$url_cgi?$IndexPage"> |
<link rel="index" href="$url_cgi?$IndexPage"> |
503 |
<link rel="help" href="$url_cgi?WikiHelp"> |
<link rel="help" href="$url_cgi?WikiHelp"> |
575 |
|
|
576 |
sub print_footer { |
sub print_footer { |
577 |
my ($page, $lm) = @_; |
my ($page, $lm) = @_; |
578 |
|
my $epage = &encode ($page); |
579 |
$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) |
580 |
# Walrus mod (1) start |
# Walrus mod (1) start |
581 |
my $cvslog1 = q$Revision$; |
my $cvslog1 = q$Revision$; |
591 |
<a href="/map" title="このサーバーの案内">地図</a> |
<a href="/map" title="このサーバーの案内">地図</a> |
592 |
<a href="/search/" title="このサーバーの検索">検索</a>] |
<a href="/search/" title="このサーバーの検索">検索</a>] |
593 |
</div> |
</div> |
594 |
|
<div class="myuri"> |
595 |
|
<<a href="$url_cgi?$epage">$url_cgi?$epage</a>> |
596 |
|
</div> |
597 |
</div> |
</div> |
598 |
$walrus_log |
$walrus_log |
599 |
</body> |
</body> |
600 |
</html> |
</html> |
601 |
EOD |
EOD |
|
# print <<"EOD"; |
|
|
# <hr> |
|
|
# <address class="footer"> |
|
|
# <a href="http://www.hyuki.com/yukiwiki/">YukiWiki</a> $version |
|
|
# © 2000-2002 by <a href="http://www.hyuki.com/">Hiroshi Yuki</a>.<br /> |
|
|
# Modified by <a href="$modifier_url">$modifier_name</a>. |
|
|
# </address> |
|
|
# <p class="footer"> |
|
|
# <a href="http://www.hyuki.com/yukiwiki/">$icontag</a> |
|
|
# </p> |
|
|
# </body> |
|
|
# </html> |
|
|
# EOD |
|
|
# Walrus mod (1) end |
|
602 |
} |
} |
603 |
|
|
604 |
sub escape { |
sub escape { |
765 |
sub inline { |
sub inline { |
766 |
my ($line) = @_; |
my ($line) = @_; |
767 |
$line = &escape($line); |
$line = &escape($line); |
768 |
|
$line =~ s{$embed_command{form}}{&make_custom_form ($1, $2, $3, $4)}ge; |
769 |
$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; |
770 |
$line =~ s:\[(WEAK)\[(.+?)\]\]:<span class="@{[lc $1]}">$2</span>:g; |
$line =~ s:\[(WEAK)\[(.+?)\]\]:<span class="@{[lc $1]}">$2</span>:g; |
771 |
$line =~ s:\[ABBR\[([^]]+)\] \[([^]]+)\]\]:<acronym title="$2">$1</acronym>:g; |
$line =~ s:\[ABBR\[([^]]+)\] \[([^]]+)\]\]:<acronym title="$2">$1</acronym>:g; |
847 |
} |
} |
848 |
} |
} |
849 |
|
|
850 |
|
my $FormIndex = 0; |
851 |
|
sub make_custom_form ($$$) { |
852 |
|
my ($wfname, $definition, $template, $option) = @_; |
853 |
|
## $template and $option is currently not used in this procedure. |
854 |
|
unless ($main::_EMBEDED) { |
855 |
|
$FormIndex++; |
856 |
|
if (length $definition) { |
857 |
|
my $param = bless {}, 'SuikaWiki::Plugin'; |
858 |
|
my $lastmodified = &get_info($form{mypage}, $info_LastModified); |
859 |
|
$definition =~ s/\\(.)/$1/g; |
860 |
|
$definition .= ' %submit;' if $definition !~ /%submit/; |
861 |
|
unless ($fmt{form_option}) { |
862 |
|
$fmt{form_option} = Message::Util::Formatter->new; |
863 |
|
for (@{$SuikaWiki::Plugin::List{wikiform_option}||[]}) { |
864 |
|
$_->load_formatter ($fmt{form_option}, type => 'wikiform_option'); |
865 |
|
} |
866 |
|
} |
867 |
|
$option = &unescape ($option); |
868 |
|
$option =~ s/\\(.)/$1/g; |
869 |
|
$fmt{form_option}->replace ($option, $param); |
870 |
|
my $target_form = $param->{output}->{id}; |
871 |
|
my $r = <<EOH; |
872 |
|
<form method="post" action="$url_cgi" id="wikiform-$FormIndex" class="wikiform"> |
873 |
|
<input type="hidden" name="mycmd" value="wikiform"> |
874 |
|
<input type="hidden" name="mypage" value="@{[&escape($form{mypage})]}"> |
875 |
|
<input type="hidden" name="myLastModified" value="$lastmodified"> |
876 |
|
<input type="hidden" name="mytouch" value="on"> |
877 |
|
<input type="hidden" name="@{[$target_form? qq(wikiform_targetform" value="@{[&escape($target_form)]}) : qq(wikiform_index" value="$FormIndex)]}"> |
878 |
|
EOH |
879 |
|
$r .= qq(<a name="wikiform-$FormIndex"></a>) if $UA =~ m#Mozilla/[12]\.#; |
880 |
|
$r .= $fmt{form_input}->replace (&unescape ($definition), $param); |
881 |
|
$r .= <<EOH; |
882 |
|
</form> |
883 |
|
EOH |
884 |
|
$r; |
885 |
|
} else { ## No input-interface WikiForm |
886 |
|
qq(<a id="wikiform-$FormIndex" name="wikiform-$FormIndex"><!-- #form --></a>); |
887 |
|
} |
888 |
|
} else { |
889 |
|
q(<ins class="wiki-error"><strong>Warning</strong>: form in embeded page is currently not supported.</ins>); |
890 |
|
} |
891 |
|
} |
892 |
|
|
893 |
## to be obsoleted |
## to be obsoleted |
894 |
sub make_link { |
sub make_link { |
895 |
my $chunk = shift; |
my $chunk = shift; |
962 |
# $form{mycmd} is frozen here. |
# $form{mycmd} is frozen here. |
963 |
# |
# |
964 |
|
|
965 |
|
for (grep /^wikiform__/, keys %form) { |
966 |
|
$form{$_} = &code_convert (\$form{$_}, $kanjicode); |
967 |
|
} |
968 |
$form{mymsg} = &code_convert(\$form{mymsg}, $kanjicode); |
$form{mymsg} = &code_convert(\$form{mymsg}, $kanjicode); |
969 |
$form{myname} = &code_convert(\$form{myname}, $kanjicode); |
$form{myname} = &code_convert(\$form{myname}, $kanjicode); |
970 |
} |
} |
972 |
sub update_recent_changes { |
sub update_recent_changes { |
973 |
my $update = "- @{[&get_now]} [[@{[&escape($form{mypage})]}]] @{[&get_subjectline($form{mypage})]}"; |
my $update = "- @{[&get_now]} [[@{[&escape($form{mypage})]}]] @{[&get_subjectline($form{mypage})]}"; |
974 |
my @oldupdates = split(/\r?\n/, $database{$RecentChanges}); |
my @oldupdates = split(/\r?\n/, $database{$RecentChanges}); |
975 |
|
shift (@oldupdates); ## '#?' magic line |
976 |
my @updates; |
my @updates; |
977 |
foreach (@oldupdates) { |
foreach (@oldupdates) { |
978 |
/^\- \d\d\d\d\-\d\d\-\d\d \([^)]+\) \d\d:\d\d \[\[(\S+?)\]\]/; |
/^\- \d\d\d\d\-\d\d\-\d\d \([^)]+\) \d\d:\d\d \[\[(\S+?)\]\]/; |
1285 |
$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]+)+$/; |
1286 |
&encode (&code_convert (\$p->{name}, $o->{charset} || 'shift_jis')); |
&encode (&code_convert (\$p->{name}, $o->{charset} || 'shift_jis')); |
1287 |
}; |
}; |
1288 |
|
|
1289 |
|
$fmt{form_input} = Message::Util::Formatter->new; |
1290 |
|
for (@{$SuikaWiki::Plugin::List{wikiform_input}||[]}) { |
1291 |
|
$_->load_formatter ($fmt{form_input}, type => 'wikiform_input'); |
1292 |
|
} |
1293 |
} |
} |
1294 |
|
|
1295 |
|
|
1356 |
} elsif (length $namestr) { |
} elsif (length $namestr) { |
1357 |
$namestr = qq( ''[[$namestr]]'': ); |
$namestr = qq( ''[[$namestr]]'': ); |
1358 |
} |
} |
1359 |
my $anchor = 0; |
my $anchor = &get_new_anchor_index ($content); |
|
$content =~ s/(?:-+\s)?\[([0-9]+)\]/$anchor = $1 if $1 > $anchor; $&/mge; |
|
|
$anchor++; |
|
1360 |
my $i = 1; my $o = 0; |
my $i = 1; my $o = 0; |
1361 |
$content =~ s{(\Q$embed_comment\E|\Q$embed_rcomment\E)}{ |
$content =~ s{(\Q$embed_comment\E|\Q$embed_rcomment\E)}{ |
1362 |
my $embed = $1; |
my $embed = $1; |
1385 |
} |
} |
1386 |
} |
} |
1387 |
|
|
1388 |
|
sub get_new_anchor_index ($) { |
1389 |
|
my $content = shift; |
1390 |
|
my $anchor = 0; |
1391 |
|
$content =~ s/^(?:[-=]+\s*)?\[([0-9]+)\]/$anchor = $1 if $1 > $anchor; $&/mge; |
1392 |
|
$anchor + 1; |
1393 |
|
} |
1394 |
|
|
1395 |
my $CommentIndex = 0; |
my $CommentIndex = 0; |
1396 |
sub embedded_to_html { |
sub embedded_to_html { |
1397 |
my ($embedded) = @_; |
my ($embedded) = @_; |
1455 |
} |
} |
1456 |
} |
} |
1457 |
|
|
1458 |
|
sub do_wikiform { |
1459 |
|
my $content = $database{$form{mypage}}; |
1460 |
|
my $anchor = &get_new_anchor_index ($content); |
1461 |
|
for my $t (qw/form_template form_option/) { |
1462 |
|
unless ($fmt{$t}) { |
1463 |
|
$fmt{$t} = Message::Util::Formatter->new; |
1464 |
|
for (@{$SuikaWiki::Plugin::List{'wiki'.$t}||[]}) { |
1465 |
|
$_->load_formatter ($fmt{$t}, type => 'wiki'.$t); |
1466 |
|
} |
1467 |
|
} |
1468 |
|
} |
1469 |
|
my $write = 0; |
1470 |
|
my $i = 1; |
1471 |
|
$content =~ s{$embed_command{form}}{ |
1472 |
|
my ($embed, $wfname, $template, $option) = ($&, $1, $3, $4); |
1473 |
|
if (($wfname && $wfname eq $form{wikiform_targetform}) |
1474 |
|
|| $i == $form{wikiform_index}) { |
1475 |
|
$template =~ s/\\(.)/$1/g; |
1476 |
|
$option =~ s/\\(.)/$1/g; |
1477 |
|
my $param = bless {}, 'SuikaWiki::Plugin'; |
1478 |
|
$param->{page} = $form{mypage}; |
1479 |
|
$param->{form_index} = $i; |
1480 |
|
$param->{form_name} = $wfname; |
1481 |
|
$param->{anchor_index} = $anchor; |
1482 |
|
$param->{argv} = \%form; |
1483 |
|
$param->{default_name} = $1 if $content =~ /default-name="([^"]+)"/; |
1484 |
|
$param->{default_name} ||= $DEFAULT_embed_comment_name; |
1485 |
|
$fmt{form_option}->replace ($option, $param); |
1486 |
|
my $t = 1; |
1487 |
|
for (@{$param->{require}||[]}) { |
1488 |
|
(undef $t, last) unless length $param->{argv}->{'wikiform__'.$_}; |
1489 |
|
} |
1490 |
|
$t = $fmt{form_template}->replace ($template, $param) if $t; |
1491 |
|
if (length $t) { |
1492 |
|
if ($param->{output}->{reverse}) { |
1493 |
|
$embed .= "\n" . $t; |
1494 |
|
} else { |
1495 |
|
$embed = $t . "\n" . $embed; |
1496 |
|
} |
1497 |
|
$write = 1; |
1498 |
|
$form{__comment_anchor_index} = $anchor |
1499 |
|
if $param->{anchor_index_}; ## $anchor is used! |
1500 |
|
} |
1501 |
|
$form{__wikiform_anchor_index} = $i; |
1502 |
|
undef $form{wikiform_targetform}; ## make sure never to match |
1503 |
|
undef $form{wikiform_index}; ## with WikiForm in rest of page |
1504 |
|
} |
1505 |
|
$i++; $embed; |
1506 |
|
}ge; |
1507 |
|
unless ($write) { |
1508 |
|
#$content = "#?SuikaWiki/0.9\n\n" unless $content; |
1509 |
|
#$content .= "\n" unless $content =~ /\n$/s; |
1510 |
|
# |
1511 |
|
} |
1512 |
|
if ($write) { |
1513 |
|
$form{mymsg} = $content; |
1514 |
|
$form{mytouch} = 'on'; |
1515 |
|
&do_write; |
1516 |
|
} else { |
1517 |
|
$form{mycmd} = 'read'; |
1518 |
|
&do_read; |
1519 |
|
} |
1520 |
|
} |
1521 |
|
|
1522 |
|
|
1523 |
# Walrus add (5) start |
# Walrus add (5) start |
1524 |
sub do_interwiki_box { |
sub do_interwiki_box { |
1525 |
my $remoteurl = $interwiki{$form{'myintername'}}; |
my $remoteurl = $interwiki{$form{'myintername'}}; |
1807 |
&main::__set_database ('WikiUserAgentList' => $s); |
&main::__set_database ('WikiUserAgentList' => $s); |
1808 |
} |
} |
1809 |
|
|
1810 |
|
package SuikaWiki::Plugin; |
1811 |
|
our %List; |
1812 |
|
|
1813 |
|
sub escape ($$) { main::escape ($_[1]) } |
1814 |
|
sub unescape ($$) { main::unescape ($_[1]) } |
1815 |
|
sub encode ($$) { main::encode ($_[1]) } |
1816 |
|
sub decode ($$) { main::decode ($_[1]) } |
1817 |
|
sub __get_datetime ($) { main::get_now () } |
1818 |
|
|
1819 |
|
sub regist ($@) { |
1820 |
|
my $pack = shift; |
1821 |
|
for (@_) { |
1822 |
|
push @{$List{$_}}, $pack; |
1823 |
|
} |
1824 |
|
} |
1825 |
|
|
1826 |
|
use SuikaWiki::Plugin::WikiFormBasic; |
1827 |
|
|
1828 |
1; |
1; |
1829 |
__END__ |
__END__ |
1830 |
=head1 NAME |
=head1 NAME |