/[pub]/suikawiki/script/wiki.cgi
Suika

Diff of /suikawiki/script/wiki.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.31 by wakaba, Thu Nov 14 10:22:19 2002 UTC revision 1.36 by wakaba, Tue Dec 10 07:27:38 2002 UTC
# Line 26  use Yuki::DiffText qw(difftext); Line 26  use Yuki::DiffText qw(difftext);
26  use Yuki::YukiWikiDB;  use Yuki::YukiWikiDB;
27  use AnyDBM_File;  use AnyDBM_File;
28  require 'jcode.pl';  require 'jcode.pl';
29  # use Jcode;  require Jcode;
30  use Fcntl;  use Fcntl;
31  my $version = '2.0.beta1.2002-05-29';  my $version = '2.0.beta1.2002-05-29';
32  my $walversion;  my $walversion;
# Line 50  my $modifier_rss_description = 'This is Line 50  my $modifier_rss_description = 'This is
50  #  #
51  # You MAY modify following variables.  # You MAY modify following variables.
52  #  #
53    $SuikaWiki::Plugin::plugin_directory = q(./SuikaWiki/Plugin/);
54  my $file_touch = "$modifier_dir_data/touched.txt";  my $file_touch = "$modifier_dir_data/touched.txt";
55  my $file_resource = "$modifier_dir_data/resource.txt";  my $file_resource = "$modifier_dir_data/resource.txt";
56  my $file_FrontPage = "$modifier_dir_data/frontpage.txt";  my $file_FrontPage = "$modifier_dir_data/frontpage.txt";
# Line 97  my $DEFAULT_embed_comment_name = '名無し Line 98  my $DEFAULT_embed_comment_name = '名無し
98  my $embed_interwiki = '^\[\[#(box|text|password):(\S+)\]\]$';    # Walrus add (5)  my $embed_interwiki = '^\[\[#(box|text|password):(\S+)\]\]$';    # Walrus add (5)
99  my %embed_command = (  my %embed_command = (
100          searched        => '^\[\[#searched:([^\]]+)\]\]$',          searched        => '^\[\[#searched:([^\]]+)\]\]$',
101        form => qw/\[\[\#form(?:\(([A-Za-z0-9-]+)\))?:'((?:[^'\\]|\\.)*)':'((?:[^'\\]|\\.)*)'(?::'((?:[^'\\]|\\.)*)')?\]\]/,
102  );  );
103  ##############################  ##############################
104  my $info_LastModified = 'LastModified';  my $info_LastModified = 'LastModified';
# Line 116  my %fixedpage = ( Line 118  my %fixedpage = (
118      $AdminChangePassword => 1,      $AdminChangePassword => 1,
119      $CompletedSuccessfully => 1,      $CompletedSuccessfully => 1,
120      #$FrontPage => 1,      #$FrontPage => 1,
121        WikiUserAgentList => 1,
122        WikiPluginInfo    => 1,
123  );  );
124  my %form;  my %form;
125  my %database;  my %database;
# Line 131  my %page_command = ( Line 135  my %page_command = (
135      $RssPage => 'rss',      $RssPage => 'rss',
136      $AdminChangePassword => 'adminchangepasswordform',      $AdminChangePassword => 'adminchangepasswordform',
137      #$FrontPage => 'FrontPage',      #$FrontPage => 'FrontPage',
138        WikiPluginInfo       => 'x_WikiPluginInfo',
139  );  );
140  my %command_do = (  my %command_do = (
141      read => \&do_read,      read => \&do_read,
# Line 151  my %command_do = ( Line 156  my %command_do = (
156      rss => \&do_rss,      rss => \&do_rss,
157      diff => \&do_diff,      diff => \&do_diff,
158      interwikibox => \&do_interwiki_box, # Walrus add (5)      interwikibox => \&do_interwiki_box, # Walrus add (5)
159        wikiform => \&do_wikiform,
160        x_WikiPluginInfo  => \&do_wikiplugininfo,
161  );  );
162  ##############################  ##############################
 my @ignore_html_page = ('FrontPage');        # Walrus add (6)  
 my @ignore_html_tags = ('a', 'br', 'img');   # Walrus add (6)  
163  my $walversion = '2.0.beta1.wal.1';          # Walrus add (1)  my $walversion = '2.0.beta1.wal.1';          # Walrus add (1)
164  ##############################  ##############################
165  # &test_convert;  # &test_convert;
166  &main;  my $UA = '';  ## User agent name
 exit(0);  
