--- suikawiki/script/wiki.cgi 2003/01/12 09:15:06 1.50 +++ suikawiki/script/wiki.cgi 2003/01/26 02:30:24 1.51 @@ -1,33 +1,28 @@ #!/usr/bin/perl -# wiki.cgi - This is YukiWiki, yet another Wiki clone. -# -# This program is free software; you can redistribute it and/or -# modify it under the same terms as Perl itself. +## wiki.cgi - This is SuikaWiki, yet another WikiEngine use strict; use lib qw(./lib); use CGI::Carp qw(fatalsToBrowser); -our $VERSION = do{my @r=(q$Revision: 1.50 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; binmode STDOUT; binmode STDIN; -require 'wikidata/suikawiki-config.ph'; +our $VERSION = do{my @r=(q$Revision: 1.51 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; +require 'wikidata/suikawiki-config.ph'; ## site configuration script +require Yuki::YukiWikiCache; use Fcntl; -############################## our %fmt; ## formatter objects our %embed_command = ( searched => '^\[\[#searched:([^\]]+)\]\]$', form => qr/\[\[\#form(?:\(([A-Za-z0-9-]+)\))?:'((?:[^'\\]|\\.)*)':'((?:[^'\\]|\\.)*)'(?::'((?:[^'\\]|\\.)*)')?\]\]/, ); -our ($modifier_dbtype,$url_cgi,%uri,%PathTo,$use_exists); +our ($modifier_dbtype,$url_cgi,%uri,%PathTo); our (%PageName,$kanjicode,$lang,%ViewDefinition); -############################## my %form; our %database; our $database = bless {}, 'wiki::dummy'; my %interwiki; -############################## my %command_do = ( - read => \&do_view, + default => \&do_view, adminchangepassword => \&do_adminchangepassword, write => \&do_write, searchform => \&do_searchform, @@ -35,9 +30,8 @@ RandomJump => \&do_random_jump, wikiform => \&do_wikiform, ); -my $UA = ''; ## User agent name +our $UA = ''; ## User agent name $| = 1; -############################## sub main { $UA = $main::ENV{HTTP_USER_AGENT}; @@ -46,7 +40,7 @@ if ($command_do{$form{mycmd}}) { &{$command_do{$form{mycmd}}}; } else { - &{$command_do{read}}; + &{$command_do{default}}; } &close_db; } @@ -61,7 +55,15 @@ if ($view eq 'edit') { $view = 'adminedit' if $form{admin}; } elsif ($view =~ /[^0-9A-Za-z]/) { - $view = 'view' + $view = 'default' + } + if ($view eq 'default' || !$view) { + ## BUG: this code is not strict + if ($main::ENV{HTTP_COOKIE} =~ /SelectedMode=([0-9A-Za-z]+)/) { + $view = $1; + } else { + $view = 'read'; + } } my ($magic, $content) = &SuikaWiki::Plugin::magic_and_content (undef, $content); $magic ||= '#?SuikaWiki/0.9'; @@ -76,16 +78,23 @@ if ($ViewDefinition{$view}->{xmedia} && $UA =~ /Gecko/) { $media = $ViewDefinition{$view}->{xmedia}; $o->{media} = $media; + } elsif ($UA =~ m#Mozilla/0\..+Windows#) { + $kanjicode = 'shift_jis'; } if ($magic =~ m!^\#\?SuikaWiki/0.9!) { - &print_header ($form{mypage}, -last_modified => ($magic =~ /interactive="yes"/ ? $lm : time), + &print_header ($form{mypage}, -last_modified => ($magic =~ /interactive="yes"/ ? time : $lm), -expires => ($magic =~ /interactive="yes"/ ? 1 : undef), o => $o, -media => $media, -magic => $magic, content => $content); } else { &print_header($form{mypage}, -media => $media, -magic => $magic, -last_modified => $lm, o => $o); } + if ($kanjicode ne 'euc') { + my $s = $fmt{view}->replace ($ViewDefinition{$view}->{template} => $o); + print &code_convert (\$s => $kanjicode); + } else { print $fmt{view}->replace ($ViewDefinition{$view}->{template} => $o); + } } sub _do_view_msg (%) { @@ -175,7 +184,7 @@ } elsif ($form{__wikiform_anchor_index}) { $fragment .= qq(#wikiform-$form{__wikiform_anchor_index}); } - &_do_view_msg (-view => '-wrote', -page => $form{mypage}, -goto => $url_cgi.'?mycmd='.&encode($form{after_edit_cmd}||'read').';mypage='.&encode($form{mypage}).qq(;x-param=@{[time.[0..9]->[rand 10]]}$fragment)); + &_do_view_msg (-view => '-wrote', -page => $form{mypage}, -goto => $url_cgi.'?mycmd='.&encode($form{after_edit_cmd}||'default').';mypage='.&encode($form{mypage}).qq(;x-param=@{[time.[0..9]->[rand 10]]}$fragment)); } else { delete $database{$form{mypage}}; &_do_view_msg (-view => '-deleted', -page => $form{mypage}); @@ -188,23 +197,31 @@ sub get_search_result ($;%) { my $word = lc shift; + my $SearchResult = SuikaWiki::Plugin->cache ('search'); my %option = @_; my @r; - foreach my $page (keys %database) { - next if !$option{-match_myself} && ($page eq $word); - my $content = lc $database{$page}; - if (index (lc $page, $word) > -1) { - my $c = $content =~ s/\Q$word\E//g; - push @r, [$page, $c+20]; - } elsif (index ($word, lc $page) > -1) { - my $c = $content =~ s/\Q$word\E//g; - push @r, [$page, $c+10]; - } elsif (my $c = $content =~ s/\Q$word\E//g) { - push @r, [$page, $c]; + unless (defined $SearchResult->{$word}) { + for my $page (keys %database) { + next if !$option{-match_myself} && ($page eq $word); + my $content = lc $database{$page}; + $content =~ s/^[^\x0A\x0D]+[\x0D\x0A]+//s; + if (index (lc $page, $word) > -1) { + my $c = $content =~ s/\Q$word\E//g; + push @r, [$page, $c+20]; + } elsif (index ($word, lc $page) > -1) { + my $c = $content =~ s/\Q$word\E//g; + push @r, [$page, $c+10]; + } elsif (my $c = $content =~ s/\Q$word\E//g) { + push @r, [$page, $c]; + } } + @r = sort {$b->[1] <=> $a->[1] || $a->[0] cmp $b->[0]} @r; + $SearchResult->{$word} = join "\x1E", map {$_->[0]."\x1F".$_->[1]} @r; + } else { + @r = map {[split /\x1F/, $_, 2]} split /\x1E/, $SearchResult->{$word}; } #my $em = sub { my $s = shift; $s =~ s#(\Q$word\E)#$1#gi; $s }; - my $r = join "\n", map {qq(
  • [$_->[1]] @{[&escape($_->[0])]} @{[&escape(&get_subjectline($_->[0]))]}
  • )} sort {$b->[1] <=> $a->[1] || $a->[0] cmp $b->[0]} @r; + my $r = join "\n", map {qq(
  • [$_->[1]] @{[&escape($_->[0])]} @{[&escape(&get_subjectline($_->[0]))]}
  • )} @r; $r = qq|| if $r; wantarray? ($r, scalar @r): $r; } @@ -245,12 +262,13 @@ print qq{Expires: @{[scalar gmtime (time + $option{-media}->{expires})]}\n}; } } - if ($option{-media}->{charset} && $UA =~ m#Mozilla/2#) { + if ($option{-media}->{charset} && $UA =~ m#Mozilla/[12]\.#) { my $ct = qq{$option{-media}->{type}; charset=@{[&get_charset_name($kanjicode,compatible=>1)]}}; print qq{Content-Type: $ct\n}; $option{o}->{-header}->{meta_ct} = qq{\n}; - } elsif (!$option{-media}->{charset} || $UA =~ m#Infomosaic#) { + } elsif (!$option{-media}->{charset} || $UA =~ m#Infomosaic|Mozilla/0\.#) { print qq{Content-Type: $option{-media}->{type}\n}; + $option{o}->{-header}->{meta_ct} = qq{\n}; } else { my $type = $option{-media}->{type}; $type = 'application/xml' if $type eq 'application/rss+xml'; @@ -319,10 +337,10 @@ ## Load constants my %const; - if ($option{content_format} =~ /import="([^"]+)"/) { + if ($option{magic} =~ /import="([^"]+)"/) { for (split /\s*,\s*/, $1) { my $wp = $database{$_}; - if ($wp =~ m!^\#\?SuikaWikiConst/1.0!) { + if ($wp =~ m!^\#\?SuikaWikiConst/(?:0.9|1.0)!) { wiki::suikawikiconst::to_hash ($wp => \%const); } } @@ -337,29 +355,29 @@ chomp; if (/^\*\*\*\*\*([^\x0D\x0A]*)/) { push @$toc, [5, "i$tocnum" => ($1 || $tocnum)]; - push(@result, splice(@saved), qq(
    ) . &inline($1, const => \%const) . '
    '); + push(@result, splice(@saved), qq(
    ) . &inline($1, %option, const => \%const) . '
    '); $tocnum++; } elsif (/^\*\*\*\*([^\x0D\x0A]*)/) { push @$toc, [4, "i$tocnum" => ($1 || $tocnum)]; - push(@result, splice(@saved), qq(
    ) . &inline($1, const => \%const) . '
    '); + push(@result, splice(@saved), qq(
    ) . &inline($1, %option, const => \%const) . '
    '); $tocnum++; } elsif (/^\*\*\*([^\x0D\x0A]*)/) { push @$toc, [3, "i$tocnum" => ($1 || $tocnum)]; - push(@result, splice(@saved), qq(

    ) . &inline($1, const => \%const) . '

    '); + push(@result, splice(@saved), qq(

    ) . &inline($1, %option, const => \%const) . '

    '); $tocnum++; } elsif (/^\*\*([^\x0D\x0A]*)/) { # if (/^\*\*(.*)/) { # Walrus mod (6) end push @$toc, [2, "i$tocnum" => ($1 || $tocnum)]; - push(@result, splice(@saved), qq(

    ) . &inline($1, const => \%const) . '

    '); + push(@result, splice(@saved), qq(

    ) . &inline($1, %option, const => \%const) . '

    '); $tocnum++; } elsif (/^\*([^\x0D\x0A]*)/) { push @$toc, [1, "i$tocnum" => ($1 || $tocnum)]; - push(@result, splice(@saved), qq(

    ) . &inline($1, const => \%const) . '

    '); + push(@result, splice(@saved), qq(

    ) . &inline($1, %option, const => \%const) . '

    '); $tocnum++; } elsif (/^(={1,6})(.*)/) { &back_push('ol', length($1), \@saved, \@result); - push(@result, '
  • ' . &inline($2, const => \%const) . '
  • '); + push(@result, '
  • ' . &inline($2, %option, const => \%const) . '
  • '); } elsif (/^(-{1,6})(.*)/) { &back_push('ul', length($1), \@saved, \@result); my ($pf, $l) = ('', $2); @@ -367,14 +385,14 @@ my $num = 0+$1; $pf = qq([$num]); } - push(@result, '
  • ' . $pf . &inline ($l, const => \%const) . '
  • '); + push(@result, '
  • ' . $pf . &inline ($l, %option, const => \%const) . '
  • '); } elsif (/^:([^:]+):(.*)/) { &back_push('dl', 1, \@saved, \@result); - push(@result, '
    ' . &inline($1, const => \%const) . '
    ', '
    ' . &inline($2, const => \%const) . '
    '); + push(@result, '
    ' . &inline($1, %option, const => \%const) . '
    ', '
    ' . &inline($2, %option, const => \%const) . '
    '); } elsif (/^(?!>>\d)(>{1,5})(.*)/) { &back_push('blockquote', length($1), \@saved, \@result); push @result, "

    "; - push(@result, &inline($2, const => \%const)); + push(@result, &inline($2, %option, const => \%const)); unshift @saved, "

    "; } elsif (/^\s*$/) { push(@result, splice(@saved)); @@ -382,7 +400,7 @@ unshift(@saved, "

    "); } elsif (/^(\s+.*)$/) { &back_push('pre', 1, \@saved, \@result); - push(@result, &inline($1, const => \%const)); + push(@result, &inline($1, %option, const => \%const)); } elsif (/^\,(.*?)[\x0D\x0A]*$/) { &back_push('table', 1, \@saved, \@result); ####### @@ -398,7 +416,7 @@ $colspan[$i]++; } $colspan[$i] = ($colspan[$i] > 1) ? sprintf(' colspan="%d"', $colspan[$i]) : ''; - $value[$i] = sprintf('%s', $align[$i], $colspan[$i], &inline($value[$i], const => \%const)); + $value[$i] = sprintf('%s', $align[$i], $colspan[$i], &inline($value[$i], %option, const => \%const)); } else { $value[$i] = ''; } @@ -415,9 +433,9 @@ } elsif (/^\[([0-9]+)\](.*)$/ && !$main::_EMBEDED) { my $num = 0+$1; push @result, qq([$num]); - push @result, &inline ($2, const => \%const); + push @result, &inline ($2, %option, const => \%const); } else { - push(@result, &inline($_, const => \%const)); + push(@result, &inline($_, %option, const => \%const)); } } push(@result, splice(@saved)); @@ -446,7 +464,7 @@ sub inline ($;%) { my ($line, %option) = @_; $line = &escape($line); - $line =~ s{$embed_command{form}}{&make_custom_form ($1, $2, $3, $4)}ge; + $line =~ s{$embed_command{form}}{&make_custom_form ($1, $2, $3, $4, \%option)}ge; $line =~ s{\[(INS|DEL|SUP|SUB|VAR|CODE|KBD|SAMP|DFN)(?:\(([A-Za-z0-9\x20-]+)\))?\[(.+?)\]\]}{<@{[lc $1]}@{[$2 ? qq( class="$2") : '']}>$3}g; $line =~ s:\[(WEAK)\[(.+?)\]\]:$2:g; $line =~ s:\[ABBR\[([^]]+)\] \[([^]]+)\]\]:$1:g; @@ -478,7 +496,7 @@ sub make_wikilink ($%) { my ($ename, %option) = @_; my $name = &unescape ($ename); - $option{latest} = $option{latest} ? qq(mycmd=read;x-param=@{[time.[0..9]->[rand 10]]};mypage=) : ''; + $option{latest} = $option{latest} ? qq(mycmd=default;x-param=@{[time.[0..9]->[rand 10]]};mypage=) : ''; if ($database{$name}) { my $subject = &escape (&get_subjectline ($name, delimiter => '')); if ($option{anchor}) { @@ -530,45 +548,46 @@ } } -{my $FormIndex = 0; -sub make_custom_form ($$$$) { - my ($wfname, $definition, $template, $option) = @_; - ## $template and $option is currently not used in this procedure. - unless ($main::_EMBEDED) { - $FormIndex++; +{my %FormIndex; +sub make_custom_form ($$$$%) { + my ($wfname, $definition, $template, $foption, $option) = @_; + ## $template is currently not used in this procedure. + #unless ($main::_EMBEDED) { + $FormIndex{$option->{page}}++; if (length $definition) { - my $param = bless {}, 'SuikaWiki::Plugin'; - my $lastmodified = $database->mtime ($form{mypage}); + my $param = bless {depth=>10}, 'SuikaWiki::Plugin'; + my $lastmodified = $database->mtime ($option->{page}); &load_formatter (qw/form_input form_option/); $definition = &unescape ($definition); $definition =~ s/\\(.)/$1/g; - $option = &unescape ($option); - $option =~ s/\\(.)/$1/g; - $fmt{form_option}->replace ($option, $param); + $foption = &unescape ($foption); + $foption =~ s/\\(.)/$1/g; + $fmt{form_option}->replace ($foption, $param); $param->{output}->{form} = 1 unless defined $param->{output}->{form}; + $param->{output}->{form} = 0 if $main::_EMBEDED; $definition .= ' %submit;' if $definition !~ /%submit/ && !$param->{output}->{nosubmit} && $param->{output}->{form}; - $param->{output}->{page} ||= $form{mypage}; - $param->{form_disabled} = 1 if $database->meta (IsFrozen => $form{mypage}); + $param->{output}->{page} ||= $option->{page}; + $param->{form_disabled} = 1 if $database->meta (IsFrozen => $option->{page}); my $target_form = $param->{output}->{id}; my $r = ''; $r = <{output}->{form}; -
    - + + - + EOH - $r .= qq() if $UA =~ m#Mozilla/[12]\.#; + $r .= qq() if $UA =~ m#Mozilla/[12]\.#; $r .= $fmt{form_input}->replace ($definition, $param); $r .= "
    \n" if $param->{output}->{form}; $r; } else { ## No input-interface WikiForm - qq(); + qq(); } - } else { - qq(@{[&Resource('Error:WikiForm:EmbedIsNotSupported',escape=>1)]}); - } + #} else { + # qq(@{[&Resource('Error:WikiForm:EmbedIsNotSupported',escape=>1)]}); + #} }} sub init_form { @@ -582,7 +601,7 @@ my $query = &decode($main::ENV{QUERY_STRING}); $query = &code_convert(\$query, $kanjicode); $form{mypage} = $query; - $form{mycmd} = $database{$form{mypage}} ? 'read' : 'edit'; + $form{mycmd} = 'default'; } else { for (split /[;&]/, $query) { if (my ($n, $v) = split /=/, $_, 2) { @@ -597,7 +616,7 @@ } $form{mypage} ||= $PageName{FrontPage}; $form{mypage} =~ tr/\x00-\x1F\x7F//d; - $form{mycmd} ||= 'read'; + $form{mycmd} ||= 'default'; # mypreview_edit -> do_edit, with preview. # mypreview_adminedit -> do_adminedit, with preview. @@ -620,25 +639,27 @@ $form{myname} = &code_convert(\$form{myname}, $kanjicode); } -{my %SubjectLine; sub get_subjectline { my ($page, %option) = @_; - unless (defined $SubjectLine{$page}) { + my $SubjectLine = SuikaWiki::Plugin->cache ('headline'); + unless (defined $SubjectLine->{$page}) { if (not &is_editable($page)) { - $SubjectLine{$page} = ""; + $SubjectLine->{$page} = ""; } else { - $SubjectLine{$page} = $database{$page}; - $SubjectLine{$page} =~ s!^\#\?[^\x0A\x0D]+[\x0A\x0D]*!!s; - $SubjectLine{$page} =~ s/\x0D?\x0A.*//s; + $SubjectLine->{$page} = do { + my $s=$database{$page}; + $s =~ s!^\#\?[^\x0A\x0D]+[\x0A\x0D]*!!s; + $s =~ s/\x0D?\x0A.*//s; + $s}; } } - if (length $SubjectLine{$page}) { + if (length $SubjectLine->{$page}) { $option{delimiter} = defined $option{delimiter} ? $option{delimiter} : &Resource('Title-Summary Delimiter'); - $option{delimiter}.$SubjectLine{$page}.$option{tail}; + $option{delimiter}.$SubjectLine->{$page}.$option{tail}; } else { ''; } -}} +} sub open_db { if ($modifier_dbtype eq 'dbmopen') { @@ -673,7 +694,7 @@ my $magic = ''; $magic = $1 if $option{content} =~ m/^([^\x0A\x0D]+)/s; - my $selected = 'read'; + my $selected = 'default'; if ($form{after_edit_cmd}) { $selected = $form{after_edit_cmd}; } elsif ($magic =~ /Const|Config|CSS/) { @@ -681,6 +702,7 @@ } my $afteredit = < + @@ -805,9 +827,9 @@ $form{mymsg} = $content; $form{mytouch} = 'on'; &do_write; - } else { - $form{mycmd} = 'read'; - &do_read; + } else { ## Don't write + $form{mycmd} = 'default'; + &do_view; } } @@ -840,7 +862,7 @@ } else { return <<"EOD";
    - + @{[&Resource('WikiForm:WikiComment:Name=',escape=>1)]} @@ -853,19 +875,19 @@ } elsif ($embedded =~ /^\[\[\#embed:(.+)\]\]$/) { my ($name, $r) = ($1, ''); if ($main::_EMBEDED != 1) { - my ($content, $cf) = ($database{$name}, 'SuikaWiki/0.9'); - $cf = $1 if $content =~ s!^(?:[\#<]\?|/\*\s*)?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:[^0-9.][^\x0D\x0A]*)?)[\x0D\x0A]+!!s; - if ($cf =~ m!^(?:\#\?)?SuikaWiki/0.9(?:$|\s)!) { + my ($cf, $content) = SuikaWiki::Plugin->magic_and_conten ($database{$name}); + $cf ||= '#?SuikaWiki/0.9'; + if ($cf =~ m!^#\?SuikaWiki/0.9(?:$|\s)!) { $main::_EMBEDED = 1; - $r = &text_to_html ($content, content_format => $cf); + $r = &text_to_html ($content, magic => $cf, page => $name); $main::_EMBEDED = 0; } elsif (length $content) { $r = "
    @{[&escape ($content)]}
    "; } else { - $r = &text_to_html ("[INS[\n[[$name]]: @{[&Resource('Embed:PageNotFound')]}\n]INS]\n", content_format => 'SuikaWiki/0.9'); + $r = &text_to_html ("[INS[\n[[$name]]: @{[&Resource('Embed:PageNotFound')]}\n]INS]\n", magic => '#?SuikaWiki/0.9'); } } else { ## nested #EMBED - $r = &text_to_html ("[INS[\n[[$name]]: @{[&Resource('Embed:Nested',escape=>1)]}\n]INS]\n", content_format => 'SuikaWiki/0.9'); + $r = &text_to_html ("[INS[\n[[$name]]: @{[&Resource('Embed:Nested',escape=>1)]}\n]INS]\n", magic => '#?SuikaWiki/0.9'); } return qq(
    $r
    ); } elsif ($embedded =~ /^\[\[\#randomlink:(.+)\]\]$/) { @@ -899,7 +921,7 @@ || $i == $form{wikiform_index}) { $template =~ s/\\(.)/$1/g; $option =~ s/\\(.)/$1/g; - my $param = bless {}, 'SuikaWiki::Plugin'; + my $param = bless {depth=>10}, 'SuikaWiki::Plugin'; $param->{page} = $form{mypage}; $param->{form_index} = $i; $param->{form_name} = $wfname; @@ -909,7 +931,7 @@ $param->{default_name} ||= &Resource('WikiForm:WikiComment:DefaultName'); $fmt{form_option}->replace ($option, $param); my $t = 1; - for (@{$param->{require}||[]}) { + for (keys %{$param->{require}||{}}) { (undef $t, last) unless length $param->{argv}->{'wikiform__'.$_}; } $t = $fmt{form_template}->replace ($template, $param) if $t; @@ -924,8 +946,8 @@ if $param->{anchor_index_}; ## $anchor is used! } $form{__wikiform_anchor_index} = $i; - undef $form{wikiform_targetform}; ## make sure never to match - undef $form{wikiform_index}; ## with WikiForm in rest of page + undef $form{wikiform_targetform}; ## Make sure never to match + undef $form{wikiform_index}; ## with WikiForm in rest of page! } $i++; $embed; }ge; @@ -938,9 +960,9 @@ $form{mymsg} = $content; $form{mytouch} = 'on'; &do_write; - } else { - $form{mycmd} = 'read'; - &do_read; + } else { ## Don't write! + $form{mycmd} = 'default'; + &do_view; } } @@ -960,9 +982,6 @@ sprintf '%04d-%02d-%02dT%02d:%02d:%02d+00:00', $time[5]+1900,$time[4]+1,@time[3,2,1,0]; } -sub is_exist_page { $use_exists ? exists ($database{$_[0]}) : $database{$_[0]} } -sub __get_database ($) { $database{ $_[0] } } - my %_Resource; sub Resource ($;%) { my ($s, %o) = @_; @@ -1058,7 +1077,7 @@ return unless $UseLog; $s =~ s/([\x00-\x08\x0A-\x1F\x25\x7F-\xFF])/sprintf '%%%02X', unpack 'C', $1/ge; my %ua; - for (split /\n/, &main::__get_database($main::PageName{UserAgentList})) { + for (split /\n/, $main::database{$main::PageName{UserAgentList}}) { if (/^-\[(\d+)\] (.+)$/) { my ($t, $n) = ($1, $2); $n =~ tr/\x0A\x0D//d; @@ -1080,6 +1099,7 @@ my $h = shift || {}; my $val; for my $line (split /\n/, $page) { + next if $line =~ /^#/; $line =~ tr/\x0A\x0D//d; if ($val && $line =~ s/^\s+//) { $h->{$val} .= length $h->{$val} ? "\n" . $line : $line; @@ -1096,9 +1116,7 @@ sub Yuki::YukiWikiDB2::meta (@) {undef} package SuikaWiki::Plugin; - our $plugin_directory; - our %List; - our %Index; + our ($plugin_directory, %List, %Index, %Cache); push @main::INC, $plugin_directory.'/../..'; sub escape ($$) { main::escape ($_[1]) } @@ -1124,6 +1142,15 @@ $main::fmt{format}->{($_[1]=~/([A-Za-z0-9]\S+)/?$1:'SuikaWiki/0.9').'_to_'.$_[2]} || $main::fmt{format}->{($_[1]=~/([A-Za-z0-9](?:(?!\/)\S)+)/?$1:'SuikaWiki').'_to_'.$_[2]}; } +sub cache ($$) { + my $name = $_[1]; + unless (ref $Cache{$name}) { + my %cache; + tie (%cache, 'Yuki::YukiWikiCache', -file => $main::PathTo{CachePrefix}.$name); + $Cache{$name} = \%cache; + } + $Cache{$name}; +} sub regist ($@) { my $pack = shift; @@ -1150,6 +1177,9 @@ sub get_accept_lang (;$) { my $alang = shift || $main::ENV{HTTP_ACCEPT_LANGUAGE}; my %alang = (ja => 0.0002, en => 0.0001); + if ($UA =~ m#Mozilla/0\.#) { + $alang{ja} = 0.00001; + } my $i = 0.1; for (split /\s*,\s*/, $alang) { tr/\x09\x0A\x0D\x20//d; @@ -1192,7 +1222,7 @@ __END__ =head1 NAME -wiki.cgi --- SuikaWiki: Yet yet another Wiki engine +wiki.cgi --- SuikaWiki: Yet yet another WikiEngine =head1 SEE ALSO