167  ##############################  ##############################
168    
169  sub main {  sub main {
170        $UA = $main::ENV{HTTP_USER_AGENT};
171      &init_resource;      &init_resource;
172      &open_db;      &open_db;
173      &init_form;      &init_form;
# Line 179  sub do_read { Line 184  sub do_read {
184    my $content = $database{$form{mypage}};    my $content = $database{$form{mypage}};
185    my $lm = &get_info($form{mypage}, $info_LastModified);    my $lm = &get_info($form{mypage}, $info_LastModified);
186    wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER});    wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER});
187      wiki::useragent::add ($ENV{HTTP_USER_AGENT});
188    my ($r, $c) = get_search_result ($form{mypage});    my ($r, $c) = get_search_result ($form{mypage});
189    my $rl = wiki::referer::list_html ($form{mypage});    my $rl = wiki::referer::list_html ($form{mypage});
190    my @toc;    my @toc;
# Line 189  sub do_read { Line 195  sub do_read {
195      ## - 'SuikaWiki/0.9' CRLF      ## - 'SuikaWiki/0.9' CRLF
196      ## - 'H2H/' ("0.9" / "1.0" / "1.1") CRLF      ## - 'H2H/' ("0.9" / "1.0" / "1.1") CRLF
197      ## - "/*" WSP* 'W3C-CSS/' ("1.0" / "2.0") "*/" CRLF      ## - "/*" WSP* 'W3C-CSS/' ("1.0" / "2.0") "*/" CRLF
198      $cf = $1 if $content =~ s#^(?:/\*\s*|[\#<]\?)?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:[^0-9.][^\x0D\x0A]*)?)[\x0D\x0A]+##s;      $cf = $1 if $content =~ s#^(?:/\*\s*|[\#<]\?)?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:[^0-9.\x0D\x0A][^\x0D\x0A]*)?)[\x0D\x0A]+##s;
199      if ($cf =~ m!^(?:\#\?)?SuikaWiki/0.9(?:$|\s)!) {      if ($cf =~ m!^(?:\#\?)?SuikaWiki/0.9(?:$|\s)!) {
200        &print_header ($form{mypage}, -last_modified => $lm,        &print_header ($form{mypage}, -last_modified => $lm,
201          -content_format => $cf, -noindex => $cf =~ /obsoleted="yes"/);          -content_format => $cf, -noindex => $cf =~ /obsoleted="yes"/);
202        &print_content ($content, content_format => $cf, last_modified => $lm,        &print_content ($content, content_format => $cf, last_modified => $lm,
203          -toc => \@toc);          -toc => \@toc);
204        print &text_to_html (q([[#comment]])) unless $cf =~ /obsoleted="yes"/;        print &text_to_html (q([[#comment]])) if $cf !~ /obsoleted="yes"/ && !$fixedpage{$form{mypage}};
205      } else {      } else {
206        &print_header($form{mypage}, -last_modified => $lm);        &print_header($form{mypage}, -last_modified => $lm);
207        print "<pre>@{[&escape($content)]}</pre>";        print "<pre>@{[&escape($content)]}</pre>";
208      }      }
209      if ($c) {      if ($c) {
210        print q{<h2 id="wikipage-see-also">See also</h2>};        print qq{<h2 @{[&id_and_name('wikipage-see-also')]}>See also</h2>};
211        print $r;        print $r;
212      }      }
213      if ($rl) {      if ($rl) {
214        print qq(<div id="wikipage-referer"><h2>参照元</h2>\n$rl</div>\n);        print qq(<div @{[&id_and_name('wikipage-referer')]}><h2>参照元</h2>\n$rl</div>\n);
215      }      }
216    &print_footer($form{mypage}, $lm);    &print_footer($form{mypage}, $lm);
217  }  }
# Line 214  sub do_output_css { Line 220  sub do_output_css {
220    my $content = $database{$form{mypage}};    my $content = $database{$form{mypage}};
221    if ($content =~ m#^\s*/\*\s*W3C-CSS#) {    if ($content =~ m#^\s*/\*\s*W3C-CSS#) {
222      my $lm = &get_info($form{mypage}, $info_LastModified);      my $lm = &get_info($form{mypage}, $info_LastModified);
223          print scalar make_navigate_links ($form{mypage});
224      print "Content-Type: text/css; charset=$charset\n";      print "Content-Type: text/css; charset=$charset\n";
225      print "Last-Modified: $lm\n";      print "Last-Modified: $lm\n";
226      print "\n";      print "\n";
# Line 226  sub do_output_css { Line 233  sub do_output_css {
233    }    }
234  }  }
235    
236    sub id_and_name ($) {
237        my $name = shift;
238        if ($UA =~ m#Mozilla/[12]\.|Microsoft Internet Explorer#) {
239          qq{id="$name"><a name="$name"></a};
240        } else {
241            qq{id="$name"};
242        }
243    }
244    
245  sub do_edit {  sub do_edit {
246      my ($page) = &unarmor_name(&armor_name($form{mypage}));      my ($page) = &unarmor_name(&armor_name($form{mypage}));
247      &print_header($page, -noindex => 1);      &print_header($page, -noindex => 1);
# Line 237  sub do_edit { Line 253  sub do_edit {
253          &print_editform($database{$page}, &get_info($page, $info_LastModified), admin=>0);          &print_editform($database{$page}, &get_info($page, $info_LastModified), admin=>0);
254      }      }
255      wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER});      wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER});
256        wiki::useragent::add ($ENV{HTTP_USER_AGENT});
257      my ($r, $c) = get_search_result ($form{mypage});      my ($r, $c) = get_search_result ($form{mypage});
258      my $rl = wiki::referer::list_html ($form{mypage});      my $rl = wiki::referer::list_html ($form{mypage});
259      if ($c) {      if ($c) {
# Line 341  sub do_write { Line 358  sub do_write {
358              &update_recent_changes;              &update_recent_changes;
359          }          }
360          &set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen});          &set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen});
361          &print_header($CompletedSuccessfully, -noindex => 1, -goto => $url_cgi.'?'.&encode($form{mypage}).($form{__comment_anchor_index}?"#anchor-$form{__comment_anchor_index}":''));          my $fragment = '';
362            $fragment .= qq(;after_edit_cmd=@{[&encode($form{after_edit_cmd})]}) if $form{after_edit_cmd};
363            if ($form{__comment_anchor_index}) {
364                $fragment .= qq(#anchor-$form{__comment_anchor_index});
365            } elsif ($form{__wikiform_anchor_index}) {
366                $fragment .= qq(#wikiform-$form{__wikiform_anchor_index});
367            }
368            &print_header($CompletedSuccessfully, -noindex => 1, -goto => $url_cgi.'?mycmd='.&encode($form{after_edit_cmd}||'read').';mypage='.&encode($form{mypage}).qq(;x-param=@{[time.[0..9]->[rand 10]]}$fragment));
369          &print_message($resource{saved});          &print_message($resource{saved});
370          &print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}");          &print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}");
371          &print_footer($CompletedSuccessfully);          &print_footer($CompletedSuccessfully);
# Line 373  sub do_search { Line 397  sub do_search {
397  }  }
398    
399  sub get_search_result ($;%) {  sub get_search_result ($;%) {
400    my $word = shift;    my $word = lc shift;
401    my %option = @_;    my %option = @_;
402    my @r;    my @r;
403    foreach my $page (keys %database) {    foreach my $page (keys %database) {
# Line 382  sub get_search_result ($;%) { Line 406  sub get_search_result ($;%) {
406      my $cf = 'SuikaWiki/0.9';      my $cf = 'SuikaWiki/0.9';
407      $cf = $1 if $content =~ s/^\#\?([^\x0A\x0D]+)//s;      $cf = $1 if $content =~ s/^\#\?([^\x0A\x0D]+)//s;
408      next if $cf =~ /obsoleted="yes"/;      next if $cf =~ /obsoleted="yes"/;
409      if (index ($page, $word) > -1) {      if (index (lc $page, $word) > -1) {
410        my $c = $content =~ s/\Q$word\E/$word/g;        my $c = $content =~ s/\Q$word\E//gi;
411        push @r, [$page, $c+20];        push @r, [$page, $c+20];
412      } elsif (index ($word, $page) > -1) {      } elsif (index ($word, lc $page) > -1) {
413        my $c = $content =~ s/\Q$word\E/$word/g;        my $c = $content =~ s/\Q$word\E//gi;
414        push @r, [$page, $c+10];        push @r, [$page, $c+10];
415      } elsif (my $c = $content =~ s/\Q$word\E/$word/g) {      } elsif (my $c = $content =~ s/\Q$word\E//gi) {
416        push @r, [$page, $c];        push @r, [$page, $c];
417      }      }
418    }    }
419    my $em = sub { my $s = shift; $s =~ s#(\Q$word\E)#<em>$1</em>#g; $s };    my $em = sub { my $s = shift; $s =~ s#(\Q$word\E)#<em>$1</em>#gi; $s };
420    my $r = join "\n", map {qq(<li>[$_->[1]] <a href ="$url_cgi?@{[&encode($_->[0])]}" class="wiki">@{[&$em(&escape($_->[0]))]}</a> <span class="wikipage-summary">@{[&$em(&escape(&get_subjectline($_->[0])))]}</span></li>)} sort {$b->[1] <=> $a->[1] || $a->[0] cmp $b->[0]} @r;    my $r = join "\n", map {qq(<li>[$_->[1]] <a href ="$url_cgi?@{[&encode($_->[0])]}" class="wiki">@{[&$em(&escape($_->[0]))]}</a> <span class="wikipage-summary">@{[&$em(&escape(&get_subjectline($_->[0])))]}</span></li>)} sort {$b->[1] <=> $a->[1] || $a->[0] cmp $b->[0]} @r;
421    $r = qq|<ul class="search-result">$r</ul>| if $r;    $r = qq|<ul class="search-result">$r</ul>| if $r;
422    get_message ($resource{notfound}) if @r == 0 && $option{-output_not_found};    get_message ($resource{notfound}) if @r == 0 && $option{-output_not_found};
# Line 446  sub print_header ($;%) { Line 470  sub print_header ($;%) {
470          $bodyclass = "frozen";          $bodyclass = "frozen";
471      }      }
472      $bodyclass .= " wiki-page-obsoleted" if $option{-content_format} =~ /obsoleted="yes"/;      $bodyclass .= " wiki-page-obsoleted" if $option{-content_format} =~ /obsoleted="yes"/;
473      print qq{Refresh: 0; url="$option{-goto}"\n} if $option{-goto};      if ($option{-goto}) {
474          if ($UA =~ m#Opera|MSIE 2\.#) {
475              $option{-goto} =~ tr/;/&/ if $UA =~ m#Opera#;
476              print qq{Refresh: 0; url=$option{-goto}\n};
477              $option{-goto} = qq(<meta http-equiv="refresh" content="0; url=$option{-goto}">);
478          } else {
479              $option{-goto} =~ tr/;/&/ if $UA =~ m#Mozilla/[1-4]\.#;
480              print qq{Refresh: 0; url="$option{-goto}"\n};
481              $option{-goto} = qq(<meta http-equiv="refresh" content="0; url=&quot;@{[&escape($option{-goto})]}&quot;">);
482          }
483        }
484      print qq{Last-Modified: $option{-last_modified}\n} if $option{-last_modified};      print qq{Last-Modified: $option{-last_modified}\n} if $option{-last_modified};
485        my $meta_ct = '';
486        if ($UA =~ m#Mozilla/2#) {
487            $meta_ct = qq{text/html; charset=@{[&x_charset($charset)]}};
488            print qq{Content-Type: $meta_ct\n};
489            $meta_ct = qq{<meta http-equiv="content-type" content="$meta_ct">};
490        } elsif ($UA =~ m#Infomosaic#) {
491            print qq{Content-Type: text/html\n};
492        } else {
493            print qq{Content-Type: text/html; charset=$charset\n};
494        }
495      my $cookedpage = &encode($page);      my $cookedpage = &encode($page);
496      my $escapedpage = &escape($page);      my $escapedpage = &escape($page);
497        my ($Links, $links) = &make_navigate_links ($page);
498        print $Links;
499      print <<"EOD";      print <<"EOD";
 Content-type: text/html; charset=$charset  
500  Content-Language: $lang  Content-Language: $lang
501  Content-Style-Type: text/css  Content-Style-Type: text/css
502    
# Line 460  Content-Style-Type: text/css Line 505  Content-Style-Type: text/css
505      PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"      PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
506      "http://www.w3.org/TR/html4/loose.dtd"> + RUBY -->      "http://www.w3.org/TR/html4/loose.dtd"> + RUBY -->
507  <html lang="$lang">  <html lang="$lang">
508  <head>  <head profile="http://suika.fam.cx/~wakaba/-temp/wiki/wiki?WikiHTMLMetaProfile">
509        $meta_ct$option{-goto}
510      <title>$escapedpage</title>      <title>$escapedpage</title>
511      <link rel="index" href="$url_cgi?$IndexPage">      @{[($UA !~ m#Mozilla/[1-4]\.# || $UA =~ m#MSIE (?:[4-9]\.|\d\d)#) ? qq(<link rel="stylesheet" type="text/css" href="@{[&escape($url_stylesheet)]}">) : '']}
     <link rel="help" href="$url_cgi?WikiHelp">  
     <link rel="copyright" href="$url_cgi?$NAME_OF_WikiPageLicense">  
     <link rel="stylesheet" type="text/css" href="@{[&escape($url_stylesheet)]}">  
512      @{[$option{-noindex} ? q(<meta name="ROBOTS" content="NOINDEX">) : '']}      @{[$option{-noindex} ? q(<meta name="ROBOTS" content="NOINDEX">) : '']}
513    $links
514  </head>  </head>
515  <body class="$bodyclass">  <body class="$bodyclass">
516  EOD  EOD
# Line 476  EOD Line 520  EOD
520  EOD  EOD
521  }  }
522    
523    sub x_charset ($) {
524        my $charset = lc shift;
525        if ($charset eq 'euc-jp') {
526            $charset = 'x-euc-jp';
527        } elsif ($charset eq 'shift_jis') {
528            $charset = 'x-sjis';
529        }
530        $charset;
531    }
532    
533  sub print_navigate_links (@) {  sub print_navigate_links (@) {
534    my ($page) = @_;    my ($page) = @_;
535      my $editable = 0;      my $editable = 0;
# Line 501  sub print_navigate_links (@) { Line 555  sub print_navigate_links (@) {
555          qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedpage" accesskey="E">編集</a> | )          qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedpage" accesskey="E">編集</a> | )
556          : qq()          : qq()
557      ]}      ]}
558        <a href="$url_cgi?mycmd=read;mypage=$cookedpage;x-param=@{[time.[0..9]->[rand 10]]}">表示</a> |
559      @{[ $admineditable      @{[ $admineditable
560          ? qq(<a href="$url_cgi?mycmd=diff;mypage=$cookedpage">$resource{diffbutton}</a> | )          ? qq(<a href="$url_cgi?mycmd=diff;mypage=$cookedpage">$resource{diffbutton}</a> | )
561          : qq()          : qq()
# Line 513  sub print_navigate_links (@) { Line 568  sub print_navigate_links (@) {
568      <a href="$url_cgi?$RecentChanges" class="wiki">最新</a>      <a href="$url_cgi?$RecentChanges" class="wiki">最新</a>
569  </div>  </div>
570  EOH  EOH
571  <<EOH;  ## temp  }
572      <a href="$url_cgi?$CreatePage" class="wiki">$resource{createbutton}</a> |  
573      <a href="$url_cgi?$IndexPage" class="wiki">$resource{indexbutton}</a> |  sub make_navigate_links ($) {
574  <!--    <a href="$url_cgi?$RssPage" class="wiki">$resource{rssbutton}</a> | -->      my $page = shift;
575      <a href="$url_cgi?$FrontPage" class="wiki">$FrontPage</a> |      my @link;
576      <a href="$url_cgi?$SearchPage" class="wiki">$resource{searchbutton}</a> |      push @link, {rel=>'edit', href=>"$url_cgi?mycmd=edit;mypage=@{[&encode($page)]}", class=>"wiki-command", title=>$resource{editbutton}} if &is_editable ($page) && !&is_frozen ($page);
577      <a href="$url_cgi?mycmd=RandomJump;x-param=@{[time.[0..9]->[rand 10]]}" class="wiki randomlink">どこか</a> |      push @link, {rel=>'edit', href=>"$url_cgi?mycmd=adminedit;mypage=@{[&encode($page)]}", class=>"wiki-command", title=>$resource{admineditbutton}} if &is_editable ($page) || &is_frozen ($page);
578      <a href="$url_cgi?$RecentChanges" class="wiki">$resource{recentchangesbutton}</a>      push @link, {rel=>'view', href=>"$url_cgi?mycmd=read;mypage=@{[&encode($page)]};x-p=@{[time.[0..9]->[rand 10]]}", class=>'wiki-command', title=>'View latest version of this page'};
579  </div>      push @link, {rel=>'myself', href=>"$url_cgi?@{[&encode($page)]}", class=>'wiki'};
580  EOH      push @link, {rel=>'index', href=>"$url_cgi?$IndexPage", class=>'wiki', title=>$resource{indexbutton}};
581        push @link, {rel=>'home', href=>"$url_cgi?$FrontPage", class=>'wiki', title=>$FrontPage};
582        push @link, {rel=>'News', href=>"$url_cgi?WikiNews", class=>'wiki', title=>'News on this wiki'};
583        push @link, {rel=>'News', href=>"$url_cgi?$RecentChanges", class=>"wiki", title=>$resource{recentchangesbutton}};
584        push @link, {rel=>'News', href=>"$url_cgi?$RssPage", class=>"wiki", title=>$resource{rssbutton}, type=>'application/xml'};
585        push @link, {rel=>'search', href=>"$url_cgi?$SearchPage", class=>'wiki', title=>$resource{searchbutton}};
586        push @link, {rel=>'help', href=>"$url_cgi?WikiHelp", class=>'wiki'};
587        push @link, {rel=>'copyright', href=>"$url_cgi?WikiPageLicense", class=>'wiki'};
588        my ($Links, $links) = ('', '');
589        for my $e (@link) {
590            $links .= qq(<link);
591            $Links .= qq(Link: <$e->{href}>);
592            for my $attr (qw/rel rev href title class type hreflang charset/) {
593                $links .= qq( $attr="@{[&escape($e->{$attr})]}") if $e->{$attr};
594            }
595            for my $attr (qw/rel rev title/) {
596                $Links .= qq(; $attr="@{[do{$e->{$attr} =~ s/([\\\"])/\\$1/g; $e->{$attr}}]}") if $e->{$attr};
597            }
598            $links .= qq(>\n);
599            $Links .= qq(\n);
600        }
601        wantarray ? ($Links, $links) : $Links;
602  }  }
603    
604  sub print_footer {  sub print_footer {
605      my ($page, $lm) = @_;      my ($page, $lm) = @_;
606        my $epage = &encode ($page);
607      $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)
608      # Walrus mod (1) start      # Walrus mod (1) start
609    my $cvslog1 = q$Revision$;    my $cvslog1 = q$Revision$;
# Line 542  sub print_footer { Line 619  sub print_footer {
619  <a href="/map" title="このサーバーの案内">地図</a>  <a href="/map" title="このサーバーの案内">地図</a>
620  <a href="/search/" title="このサーバーの検索">検索</a>]  <a href="/search/" title="このサーバーの検索">検索</a>]
621  </div>  </div>
622    <div class="myuri">
623        &lt;<a href="$url_cgi?$epage">$url_cgi?$epage</a>&gt;
624    </div>
625  </div>  </div>
626  $walrus_log  $walrus_log
627  </body>  </body>
628  </html>  </html>
629  EOD  EOD
 #       print <<"EOD";  
 #   <hr>  
 #   <address class="footer">  
 #       <a href="http://www.hyuki.com/yukiwiki/">YukiWiki</a> $version  
 #       &copy; 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  
630  }  }
631    
632  sub escape {  sub escape {
# Line 601  sub text_to_html { Line 667  sub text_to_html {
667          chomp;          chomp;
668          if (/^\*\*\*\*\*([^\x0D\x0A]*)/) {          if (/^\*\*\*\*\*([^\x0D\x0A]*)/) {
669              push(@toc, qq(----- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));              push(@toc, qq(----- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
670              push(@result, splice(@saved), qq(<h6 id="i$tocnum">) . &inline($1) . '</h6>');              push(@result, splice(@saved), qq(<h6 @{[&id_and_name("i$tocnum")]}>) . &inline($1) . '</h6>');
671              $tocnum++;              $tocnum++;
672          } elsif (/^\*\*\*\*([^\x0D\x0A]*)/) {          } elsif (/^\*\*\*\*([^\x0D\x0A]*)/) {
673              push(@toc, qq(---- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));              push(@toc, qq(---- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
674              push(@result, splice(@saved), qq(<h5 id="i$tocnum">) . &inline($1) . '</h5>');              push(@result, splice(@saved), qq(<h5 @{[&id_and_name("i$tocnum")]}>) . &inline($1) . '</h5>');
675              $tocnum++;              $tocnum++;
676          } elsif (/^\*\*\*([^\x0D\x0A]*)/) {          } elsif (/^\*\*\*([^\x0D\x0A]*)/) {
677              push(@toc, qq(--- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));              push(@toc, qq(--- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
678              push(@result, splice(@saved), qq(<h4 id="i$tocnum">) . &inline($1) . '</h4>');              push(@result, splice(@saved), qq(<h4 @{[&id_and_name("i$tocnum")]}>) . &inline($1) . '</h4>');
679              $tocnum++;              $tocnum++;
680          } elsif (/^\*\*([^\x0D\x0A]*)/) {          } elsif (/^\*\*([^\x0D\x0A]*)/) {
681          # if (/^\*\*(.*)/) {          # if (/^\*\*(.*)/) {
682          # Walrus mod (6) end          # Walrus mod (6) end
683              push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));              push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
684              push(@result, splice(@saved), qq(<h3><a name="i$tocnum"> </a>) . &inline($1) . '</h3>');              push(@result, splice(@saved), qq(<h3 @{[&id_and_name("i$tocnum")]}>) . &inline($1) . '</h3>');
685              $tocnum++;              $tocnum++;
686          } elsif (/^\*([^\x0D\x0A]*)/) {          } elsif (/^\*([^\x0D\x0A]*)/) {
687              push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));              push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
688              push(@result, splice(@saved), qq(<h2><a name="i$tocnum"> </a>) . &inline($1) . '</h2>');              push(@result, splice(@saved), qq(<h2 @{[&id_and_name("i$tocnum")]}>) . &inline($1) . '</h2>');
689              $tocnum++;              $tocnum++;
690          } elsif (/^(={1,6})(.*)/) {          } elsif (/^(={1,6})(.*)/) {
691              &back_push('ol', length($1), \@saved, \@result);              &back_push('ol', length($1), \@saved, \@result);
# Line 727  sub back_push { Line 793  sub back_push {
793  sub inline {  sub inline {
794      my ($line) = @_;      my ($line) = @_;
795      $line = &escape($line);      $line = &escape($line);
796      $line =~ s{\[(INS|DEL|SUP|SUB|VAR|CODE|KBD)(?:\(([A-Za-z0-9\x20-]+)\))?\[(.+?)\]\]}{<@{[lc $1]}@{[$2 ? qq( class="$2") : '']}>$3</@{[lc $1]}>}g;      $line =~ s{$embed_command{form}}{&make_custom_form ($1, $2, $3, $4)}ge;
797        $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;
798      $line =~ s:\[(WEAK)\[(.+?)\]\]:<span class="@{[lc $1]}">$2</span>:g;      $line =~ s:\[(WEAK)\[(.+?)\]\]:<span class="@{[lc $1]}">$2</span>:g;
799      $line =~ s:\[ABBR\[([^]]+)\] \[([^]]+)\]\]:<acronym title="$2">$1</acronym>:g;      $line =~ s:\[ABBR\[([^]]+)\] \[([^]]+)\]\]:<acronym title="$2">$1</acronym>:g;
800      $line =~ s:\[RUBYB\[([^]]+)\] \[([^]]+)\] \[([^]]+)\]\]:<span class="ruby"><ruby class="rb"><rb>$1</rb><rp>(</rp><rt>$2</rt><rp>)</rp></ruby><span class="rp"> (</span><span class="rt-below">$3</span><span class="rp">) </span></span>:g;      $line =~ s:\[RUBYB\[([^]]+)\] \[([^]]+)\] \[([^]]+)\]\]:<span class="ruby"><ruby class="rb"><rb>$1</rb><rp>(</rp><rt>$2</rt><rp>)</rp></ruby><span class="rp"> (</span><span class="rt-below">$3</span><span class="rp">) </span></span>:g;
# Line 784  sub make_urilink ($;%) { Line 851  sub make_urilink ($;%) {
851        if ($interwiki{$site}) {        if ($interwiki{$site}) {
852          my $uri = &escape ($fmt{interwiki}->replace ($interwiki{$site} => {site => $site, name => $name}));          my $uri = &escape ($fmt{interwiki}->replace ($interwiki{$site} => {site => $site, name => $name}));
853          $site = &escape ($site); $name = &escape ($name);          $site = &escape ($site); $name = &escape ($name);
854          qq(&lt;<a href="$uri" class="out-of-wiki interwiki" title="$name ($site); URI: &lt;$uri&gt;">$name</a>&gt;);          qq(&lt;<a href="$uri" class="out-of-wiki interwiki" title="$name ($site); URI: &lt;$uri&gt;"><span class="interwiki-site">$site:</span><span class="interwiki-name">$name</span></a>&gt;);
855        } else {        } else {
856          qq(&lt;未登録の <a href="$url_cgi?InterWikiName" class="wiki">InterWikiName</a>: @{[&escape ($site)]}>);          qq(&lt;未登録の <a href="$url_cgi?InterWikiName" class="wiki">InterWikiName</a>: @{[&escape ($site)]}>);
857        }        }
# Line 808  sub make_urilink ($;%) { Line 875  sub make_urilink ($;%) {
875    }    }
876  }  }
877    
878    my $FormIndex = 0;
879    sub make_custom_form ($$$$) {
880        my ($wfname, $definition, $template, $option) = @_;
881        ## $template and $option is currently not used in this procedure.
882        unless ($main::_EMBEDED) {
883            $FormIndex++;
884            if (length $definition) {
885                my $param = bless {}, 'SuikaWiki::Plugin';
886                my $lastmodified = &get_info($form{mypage}, $info_LastModified);
887                &load_formatter (qw/form_input form_option/);
888                $definition = &unescape ($definition);
889                $definition =~ s/\\(.)/$1/g;
890                $definition .= ' %submit;' if $definition !~ /%submit/;
891                $option = &unescape ($option);
892                $option =~ s/\\(.)/$1/g;
893                $fmt{form_option}->replace ($option, $param);
894                my $target_page = $param->{output}->{page} || $form{mypage};
895                $param->{form_disabled} = 1 if $fixedpage{$target_page};
896                my $target_form = $param->{output}->{id};
897                my $r = <<EOH;
898    <form method="post" action="$url_cgi" id="wikiform-$FormIndex" class="wikiform">
899      <input type="hidden" name="mycmd" value="@{[$param->{form_disabled}?'read':'wikiform']}">
900      <input type="hidden" name="mypage" value="@{[&escape($target_page)]}">
901      <input type="hidden" name="myLastModified" value="$lastmodified">
902      <input type="hidden" name="mytouch" value="on">
903      <input type="hidden" name="@{[$target_form? qq(wikiform_targetform" value="@{[&escape($target_form)]}) : qq(wikiform_index" value="$FormIndex)]}">
904    EOH
905                $r .= qq(<a name="wikiform-$FormIndex"></a>) if $UA =~ m#Mozilla/[12]\.#;
906                $r .= $fmt{form_input}->replace ($definition, $param);
907                $r .= <<EOH;
908    </form>
909    EOH
910                $r;
911           } else {  ## No input-interface WikiForm
912               qq(<a id="wikiform-$FormIndex" name="wikiform-$FormIndex"><!-- #form --></a>);
913           }
914        } else {
915            q(<ins class="wiki-error"><strong>Warning</strong>: form in embeded page is currently not supported.</ins>);
916        }
917    }
918    
919  ## to be obsoleted  ## to be obsoleted
920  sub make_link {  sub make_link {
921      my $chunk = shift;      my $chunk = shift;
# Line 851  sub init_form { Line 959  sub init_form {
959              $form{$var} = param($var);              $form{$var} = param($var);
960        }        }
961      }      }
962      if ($main::ENV{QUERY_STRING} && $main::ENV{QUERY_STRING} !~ /[&;]/) {      $form{mypage} = &code_convert(\$form{mypage}, $kanjicode);
963        if ($main::ENV{QUERY_STRING} && $main::ENV{QUERY_STRING} !~ /[&;=]/) {
964        my $query = &decode($main::ENV{QUERY_STRING});        my $query = &decode($main::ENV{QUERY_STRING});
965          $query = &code_convert(\$query, $kanjicode);
966        if ($page_command{$query}) {        if ($page_command{$query}) {
967          $form{mycmd} = $page_command{$query};          $form{mycmd} = $page_command{$query};
968          $form{mypage} = $query;          $form{mypage} = $query;
# Line 862  sub init_form { Line 972  sub init_form {
972        }        }
973      }      }
974      $form{mypage} ||= 'HomePage';      $form{mypage} ||= 'HomePage';
975        $form{mycmd} ||= 'read';
976    
977      # mypreview_edit        -> do_edit, with preview.      # mypreview_edit        -> do_edit, with preview.
978      # mypreview_adminedit   -> do_adminedit, with preview.      # mypreview_adminedit   -> do_adminedit, with preview.
# Line 877  sub init_form { Line 988  sub init_form {
988      # $form{mycmd} is frozen here.      # $form{mycmd} is frozen here.
989      #      #
990    
991        for (grep /^wikiform__/, keys %form) {
992            $form{$_} = &code_convert (\$form{$_}, $kanjicode);
993        }
994      $form{mymsg} = &code_convert(\$form{mymsg}, $kanjicode);      $form{mymsg} = &code_convert(\$form{mymsg}, $kanjicode);
995      $form{myname} = &code_convert(\$form{myname}, $kanjicode);      $form{myname} = &code_convert(\$form{myname}, $kanjicode);
996  }  }
# Line 884  sub init_form { Line 998  sub init_form {
998  sub update_recent_changes {  sub update_recent_changes {
999      my $update = "- @{[&get_now]} [[@{[&escape($form{mypage})]}]] @{[&get_subjectline($form{mypage})]}";      my $update = "- @{[&get_now]} [[@{[&escape($form{mypage})]}]] @{[&get_subjectline($form{mypage})]}";
1000      my @oldupdates = split(/\r?\n/, $database{$RecentChanges});      my @oldupdates = split(/\r?\n/, $database{$RecentChanges});
1001        shift (@oldupdates); ## '#?' magic line
1002      my @updates;      my @updates;
1003      foreach (@oldupdates) {      foreach (@oldupdates) {
1004          /^\- \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+?)\]\]/;
# Line 896  sub update_recent_changes { Line 1011  sub update_recent_changes {
1011        unshift @updates, $update;        unshift @updates, $update;
1012      }      }
1013      splice(@updates, $maxrecent + 1);      splice(@updates, $maxrecent + 1);
1014      $database{$RecentChanges} = join("\n", @updates);      $database{$RecentChanges} = "#?SuikaWiki/0.9\n" . join("\n", @updates);
1015      if ($file_touch) {      if ($file_touch) {
1016          open(FILE, "> $file_touch");          open(FILE, "> $file_touch");
1017          print FILE localtime() . "\n";          print FILE localtime() . "\n";
# Line 1027  sub print_editform { Line 1142  sub print_editform {
1142      } else {      } else {
1143          $mymsg = &escape($mymsg || $database{NewPageTemplate});          $mymsg = &escape($mymsg || $database{NewPageTemplate});
1144      }      }
1145        my $magic = '';
1146        $magic = $1 if $mymsg =~ m/^([^\x0A\x0D]+)/s;
1147    
1148      my $edit = $mode{admin} ? 'adminedit' : 'edit';      my $edit = $mode{admin} ? 'adminedit' : 'edit';
1149      my $escapedmypage = &escape($form{mypage});      my $escapedmypage = &escape($form{mypage});
1150      my $escapedmypassword = &escape($form{mypassword});      my $escapedmypassword = &escape($form{mypassword});
1151        my $selected = 'read';
1152        if ($form{after_edit_cmd}) {
1153            $selected = $form{after_edit_cmd};
1154        } elsif ($magic =~ /Config/ || $magic =~ /CSS/) {
1155            $selected = 'edit';
1156        }
1157        my $afteredit = <<EOH;
1158    <select name="after_edit_cmd">
1159    <option value="read" label="View changed page"@{[$selected eq 'read' ? ' selected="selected"':'']}>read</option>
1160    <option value="edit" label="Edit changed page"@{[$selected eq 'edit' ? ' selected="selected"':'']}>edit</option>
1161    </select>
1162    EOH
1163    
1164      print <<"EOD";      print <<"EOD";
1165  <form action="$url_cgi" method="post">  <form action="$url_cgi" method="post">
1166  <h2>$escapedmypageの編集</h2>  <h2>$escapedmypageの編集</h2>
1167      @{[ $mode{admin} ? qq($resource{frozenpassword} <input type="password" name="mypassword" value="$escapedmypassword" size="10"><br>) : "" ]}      @{[ $mode{conflict} ? '' : qq(<input type="submit" name="mypreview_write" value="$resource{savebutton}"><kbd>S</kbd>) ]}
1168        @{[ $mode{admin} ? qq($resource{frozenpassword} <input type="password" name="mypassword" value="$escapedmypassword" size="10">) : "" ]} [@{[do {my $n = 0;
1169                   $mymsg =~ s/(?:-+\s)?\[([0-9]+)\]/$n = $1 if $1 > $n; $&/mge;
1170                   ++$n}]}]<br>
1171      <input type="hidden" name="myLastModified" value="$lastmodified">      <input type="hidden" name="myLastModified" value="$lastmodified">
1172      <input type="hidden" name="mypage" value="$escapedmypage">      <input type="hidden" name="mypage" value="$escapedmypage">
1173      <textarea cols="$cols" rows="$rows" name="mymsg" tabindex="1">$mymsg</textarea><br>      <textarea cols="$cols" rows="$rows" name="mymsg" tabindex="1">$mymsg</textarea><br>
# Line 1052  sub print_editform { Line 1184  sub print_editform {
1184          <input type="checkbox" name="mytouch" value="on" checked="checked">$resource{touch}<br>          <input type="checkbox" name="mytouch" value="on" checked="checked">$resource{touch}<br>
1185          <input type="submit" name="mypreview_$edit" value="$resource{previewbutton}">          <input type="submit" name="mypreview_$edit" value="$resource{previewbutton}">
1186          <input type="submit" name="mypreview_write" value="$resource{savebutton}" accesskey="S"><kbd>S</kbd>          <input type="submit" name="mypreview_write" value="$resource{savebutton}" accesskey="S"><kbd>S</kbd>
1187          [@{[do {my $n = 0;         $afteredit
1188                 $mymsg =~ s/(?:-+\s)?\[([0-9]+)\]/$n = $1 if $1 > $n; $&/mge;         <br>
                ++$n}]}]<br>  
1189      )      )
1190  ]}  ]}
1191  </form>  </form>
# Line 1133  sub encode { Line 1264  sub encode {
1264  sub init_resource {  sub init_resource {
1265      open(FILE, $file_resource) or &print_error("(resource)");      open(FILE, $file_resource) or &print_error("(resource)");
1266      while (<FILE>) {      while (<FILE>) {
1267          chomp;          s/[\x0A\x0D]+$//g;
1268          next if /^#/;          next if /^#/;
1269          my ($key, $value) = split(/=/, $_, 2);          my ($key, $value) = split(/=/, $_, 2);
1270          $resource{$key} = &code_convert(\$value, $kanjicode);          $resource{$key} = &code_convert(\$value, $kanjicode);
# Line 1184  sub init_InterWikiName { Line 1315  sub init_InterWikiName {
1315    $fmt{interwiki}->{encoded} = sub {    $fmt{interwiki}->{encoded} = sub {
1316      my ($o, $p) = @_;      my ($o, $p) = @_;
1317      if ($o->{except}) {      if ($o->{except}) {
1318        $o->{except} =~ tr/\x00-\x20<>\x23%\x22{|}\x5C^[]`\x7F-\xFF//d;        $o->{except} =~ tr/\x00-\x20\x22\x23%\x2D<>^[\x5C]`{|}\x7F-\xFF//d;
1319      }      }
1320      my $s = &code_convert (\$p->{name}, $o->{charset} || 'iso-2022-7bit');      my $s = &code_convert (\$p->{name}, $o->{charset} || 'iso-2022-7bit');
1321      $s =~ s/([^$o->{except}A-Za-z0-9_-])/sprintf '%02X', unpack 'C', $1/ge;      $s =~ s/([^$o->{except}A-Za-z0-9_-])/sprintf '%%%02X', unpack 'C', $1/ge;
1322      $s;      $s;
1323    };    };
1324    $fmt{interwiki}->{ykwk} = sub {       ## YukiWiki1    $fmt{interwiki}->{ykwk} = sub {       ## YukiWiki1
# Line 1262  sub do_comment { Line 1393  sub do_comment {
1393      } elsif (length $namestr) {      } elsif (length $namestr) {
1394        $namestr = qq( ''[[$namestr]]'': );        $namestr = qq( ''[[$namestr]]'': );
1395      }      }
1396      my $anchor = 0;      my $anchor = &get_new_anchor_index ($content);
     $content =~ s/(?:-+\s)?\[([0-9]+)\]/$anchor = $1 if $1 > $anchor; $&/mge;  
     $anchor++;  
1397      my $i = 1;  my $o = 0;      my $i = 1;  my $o = 0;
1398      $content =~ s{(\Q$embed_comment\E|\Q$embed_rcomment\E)}{      $content =~ s{(\Q$embed_comment\E|\Q$embed_rcomment\E)}{
1399        my $embed = $1;        my $embed = $1;
# Line 1293  sub do_comment { Line 1422  sub do_comment {
1422      }      }
1423  }  }
1424    
1425    sub get_new_anchor_index ($) {
1426        my $content = shift;
1427        my $anchor = 0;
1428        $content =~ s/^(?:[-=]+\s*)?\[([0-9]+)\]/$anchor = $1 if $1 > $anchor; $&/mge;
1429        $anchor + 1;
1430    }
1431    
1432  my $CommentIndex = 0;  my $CommentIndex = 0;
1433  sub embedded_to_html {  sub embedded_to_html {
1434      my ($embedded) = @_;      my ($embedded) = @_;
# Line 1356  EOD Line 1492  EOD
1492    }    }
1493  }  }
1494    
1495    sub load_formatter (@) {
1496        for my $t (@_) {
1497            unless ($fmt{$t}) {
1498                $fmt{$t} = Message::Util::Formatter->new;
1499                for (@{$SuikaWiki::Plugin::List{'wiki'.$t}||[]}) {
1500                    $_->load_formatter ($fmt{$t}, type => 'wiki'.$t);
1501                }
1502            }
1503        }
1504    }
1505    
1506    sub do_wikiform {
1507        my $content = $database{$form{mypage}};
1508        my $anchor = &get_new_anchor_index ($content);
1509        &load_formatter (qw/form_template form_option/);
1510        my $write = 0;
1511        my $i = 1;
1512        $content =~ s{$embed_command{form}}{
1513            my ($embed, $wfname, $template, $option) = ($&, $1, $3, $4);
1514            if (($wfname && $wfname eq $form{wikiform_targetform})
1515                || $i == $form{wikiform_index}) {
1516                $template =~ s/\\(.)/$1/g;
1517                $option =~ s/\\(.)/$1/g;
1518                my $param = bless {}, 'SuikaWiki::Plugin';
1519                $param->{page} = $form{mypage};
1520                $param->{form_index} = $i;
1521                $param->{form_name} = $wfname;
1522                $param->{anchor_index} = $anchor;
1523                $param->{argv} = \%form;
1524                $param->{default_name} = $1 if $content =~ /default-name="([^"]+)"/;
1525                $param->{default_name} ||= $DEFAULT_embed_comment_name;
1526                $fmt{form_option}->replace ($option, $param);
1527                my $t = 1;
1528                for (@{$param->{require}||[]}) {
1529                    (undef $t, last) unless length $param->{argv}->{'wikiform__'.$_};
1530                }
1531                $t = $fmt{form_template}->replace ($template, $param) if $t;
1532                if (length $t) {
1533                    if ($param->{output}->{reverse}) {
1534                        $embed .= "\n" . $t;
1535                    } else {
1536                        $embed = $t . "\n" . $embed;
1537                    }
1538                    $write = 1;
1539                    $form{__comment_anchor_index} = $anchor
1540                      if $param->{anchor_index_};  ## $anchor is used!
1541                }
1542                $form{__wikiform_anchor_index} = $i;
1543                undef $form{wikiform_targetform};  ## make sure never to match
1544                undef $form{wikiform_index};       ## with WikiForm in rest of page
1545            }
1546            $i++; $embed;
1547        }ge;
1548        unless ($write) {
1549          #$content = "#?SuikaWiki/0.9\n\n" unless $content;
1550          #$content .= "\n" unless $content =~ /\n$/s;
1551          #
1552        }
1553        if ($write) {
1554            $form{mymsg} = $content;
1555            $form{mytouch} = 'on';
1556            &do_write;
1557        } else {
1558            $form{mycmd} = 'read';
1559            &do_read;
1560        }
1561    }
1562    
1563    
1564  # Walrus add (5) start  # Walrus add (5) start
1565  sub do_interwiki_box {  sub do_interwiki_box {
1566      my $remoteurl = $interwiki{$form{'myintername'}};      my $remoteurl = $interwiki{$form{'myintername'}};
# Line 1397  sub code_convert { Line 1602  sub code_convert {
1602      $code = 'euc' if $code =~ /euc/;      $code = 'euc' if $code =~ /euc/;
1603      $code = 'sjis' if $code =~ /shift/;      $code = 'sjis' if $code =~ /shift/;
1604      $code = 'utf8' if $code =~ /utf/;      $code = 'utf8' if $code =~ /utf/;
1605  #   &Jcode::convert($contentref, $code);       # for Jcode.pm      &Jcode::convert($contentref, $code);       # for Jcode.pm
1606      &jcode::convert($contentref, $code);       # for jcode.pl  #    &jcode::convert($contentref, $code);       # for jcode.pl
1607        &jcode::tr ($contentref, "\xA3\xB0-\xA3\xB9\xA3\xC1-\xA3\xDA\xA3\xE1-\xA3\xFA\xA1\xF5\xA1\xA4\xA1\xA5\xA1\xA7\xA1\xA8\xA1\xA9\xA1\xAA\xA1\xAE\xA1\xB0\xA1\xB2\xA1\xBF\xA1\xC3\xA1\xCA\xA1\xCB\xA1\xCE\xA1\xCF\xA1\xD0\xA1\xD1\xA1\xDC\xA1\xF0\xA1\xF3\xA1\xF4\xA1\xF6\xA1\xF7\xA1\xE1\xA2\xAF\xA2\xB0\xA2\xB2\xA2\xB1\xA1\xE4\xA1\xE3\xA1\xC0\xA1\xA1" => q(0-9A-Za-z&,.:;?!`^_/|()[]{}+$%#*@='"~-><\ )) if $code eq 'euc';
1608      return $$contentref;      return $$contentref;
1609  }  }
1610    
# Line 1521  sub do_rss { Line 1727  sub do_rss {
1727          $count++;          $count++;
1728      }      }
1729      # print RSS information (as XML).      # print RSS information (as XML).
1730    print scalar &make_navigate_links ('RssPage');
1731      print <<"EOD"      print <<"EOD"
1732  Content-type: text/xml  Content-type: application/xml
1733    
1734  @{[$rss->as_string]}  @{[$rss->as_string]}
1735  EOD  EOD
# Line 1538  sub is_exist_page { Line 1745  sub is_exist_page {
1745  }  }
1746    
1747  sub __get_database ($) { $database{ $_[0] } }  sub __get_database ($) { $database{ $_[0] } }
1748    sub __set_database ($$) { $database{ $_[0] } = $_[1] }
1749    
1750    sub do_wikiplugininfo {
1751        &print_header (q(WikiPluginInfo));
1752        print text_to_html (&SuikaWiki::Plugin::make_info_page);
1753        &print_footer (q(WikiPluginInfo));
1754    }
1755    
1756  package wiki::referer;  package wiki::referer;
1757  sub add ($$) {  sub add ($$) {
# Line 1604  sub list_html ($) { Line 1818  sub list_html ($) {
1818      }      }
1819      my $euri = main::escape ($uri);      my $euri = main::escape ($uri);
1820      if ($title) {      if ($title) {
1821        $r .= qq(<li>[$list{$uri}] <a href="$euri" title="URI: &lt;$euri>">@{[main::escape ($title)]}</a></li>\n);        $r .= qq(<li>[$list{$uri}] <a href="$euri" title="URI: &lt;$euri&gt;">@{[main::escape ($title)]}</a></li>\n);
1822      } else {      } else {
1823        $r .= qq(<li>[$list{$uri}] &lt;<a href="$euri">$euri</a>&gt;</li>\n);        $r .= qq(<li>[$list{$uri}] &lt;<a href="$euri">$euri</a>&gt;</li>\n);
1824      }      }
# Line 1619  sub __decode ($) { Line 1833  sub __decode ($) {
1833    main::code_convert (\$s);    main::code_convert (\$s);
1834  }  }
1835    
1836    package wiki::useragent;
1837    
1838    sub add ($) {
1839      my $s = shift;
1840      return unless length $s;
1841      $s =~ s/([\x00-\x08\x0A-\x1F\x25\x7F-\xFF])/sprintf '%%%02X', unpack 'C', $1/g;
1842      my %ua;
1843      for (split /\n/, &main::__get_database('WikiUserAgentList')) {
1844        if (/^-\[(\d+)\] (.+)$/) {
1845          my ($t, $n) = ($1, $2);
1846          $n =~ tr/\x0A\x0D//d;
1847          $ua{$n} = $t;
1848        }
1849      }
1850      $ua{$s}++;
1851      my $s = qq(#?SuikaWiki/0.9\n);
1852      for (sort {$ua{$a} <=> $ua{$b}} keys %ua) {
1853        $s .= sprintf qq(-[%d] %s\n), $ua{$_}, $_;
1854      }
1855      &main::__set_database ('WikiUserAgentList' => $s);
1856    }
1857    
1858    package SuikaWiki::Plugin;
1859      our $plugin_directory;  # defined in top of this file.
1860      our %List;
1861    
1862    sub escape ($$) { main::escape ($_[1]) }
1863    sub unescape ($$) { main::unescape ($_[1]) }
1864    sub encode ($$) { main::encode ($_[1]) }
1865    sub decode ($$) { main::decode ($_[1]) }
1866    sub __get_datetime ($) { main::get_now () }
1867    
1868    sub regist ($@) {
1869        my $pack = shift;
1870        for (@_) {
1871            push @{$List{$_}}, $pack;
1872        }
1873    }
1874    
1875    sub import_plugins () {
1876        opendir PDIR, $plugin_directory;
1877        my @plugin = grep {s/\.pm$//} readdir (PDIR);
1878        closedir PDIR;
1879        for (@plugin) {
1880            eval qq{ use SuikaWiki::Plugin::$_ } unless /[^A-Za-z0-9_]/;
1881            push @{$List{_all}}, qq(SuikaWiki::Plugin::$_);
1882        }
1883    }
1884    
1885    sub make_info_page () {
1886        my $r = <<EOH;
1887    EOH
1888        unless ($List{_all}) {
1889            $r .= qq('''No plugin is installed!'''\n);
1890        } else {
1891            my $index = 0;
1892            for my $package (sort @{$List{_all}}) {
1893                $index++;
1894                my $prop = $package->property ();
1895                $r .= <<EOH;
1896    *$package
1897    
1898    [$index] '''$prop->{name}''' (Version $prop->{version})
1899    <$prop->{uri}>
1900    
1901    Provide:
1902    @{[do{my $t = ''; for my $f (@{$prop->{provide}||[]}) {
1903        $t .= qq(-''$f''\n);
1904        for (sort grep m#^\Q$f\E/#, keys %{$prop->{partinfo}}) {
1905             $t .= qq(--''$_'' -- $prop->{partinfo}->{$_}\n);
1906        }
1907    }$t}]}
1908    
1909    EOH
1910            }
1911        }
1912        $r;
1913    }
1914    
1915    &import_plugins ();
1916    
1917    package main;
1918    &main;
1919    exit 0;
1920    
1921  1;  1;
1922  __END__  __END__
1923  =head1 NAME  =head1 NAME

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.36

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24