/[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.1 by wakaba, Mon Feb 4 13:19:08 2002 UTC revision 1.46 by w, Thu Jan 2 12:14:15 2003 UTC
# Line 1  Line 1 
1  #!/usr/local/bin/perl  #!/usr/bin/perl
2  use lib "../lib";  # wiki.cgi - This is YukiWiki, yet another Wiki clone.
3  use CGI::Carp 'fatalsToBrowser';  #
4  use Algorithm::Diff qw(traverse_sequences);  # This program is free software; you can redistribute it and/or
5  # use strict;  # modify it under the same terms as Perl itself.
6  #  
7  # yukiwiki.cgi - Yet another WikiWikiWeb clone.  use strict;
8  #  use lib qw(./lib);
9  # Copyright (C) 2000,2001 by Hiroshi Yuki.  use CGI::Carp qw(fatalsToBrowser);
10  # <hyuki@hyuki.com>  our $VERSION = do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
11  # http://www.hyuki.com/yukiwiki/  
12  #  require 'wikidata/suikawiki-config.ph';
13  # This program is free software; you can redistribute it and/or modify  use Fcntl;
14  # it under the terms of the GNU General Public License as published by  ##############################
15  # the Free Software Foundation; either version 2 of the License, or  my %fmt;        ## formatter objects
16  # (at your option) any later version.  my %embed_command = (
17  #          searched        => '^\[\[#searched:([^\]]+)\]\]$',
18  # This program is distributed in the hope that it will be useful,          form    => qr/\[\[\#form(?:\(([A-Za-z0-9-]+)\))?:'((?:[^'\\]|\\.)*)':'((?:[^'\\]|\\.)*)'(?::'((?:[^'\\]|\\.)*)')?\]\]/,
19  # but WITHOUT ANY WARRANTY; without even the implied warranty of  );
20  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  our ($modifier_dbtype,$url_cgi,%uri,%PathTo,$use_exists);
21  # GNU General Public License for more details.  our (%PageName,$kanjicode,$lang,%FixedPage);
22  #  
23  # $Id$  ##############################
24  ##############################  my $info_LastModified = 'LastModified';
25  my $version = "1.6.6";  my $info_IsFrozen = 'IsFrozen';
26  ##############################  ##############################
27  # 単独テストのときには 1 にする。  my %form;
28  my $testing = 0;  our %database;
29  ##############################  our $database;
30  # 漢字ライブラリ  my %infobase;
31  my $jcodelib = 'jcode.pl';  my %interwiki;
32  ##############################  ##############################
33  # 保存・表示の漢字コード  my %page_command = (
34  my $kanjicode = 'sjis';     # 'sjis' 'euc'      $PageName{RssPage} => 'rss',
35  my $charset = 'Shift_JIS';  # 'Shift_JIS' 'EUC-JP'  );
36  ##############################  my %command_do = (
37  # dbmopenが使えるなら1、使えないなら0      read => \&do_read,
38  my $dbmopen = 0;      TEXT_CSS => \&do_output_css,
39  ##############################      edit => \&do_edit,
40  # データベース名(.pag, .dir, .dbなどは不要)      adminedit => \&do_adminedit,
41  # $dbmopen = 1のときはデータベース名、      adminchangepassword => \&do_adminchangepassword,
42  # $dbmopen = 0のときはディレクトリ名になる。      write => \&do_write,
43  my $dbname = './yukiwiki';      searchform => \&do_searchform,
44  my $diffdbname = './yukidiff';      comment => \&do_comment,
45  ##############################      RandomJump  => \&do_random_jump,
46  # 修正者の氏名(自由に変更してください)      rss => \&do_rss,
47  my $modifier = 'Hiroshi Yuki';      diff => \&do_diff,
48  ##############################      wikiform    => \&do_wikiform,
49  # 修正者のWebページ(自由に変更してください)      map => \&do_map,
50  my $modifierlink = 'http://www.hyuki.com/';  );
51  ##############################  my $UA = '';  ## User agent name
52  # このページのURL  $| = 1;
53  my $thisurl = 'yukiwiki.cgi';  ##############################
54  ##############################  
55  # 開始ページ名  sub main {
56  my $toppage = 'FrontPage';      $UA = $main::ENV{HTTP_USER_AGENT};
57  ##############################      &open_db;
58  # 最終更新ページ名      &init_form;
59  my $whatsnew = 'RecentChanges';      if ($command_do{$form{mycmd}}) {
60  ##############################          &{$command_do{$form{mycmd}}};
61  # 最終更新に掲載するページ数      } else {
62  my $maxnew = 50;          &{$command_do{read}};
63  ##############################      }
64  # アイコンファイル名(カラー版)      &close_db;
65  my $iconfile = 'yukiwiki.gif';  }
66  ##############################  
67  # アイコンファイル名(モノクロ版)  sub do_read {
68  # my $iconfile = 'yukimono.gif';    my $content = $database{$form{mypage}};
69  ##############################    #print "content-type:text/plain;charset=euc-jp\n\n".gmtime."Get Lastmodified\n";
70  # ページを変更したときにtouchするファイル(''なら何もしない)    my $lm = &get_info($form{mypage}, $info_LastModified);
71  my $touchfile = 'touch.txt';    wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER});
72  ##############################    wiki::useragent::add ($ENV{HTTP_USER_AGENT});
73  # プレビュー用の背景色    #print gmtime."Search...\n";
74  my $preview_color = '#FFCCCC';    my ($r, $c) = get_search_result ($form{mypage});
75  ##############################    my $rl = wiki::referer::list_html ($form{mypage});
76  # 全ページのスタイル    my @toc;
77  my $style = <<'EOD';    push @toc, qq(-<a href="#wikipage-see-also">@{[&Resource('SeeAlso',escape=>1)]}</a>) if $c;
78  pre, dl, ul, ol, p, blockquote { line-height:120%; }    push @toc, qq(-<a href="#wikipage-referer">@{[&Resource('Referers',escape=>1)]}</a>) if $rl;
79  a { text-decoration: none; }      my $cf = 'SuikaWiki/0.9';
80  a:link { color: #0000FF; background-color: #FFFFFF; }      ## Should be support at least:
81  a:visited { color: #9900CC; background-color: #FFFFFF; }      ## - 'SuikaWiki/0.9' CRLF
82  a:hover { text-decoration: underline; }      ## - 'H2H/' ("0.9" / "1.0" / "1.1") CRLF
83  EOD      ## - "/*" WSP* 'W3C-CSS/' ("1.0" / "2.0") "*/" CRLF
84  ##############################      $cf = $1 if $content =~ s#^(?:/\*\s*|[\#<]\?)?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:[^0-9.\x0D\x0A][^\x0D\x0A]*)?)[\x0D\x0A]+##s;
85  # テキスト入力部分の大きさ      if ($cf =~ m!^(?:\#\?)?SuikaWiki/0.9(?:$|\s)!) {
86  my $cols = 80;      #print gmtime."Header...\n";
87  my $rows = 20;        &print_header ($form{mypage}, -last_modified => $lm, -expires => time + 120,
88  ##############################          -content_format => $cf, -noindex => ($cf =~ /obsoleted="yes"/ ? 1 : 0));
89  my %form = ();          #print "\n". gmtime."Body...\n";
90  my %database = ();        &print_content ($content, content_format => $cf, last_modified => $lm,
91  my %diffbase = ();          -toc => \@toc);
92  my $diff_text = '';        print &text_to_html (q([[#comment]])) if $cf !~ /obsoleted="yes"/ && !$FixedPage{$form{mypage}};
93  my @diff_added = ();      } else {
94  my @diff_deleted = ();        &print_header($form{mypage}, -expires => time + 120, -last_modified => $lm);
95  my $msgrefA;        print "<pre>@{[&escape($content)]}</pre>";
96  my $msgrefB;      }
97  ##############################      if ($c) {
98  # 編集不可ページ名一覧        print qq{<h2 @{[&id_and_name('wikipage-see-also')]}>@{[&Resource('SeeAlso',escape=>1)]}</h2>};
99  my @uneditable = ( $whatsnew );        print $r;
100  ##############################      }
101  # リンク用の正規表現      if ($rl) {
102  # YukiWikiのリンクは2種類ある。        print qq(<div @{[&id_and_name('wikipage-referer')]}><h2>@{[&Resource('Referers',escape=>1)]}</h2>\n$rl</div>\n);
103  #      }
104  # (1) WikiName (RecentChangesとかFrontPageのようなもの)          #print "\n". gmtime."Footer...\n";
105  # (2) BracketName ([[結城浩]]とか[[トラブルシュート]]のようなもの)    &print_footer($form{mypage}, $lm);
106  #          #print "\n". gmtime."Fin...\n";
107  # ※シフトJISの2バイト目には ']' が来うるので、  }
108  # 文字']'を1つ多くとるようにしている。  
109  #  sub do_output_css {
110  my $WikiName = '([A-Z][a-z]+([A-Z][a-z]+)+)';    wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER});
111  my $BracketName = '\[\[([^>\s]+?\]?)\]\]';    wiki::useragent::add ($ENV{HTTP_USER_AGENT});
112      my $content = $database{$form{mypage}};
113  # アイコン部分のタグ    if ($content =~ m#^\s*/\*\s*W3C-CSS#) {
114  my $IconTag = <<"EOD";      my $lm = gmtime &get_info($form{mypage}, $info_LastModified);
115  <a href="http://www.hyuki.com/yukiwiki/"><img src="$iconfile"      print "Content-Type: text/css; charset=@{[&get_charset_name($kanjicode)]}\n";
116   border="0" width="80" height="80" alt="[YukiWiki]" /></a>      print "Last-Modified: $lm\n";
117  EOD      print "Expires: @{[scalar gmtime time+3600]}\n";    ## TODO: don't use asctime
118        print "\n";
119  require "$jcodelib";      print $content;
120      } else {
121  &init_form($kanjicode);      print "Status: 406 Unsupported Media Type\n";
122        &print_header('WikiPageIsNotCSS', -noindex => 1);
123  if ($testing) {      &print_content($database{WikiPageIsNotCSS});
124      %form = (      &print_footer('WikiPageIsNotCSS');
125          # 'mycmd' => 'write',    }
126          'mycmd' => 'read',  }
127          #'mycmd' => 'search',  
128          #'mycmd' => 'edit',  sub id_and_name ($) {
129          'mymsg' => <<"EOD",      my $name = shift;
130  はじめまして。      if ($UA =~ m#Mozilla/[12]\.|Microsoft Internet Explorer#) {
131  これからいろいろ書き込みますね。        qq{id="$name"><a name="$name"></a};
132  LinkPageも見てください。      } else {
133  TestPageはどうでしょうか。          qq{id="$name"};
134  どうぞよろしく。      }
135  http://www.hyuki.com/  }
136  [[結城浩]]  
137  EOD  sub do_edit {
138          'mypage' => '<結城浩>',      my ($page) = &unarmor_name(&armor_name($form{mypage}));
139          'myword' => '結',      if (not &is_editable($page)) {
140          # '3C8C8B8FE98D5F3E' => '',          &print_header($page, -noindex => 1, -expires => time+60);
141          # 'TestPage' => '',          &print_message(&Resource('Error:ThisPageIsUneditable'));
142      );      } elsif (&is_frozen($page)) {
143  }          &print_header($page, -noindex => 1, -expires => time+60);
144  &main;          &print_message(&Resource('Error:ThisPageIsUneditable'));
145  exit(0);      } else {
146            &print_header($page, -noindex => 1, -expires => time+60);
147  # メイン          &print_editform($database{$page}, &get_info($page, $info_LastModified), admin=>0);
148  sub main {      }
149      &normalize_form;      wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER});
150      if ($dbmopen) {      wiki::useragent::add ($ENV{HTTP_USER_AGENT});
151          if (!dbmopen(%database, $dbname, 0666)) {      my ($r, $c) = get_search_result ($form{mypage});
152              &print_error("(dbmopen) $dbname が作れません。");      my $rl = wiki::referer::list_html ($form{mypage});
153          }      if ($c) {
154      } else {        print qq{<h2 id="wikipage-see-also">@{[&Resource('SeeAlso',escape=>1)]}</h2>};
155          if (!tie(%database, "YukiWikiDB", $dbname)) {        print $r;
156              &print_error("(tie error)");      }
157          }      if ($rl) {
158      }        print qq(<div id="wikipage-referer"><h2>@{[&Resource('Referers',escape=>1)]}</h2>\n$rl</div>\n);
159        }
160      # myspecial対応      &print_footer($page);
161      foreach (keys %form) {  }
162          if (/^myspecial_(.*)/) {  
163              $form{mycmd} = $1;  sub do_adminedit {
164              last;      my ($page) = &unarmor_name(&armor_name($form{mypage}));
165          }      &print_header($page, -noindex => 1, -expires => time+60);
166      }      if (not &is_editable($page)) {
167            &print_message(&Resource('Error:ThisPageIsUneditable'));
168      if ($form{mycmd} eq 'read') {      } else {
169          &do_read;          &print_message(&Resource('Error:PasswordIsNotSpecified'));
170      } elsif ($form{mycmd} eq 'preview') {          &print_editform($database{$page}, &get_info($page, $info_LastModified), admin=>1);
171          &do_preview;      }
172      } elsif ($form{mycmd} eq 'write') {      &print_footer($page);
173          &do_write;  }
174      } elsif ($form{mycmd} eq 'edit') {  
175          &do_edit;  sub do_adminchangepassword {
176      } elsif ($form{mycmd} eq 'reedit') {      if ($form{mynewpassword} ne $form{mynewpassword2}) {
177          &do_reedit;          &print_error(&Resource('Error:PasswordMismatch'));
178      } elsif ($form{mycmd} eq 'search') {      }
179          &do_search;      my ($validpassword_crypt) = &get_info($PageName{AdminSpecialPage}, 'AdminPassword');
180      } elsif ($form{mycmd} eq 'list') {      if ($validpassword_crypt) {
181          &do_list;          if (not &valid_password($form{myoldpassword})) {
182      } elsif ($form{mycmd} eq 'diff') {              &print_error(&Resource('Error:PasswordIsIncorrect'));
183          &do_diff;          }
184      } else {      }
185          $form{mypage} = $toppage;      my ($sec, $min, $hour, $day, $mon, $year, $weekday) = localtime(time);
186          &do_read;      my (@token) = ('0'..'9', 'A'..'Z', 'a'..'z');
187      }      my $salt1 = $token[(time | $$) % scalar(@token)];
188      if ($dbmopen) {      my $salt2 = $token[($sec + $min*60 + $hour*60*60) % scalar(@token)];
189          dbmclose(%database);      my $crypted = crypt($form{mynewpassword}, "$salt1$salt2");
190      } else {      &set_info($PageName{AdminSpecialPage}, 'AdminPassword', $crypted);
191          untie(%database);  
192      }      &print_header('CompletedSuccessfully', -noindex => 1);
193  }      &print_message(&Resource('Error:PasswordIsChanged'));
194        &print_footer('CompletedSuccessfully');
195  # ページの表示  }
196  sub do_read {  
197      my $page_name = $form{mypage};  sub valid_password ($) {
198      my $percent_name = &encode_percent($page_name);      my ($validpassword_crypt) = &get_info($PageName{AdminSpecialPage}, 'AdminPassword');
199      &print_header($page_name);      return crypt (shift, $validpassword_crypt) eq $validpassword_crypt ? 1 : 0;
200      print qq|<h1>$IconTag<a href="$thisurl?mycmd=search&myword=$percent_name">$page_name</a></h1>\n|;  }
201      &print_toolbar($page_name);  
202      print &convert_html(&get_page($page_name));  sub do_write {
203      &print_footer;      if (&frozen_reject()) {
204  }          return;
205        }
206  # ページの編集  
207  sub do_edit {      if (not &is_editable($form{mypage})) {
208      if (not &is_editable($form{mypage})) {          &print_header($form{mypage}, -noindex => 1);
209          # 編集不可ページは表示のみ          &print_message(&Resource('Error:ThisPageIsUneditable'));
210          &do_read;          &print_footer($form{mypage});
211          return;          return;
212      }      }
213      &editpage(&get_page($form{mypage}));  
214  }      if (&conflict($form{mypage}, $form{mymsg})) {
215            return;
216  # ページの再編集      }
217  sub do_reedit {  
218      if (not &is_editable($form{mypage})) {      if ($form{mymsg}) {
219          # 編集不可ページは表示のみ          if ($form{mytouch} || !ref $database) {
220          &do_read;            $database{$form{mypage}} = $form{mymsg};
221      } else {          } else {
222          &editpage($form{mymsg});            $database->STORE ($form{mypage} => $form{mymsg}, -touch => 0);
223      }          }
224  }          &set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen});
225            my $fragment = '';
226  sub editpage {          $fragment .= qq(;after_edit_cmd=@{[&encode($form{after_edit_cmd})]}) if $form{after_edit_cmd};
227      my $page_msg = shift;          if ($form{__comment_anchor_index}) {
228      my $page_name = $form{mypage};              $fragment .= qq(#anchor-$form{__comment_anchor_index});
229      my $digest = &calc_message_digest($page_msg);          } elsif ($form{__wikiform_anchor_index}) {
230      &print_header($page_name);              $fragment .= qq(#wikiform-$form{__wikiform_anchor_index});
231      print qq|<h1>$IconTag${page_name}の編集</h1>\n|;          }
232      &print_toolbar($page_name);          &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));
233      $page_msg = &escape($page_msg);          &print_message(&Resource('Error:SavedSuccessfully'));
234      print <<"EOD";          &print_content(&Resource('Error:ContinueReading')." @{[&armor_name($form{mypage})]}");
235  <form action="$thisurl" method="post">          &print_footer('CompletedSuccessfully');
236  <input type="hidden" name="mycmd" value="preview">      } else {
237  <input type="hidden" name="mypage" value="$page_name">          delete $database{$form{mypage}};
238  <input type="hidden" name="mydigest" value="$digest">          delete $infobase{$form{mypage}};
239  <textarea cols="$cols" rows="$rows" name="mymsg" wrap="virtual">$page_msg</textarea><br>          &print_header($form{mypage}, -noindex => 1);
240  <input type="submit" value="プレビュー">          &print_message(&Resource('Error:PageIsDeletedSuccessfully'));
241  </form>          &print_footer($form{mypage});
242  <hr>      }
243  <h3>テキスト整形のルール</h3>  }
244    
245  <p>通常は入力した文字がそのまま出力されますが、  sub get_search_result ($;%) {
246  以下のルールに従ってテキスト整形を行うことができます。</p>    my $word = lc shift;
247      my %option = @_;
248  <ul>    my @r;
249  <li>    foreach my $page (keys %database) {
250  空行は段落の区切りとなります。      next if !$option{-match_myself} && ($page eq $word);
251        my $content = lc $database{$page};
252  <li>      if (index (lc $page, $word) > -1) {
253  HTMLのタグは書けません。        my $c = $content =~ s/\Q$word\E//g;
254          push @r, [$page, $c+20];
255  <li>      } elsif (index ($word, lc $page) > -1) {
256  ''ボールド''のようにシングルクォート二つではさむと、ボールドになります。        my $c = $content =~ s/\Q$word\E//g;
257          push @r, [$page, $c+10];
258  <li>      } elsif (my $c = $content =~ s/\Q$word\E//g) {
259  '''イタリック'''のようにシングルクォート三つではさむと、イタリックになります。        push @r, [$page, $c];
260        }
261  <li>    }
262  ----のようにマイナス4つがあると、水平線になります。    #my $em = sub { my $s = shift; $s =~ s#(\Q$word\E)#<em>$1</em>#gi; $s };
263      my $r = join "\n", map {qq(<li>[$_->[1]] <a href ="$url_cgi?@{[&encode($_->[0])]}" class="wiki">@{[&escape($_->[0])]}</a> <span class="wikipage-summary">@{[&escape(&get_subjectline($_->[0]))]}</span></li>)} sort {$b->[1] <=> $a->[1] || $a->[0] cmp $b->[0]} @r;
264  <li>    $r = qq|<ul class="search-result">$r</ul>| if $r;
265  *を行頭に書くと大見出しになります。    wantarray? ($r, scalar @r): $r;
266    }
267  <li>  
268  **を行頭に書くと小見出しになります。  sub do_random_jump {
269      my @list = keys %database;
270  <li>    my $name = &encode ($list[rand @list]);
271  -を行頭に書くと箇条書きになります。- -- --- の3レベルがあります。    my $scheme = 'http';
272      $scheme = lc $1 if $main::ENV{SERVER_PROTOCOL} =~ m#([A-Za-z0-9+.%-]+)#;
273  <li>    print "Location: $scheme://$main::ENV{SERVER_NAME}:$main::ENV{SERVER_PORT}$url_cgi?$name\n";
274  :を行頭に書くと用語と解説文が作れます。    print "\n";
275    }
276  <pre>  
277      :用語1:いろいろ書いた解説文1  sub print_error {
278      :用語2:いろいろ書いた解説文2      my ($msg) = @_;
279      :用語3:いろいろ書いた解説文3      &print_header($PageName{ErrorPage}, -noindex => 1);
280  </pre>      print qq(<p><strong class="error">$msg</strong></p>);
281        &print_footer($PageName{ErrorPage});
282  <li>      exit(0);
283  http://www.hyuki.com/ のようなURLは自動的にリンクになります。  }
284    
285  <li>  sub print_header ($;%) {
286  YukiWikiのように大文字小文字を混ぜた英文字列を書くと、      my ($page, %option) = @_;
287  YukiWikiのページ名になります。      my @head;
288        $option{body_class} = &is_frozen($page) ? 'frozen' : 'normal';
289  <li>      $option{body_class} .= " wiki-page-obsoleted" if $option{-content_format} =~ /obsoleted="yes"/;
290  [[結城浩]]のように二重の大かっこ[[ ]]でくくった文字列を書くと、      if ($option{-goto}) {
291  YukiWikiのページ名になります。        if ($UA =~ m#Opera|MSIE 2\.#) {
292  大かっこの中にはスペースを含めてはいけません。            ## WARNING: This code may output unsafe HTML document if
293  日本語も使えます。            ##          $option{-goto} is not clean.
294              $option{-goto} =~ tr/;/&/ if $UA =~ m#Opera#;
295  <li>            print qq{Refresh: 0; url=$option{-goto}\n};
296  行頭がスペースで始まっていると、            push @head, qq(<meta http-equiv="refresh" content="0; url=$option{-goto}">);
297  その段落は整形済み扱われます。        } else {
298  プログラムを書き込むときに使うと便利です。            $option{-goto} =~ tr/;/&/ if $UA =~ m#Mozilla/[1-4]\.#;
299              print qq{Refresh: 0; url="$option{-goto}"\n};
300  <li>            push @head, qq(<meta http-equiv="refresh" content="0; url=&quot;@{[&escape($option{-goto})]}&quot;">);
301  > を行頭に書くと、        }
302  引用文が書けます。      }
303  >の数が多いとインデントが深くなります(3レベルまで)。      print qq{Last-Modified: @{[scalar gmtime $option{-last_modified}]}\n} if $option{-last_modified};
304        if ($option{-expires}) {
305  </ul>        print qq{Expires: @{[scalar gmtime $option{-expires}]}\n};
306  EOD      }
307      &print_footer;      if ($UA =~ m#Mozilla/2#) {
308  }          my $ct = qq{text/html; charset=@{[&get_charset_name($kanjicode,compatible=>1)]}};
309            print qq{Content-Type: $ct\n};
310  # ページの検索          push @head, qq{<meta http-equiv="content-type" content="$ct">};
311  sub do_search {      } elsif ($UA =~ m#Infomosaic#) {
312      if ($form{myword}) {          print qq{Content-Type: text/html\n};
313          &print_header('検索結果');      } else {
314          print qq|<h1>$IconTag$form{myword}の検索結果</h1>\n|;          print qq{Content-Type: text/html; charset=@{[&get_charset_name($kanjicode)]}\n};
315          &print_toolbar();      }
316          print qq|<ul>\n|;      push @head, qq(<title>@{[&escape($page)]}</title>);
317          my $count = 0;      if ($UA !~ m#Mozilla/[1-4]\.# || $UA =~ m#MSIE (?:[4-9]\.|\d\d)#) {
318          foreach my $page_name (sort keys %database) {    # sortするのは無謀かな        push @head, qq(<link rel="stylesheet" type="text/css" href="@{[&escape($uri{wiki}.'?mycmd=TEXT_CSS;mypage='.&encode($PageName{DefaultStyleForHTML}).';x-lm='.&get_info($PageName{DefaultStyleForHTML}, $info_LastModified))]}");
319              if ($database{$page_name} =~ /\Q$form{'myword'}\E/) {      }
320                  my $encoded = &encode_percent($page_name);      push @head, q(<meta name="ROBOTS" content="NOINDEX">) if $option{-noindex};
321                  print qq|<li><a href="$thisurl?mycmd=read&mypage=$encoded">$page_name</a>\n|;      my ($Links, $links) = &make_navigate_links ($page);
322                  $count++;      #print $Links;      ## Link: fields
323              }      $links = join "\n", (@head, $links);
324          }      print <<"EOD";
325          print qq|</ul>\n|;  Content-Language: $lang
326          if ($count > 0) {  Content-Style-Type: text/css
327              print qq|<p><b>$form{myword}</b>を含むページは、上に示す<b>$count</b>ページです。</p>\n|;  
328          } else {  <!-- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
329              print qq|<p><b>$form{myword}</b>を含むページは見つかりません。</p>\n|;  "http://www.w3.org/TR/html4/loose.dtd"> + RUBY -->
330          }  <html lang="$lang" class="$option{body_class}">
331      } else {  <head profile="http://suika.fam.cx/~wakaba/-temp/wiki/wiki?WikiHTMLMetaProfile">
332          &print_header('単語検索');  $links
333          print qq|<h1>$IconTag単語検索</h1>\n|;  </head>
334          &print_toolbar();  <body class="$option{body_class}">
335      }  EOD
336      print <<"EOD";      &print_navigate_links ($page);
337  <p>      print <<EOD;
338  <form action="$thisurl" method="post">  <h1 class="header">@{[&escape($page)]}</h1>
339  <input type="hidden" name="mycmd" value="search">  EOD
340  <input type="text" name="myword" size="20" value="$form{myword}">  }
341  <input type="submit" value="単語検索">  
342  </form>  sub get_charset_name ($;%) {
343  </p>      my ($charset, %option) = (lc shift, @_);
344  EOD      if ($charset =~ 'euc') {
345      &print_footer;          $charset = $option{compatible} ? 'x-euc-jp' : 'euc-jp';
346  }      } elsif ($charset =~ 'sjis' || $charset =~ 'shift') {
347            $charset = $option{compatible} ? 'x-sjis' : 'shift_jis';
348  # ページの一覧      } elsif ($charset =~ 'jis') {
349  sub do_list {          $charset = 'iso-2022-jp';
350      &print_header('ページ一覧');      }
351      print qq|<h1>$IconTag ページ一覧</h1>\n|;      $charset;
352      &print_toolbar();  }
353      print qq|<ul>\n|;  
354      foreach my $page_name (sort keys %database) {    # sortするのは無謀かな  sub print_navigate_links (@) {
355          my $encoded = &encode_percent($page_name);    my ($page) = @_;
356          print qq|<li><a href="$thisurl?mycmd=read&mypage=$encoded">$page_name</a>\n|    my $editable = (&is_editable($page) && !&is_frozen($page)) ? 1 : 0;
357      }    my $cookedpage = &encode($page);
358      print qq|</ul>\n|;    print <<EOH;
359      &print_footer;  <div class="tools">
360  }      @{[ $editable
361            ? qq(<a title="@{[&Resource('EditThisPageLong',escape=>1)]}" href="$url_cgi?mycmd=edit;mypage=$cookedpage" accesskey="E" class="wiki-cmd">@{[&Resource('EditThisPage',escape=>1)]}</a> | )
362  # プレビュー          : qq()
363  sub do_preview {      ]}
364      my $page_name = $form{mypage};      <a href="$url_cgi?mycmd=read;mypage=$cookedpage;x-param=@{[time.[0..9]->[rand 10]]}" class="wiki-cmd" title="@{[&Resource('ViewThisPageLong',escape=>1)]}">@{[&Resource('ViewThisPage',escape=>1)]}</a> |
365      my $escapedmsg = &escape($form{mymsg});      <a href="$url_cgi?mycmd=map;mypage=$cookedpage" class="wiki-cmd" title="@{[&Resource('ShowMapOfThisPageLong',escape=>1)]}">@{[&Resource('ShowMapOfThisPage',escape=>1)]}</a> |
366      &print_header($page_name);      <a href="$url_cgi?$PageName{CreatePage}" class="wiki" title="@{[&Resource('GoToCreatePageLong',escape=>1)]}">@{[&Resource('GoToCreatePage',escape=>1)]}</a> |
367      print qq|<h1>$IconTag${page_name}のプレビュー</h1>\n|;      <a href="$url_cgi?$PageName{IndexPage}" class="wiki" title="@{[&Resource('GoToIndexPageLong',escape=>1)]}">@{[&Resource('GoToIndexPage',escape=>1)]}</a> |
368      &print_toolbar($page_name);      <a href="$url_cgi?$PageName{FrontPage}" class="wiki" title="@{[&Resource('GoToHomePageLong',escape=>1)]}">@{[&Resource('GoToHomePage',escape=>1)]}</a> |
369      # local $percent_name = &encode_percent($page_name);      <a href="$url_cgi?$PageName{SearchPage}" class="wiki" title="@{[&Resource('GoToSearchPageLong',escape=>1)]}">@{[&Resource('GoToSearchPage',escape=>1)]}</a> |
370      print qq|<p>以下のプレビューを確認して、よければページ下部のボタンで更新してください。</p>\n|;      <a href="$url_cgi?mycmd=RandomJump;x-param=@{[time.[0..9]->[rand 10]]}" class="wiki randomlink" title="@{[&Resource('GoSomewhereLong',escape=>1)]}">@{[&Resource('GoSomewhere',escape=>1)]}</a> |
371      if ($form{mymsg}) {      <a href="$url_cgi?$PageName{RecentChanges}" class="wiki" title="@{[&Resource('GoToRecentChangesLong',escape=>1)]}">@{[&Resource('GoToRecentChanges',escape=>1)]}</a>
372          print qq|<table width="100%" bgcolor="$preview_color" ><tr><td>\n|;  </div>
373          # print &convert_html($escapedmsg);  EOH
374          print &convert_html($form{mymsg});  }
375          print qq|</td></tr></table>\n|;  
376      } else {  sub make_navigate_links ($) {
377          print qq|<p>(ページの内容は空です。更新するとこのページは<b>削除</b>されます。)</p>\n|;      my $page = shift;
378      }      my @link;
379      &print_preview_buttons($page_name, $escapedmsg, $form{mydigest});      push @link, {rel=>'edit', href=>"$url_cgi?mycmd=edit;mypage=@{[&encode($page)]}", class=>"wiki-command", title=>&Resource('EditThisPageLink')} if &is_editable ($page) && !&is_frozen ($page);
380      &print_footer;      push @link, {rel=>'edit', href=>"$url_cgi?mycmd=adminedit;mypage=@{[&encode($page)]}", class=>"wiki-command", title=>&Resource('AdminEditThisPageLink')} if &is_editable ($page) || &is_frozen ($page);
381  }      push @link, {rel=>'view', href=>"$url_cgi?mycmd=read;mypage=@{[&encode($page)]};x-p=@{[time.[0..9]->[rand 10]]}", class=>'wiki-command', title=>&Resource('ViewThisPageLink')};
382        push @link, {rel=>'myself', href=>"$url_cgi?@{[&encode($page)]}", class=>'wiki', title=>&Resource('GoToMyselfLink')};
383  sub print_preview_buttons {      push @link, {rel=>'index', href=>"$url_cgi?$PageName{IndexPage}", class=>'wiki', title=>&Resource('GoToIndexPageLink')};
384      my ($page_name, $escapedmsg, $digest) = @_;      push @link, {rel=>'home', href=>"$url_cgi?$PageName{FrontPage}", class=>'wiki', title=>&Resource('GoToHomePageLink')};
385      print <<"EOD";      push @link, {rel=>'News', href=>"$url_cgi?WikiNews", class=>'wiki', title=>&Resource('GoToWikiNewsLink')};
386      <form action="$thisurl" method="post">      push @link, {rel=>'News', href=>"$url_cgi?$PageName{RecentChanges}", class=>"wiki", title=>&Resource('GoToRecentChangesLink')};
387      <textarea cols="$cols" rows="$rows" name="mymsg" wrap="virtual">$escapedmsg</textarea>      push @link, {rel=>'News', href=>"$url_cgi?$PageName{RssPage}", class=>"wiki", title=>&Resource('GoToRssPageLink'), type=>'application/xml'};
388      <br />      push @link, {rel=>'search', href=>"$url_cgi?$PageName{SearchPage}", class=>'wiki', title=>&Resource('GoToSearchPageLink')};
389      <input type="hidden" name="mypage" value="$page_name">      push @link, {rel=>'help', href=>"$url_cgi?WikiHelp", class=>'wiki', title=>&Resource('GoToWikiHelpLink')};
390      <input type="hidden" name="mydigest" value="$digest">      push @link, {rel=>'copyright', href=>"$url_cgi?WikiPageLicense", class=>'wiki', title=>&Resource('GoToWikiPageLicenseLink')};
391      <input type="submit" name="myspecial_preview" value="再度プレビュー">      push @link, {rel=>'jump', href=>qq(javascript:var%20WikiName=prompt('Please%20input%20the%20WikiName:','','Jump%20to%20SuikaWiki');if(WikiName)%7B_content.location.href='$url_cgi%3F'+encodeURIComponent(WikiName)%7D), class=>'wiki-cmd', title=>&Resource('JumpToLink')};
392      <input type="submit" name="myspecial_write" value="ページの更新">      push @link, {rel=>'jump', href=>qq(javascript:var%20WikiName=prompt('Please%20input%20the%20WikiName:','','Jump%20to%20SuikaWiki');if(WikiName)%7B_content.location.href='$url_cgi%3Fmycmd=edit;mypage='+encodeURIComponent(WikiName)%7D), class=>'wiki-cmd', title=>&Resource('JumpToEditLink')};
393      </form>      push @link, {rel=>'lucky', href=>"$url_cgi?mycmd=RandomJump;x-param=@{[time.[0..9]->[rand 10]]}", class=>'wiki randomlink', title=>&Resource('GoSomewhereLink')};
394  EOD      push @link, {rel=>'history', href=>$uri{cvs_wikipage}.do{my $s=$page;$s=~s/(.)/sprintf '%02X', ord $1/ges;$s}.'.txt', title=>&Resource('ViewHistoryOfThisPageLink'),hreflang=>'en'} if $uri{cvs_wikipage};
395  }      push @link, {rel=>'history', href=>"$url_cgi?mycmd=diff;mypage=@{[&encode($page)]}", title=>&Resource('ViewDiffOfThisPageLink'), class=>'wiki-command'} if $wiki::diff::UseDiff;
396        push @link, {rel=>'contents', href=>"$url_cgi?mycmd=map;mypage=@{[&encode($page)]}", title=>&Resource('ShowMapOfThisPageLink'), class=>'wiki-command'};
397  # 書き込む      my ($Links, $links) = ('', '');
398  sub do_write {      for my $e (@link) {
399      if (not &is_editable($form{mypage})) {          $links .= qq(<link);
400          # 編集不可ページは表示のみ          $Links .= qq(Link: <$e->{href}>);
401          &do_read;          for my $attr (qw/rel rev href title class type hreflang charset/) {
402          return;              $links .= qq( $attr="@{[&escape($e->{$attr})]}") if $e->{$attr};
403      }          }
404            for my $attr (qw/rel rev title/) {
405      my $page_name = $form{mypage};              $Links .= qq(; $attr="@{[do{$e->{$attr} =~ s/([\\\"])/\\$1/g; $e->{$attr}}]}") if $e->{$attr};
406            }
407      # digestを使って、更新の衝突チェック          $links .= qq(>\n);
408      my $original_digest = &calc_message_digest(&get_page($page_name));          $Links .= qq(\n);
409      if ($form{mydigest} ne $original_digest) {      }
410          &print_header($page_name);      wantarray ? ($Links, $links) : $Links;
411          print qq|<h1>$IconTag${page_name}で【更新の衝突】が起きました</h1>\n|;  }
412          print <<"EOD";  
413  <p>あなたがこのページを編集している間に、  sub print_footer {
414  他の人が同じページを更新してしまったようです。      my ($page, $lm) = @_;
415  </p><p>      my $epage = &encode ($page);
416  以下に、あなたの編集したテキストがありますので、    my $cvslog1 = q$Revision$;
417  あなたの編集内容が失われないように、    my $cvslog2 = q$Date$;
418  いますぐ、メモ帳などにコピー&ペーストしてください。    print_navigate_links ($page);
419  </p><p>    print <<"EOD";
420  コピー&ペーストが済んでから、  @{[ $lm ? qq(<div id="wikipage-last-modified">@{[&Resource('LastModified=',escape=>1)]}@{[&_rfc3339_date ($lm)]}</div>) : '' ]}
421  最新の内容を見て再度編集し直してください。  <div class="footer">
422  最新の内容は  <a href="http://www.hyuki.com/yukiwiki/" title="YukiWiki 2.0.beta1.2002-05-29 &copy; 2000-2002 by Hiroshi Yuki">@{[&Resource('About:Name:YukiWiki',escape=>1)]}</a> <a href="http://digit.que.ne.jp/work/" title="WalWiki 2.0.beta1.wal.1 &copy; 2000-2002 by Makio Tsukamoto">@{[&Resource('About:Name:WalWiki',escape=>1)]}</a>
423  <a target="_blank" href="$thisurl?mycmd=read&mypage=$form{mypage}">$form{mypage}</a>  <a href="/gate/cvs/wakaba/wiki/" title="@{[&Resource('About:SuikaWiki:JumpToCVS',escape=>1)]} ($cvslog2)">@{[&Resource('About:Name:SuikaWiki',escape=>1)]} $cvslog1</a>
424  で見ることができます。  </div>
425  </p>  </body>
426  EOD  </html>
427          # &print_toolbar($page_name);  EOD
428          &print_preview_buttons($page_name, &escape($form{mymsg}), $form{mydigest});  }
429          &print_footer;  
430          return;  sub escape {
431      }      my $s = shift;
432        $s =~ s|\r\n|\n|g;
433      # diff生成      $s =~ s|&|&amp;|g;
434      {      $s =~ s|<|&lt;|g;
435          &opendiff;      $s =~ s|>|&gt;|g;
436          my @msg1 = split(/\n/, &get_page($page_name));      $s =~ s|"|&quot;|g;
437          my @msg2 = split(/\n/, $form{mymsg});      return $s;
438          $msgrefA = \@msg1;  }
439          $msgrefB = \@msg2;  
440          &diff_check;  sub unescape {
441          $diffbase{$form{mypage}} = $diff_text;      my $s = shift;
442          $diff_text = '';      # $s =~ s|\n|\r\n|g;
443          &closediff;      $s =~ s|&lt;|<|g;
444      }      $s =~ s|&gt;|>|g;
445        $s =~ s|&quot;|"|g;
446      &print_header($page_name);      $s =~ s|&amp;|&|g;
447      &set_page($page_name, $form{mymsg});      return $s;
448      if ($form{mymsg}) {  }
449          print qq|<h1>$IconTag${page_name}を更新しました</h1>\n|;  
450          &print_toolbar($page_name);  sub print_content ($;$) {
451          print &convert_html(&get_page($page_name));      my ($rawcontent, %option) = @_;
452      } else {      print &text_to_html($rawcontent, toc=>1, %option);
453          print qq|<h1>$IconTag${page_name}を削除しました</h1>\n|;  }
454          &print_toolbar($page_name);  
455          print qq|<p>${page_name}を削除しました。</p>\n|;  sub text_to_html {
456      }      my ($txt, %option) = @_;
457      &print_footer;      my @toc;
458      # 更新されたのでタッチしておく。      my @toc2 = @{$option{-toc}||[]};
459      if ($touchfile) {      my $tocnum = 0;
460          open(FILE, "> $touchfile");      
461          print FILE "\n";      ## Load constants
462          close(FILE);      my %const;
463      }      if ($option{content_format} =~ /import="([^"]+)"/) {
464  }        for (split /\s*,\s*/, $1) {
465            my $wp = $database{$_};
466  # ページの変更点          if ($wp =~ m!^\#\?SuikaWikiConst/1.0!) {
467  sub do_diff {            wiki::suikawikiconst::to_hash ($wp => \%const);
468      if (not &is_editable($form{mypage})) {          }
469          # 編集不可ページは表示のみ        }
470          &do_read;      }
471          return;      
472      }      $txt =~ s{__&&([^&]+)&&__}{defined $const{$1}?$const{$1}:qq(__&&$1&&__)}ge;
473      &opendiff;      my (@txt) = split(/\n/, $txt);
474      &print_header($form{mypage} . 'の変更点');      my (@saved, @result);
475      print qq|<h1>$IconTag <a href="$thisurl?mycmd=read&mypage=$form{mypage}">$form{mypage}</a>の変更点</h1>\n|;      unshift(@saved, "</p>");
476      &print_toolbar();      push(@result, "<p>");
477      $_ = &escape($diffbase{$form{mypage}});      foreach (@txt) {
478      print <<"EOD";          chomp;
479  <ul>          if (/^\*\*\*\*\*([^\x0D\x0A]*)/) {
480  <li>追加された行は<font color="blue">青色</font>です。              push(@toc, qq(----- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
481  <li>削除された行は<font color="red">赤色</font>です。              push(@result, splice(@saved), qq(<h6 @{[&id_and_name("i$tocnum")]}>) . &inline($1, const => \%const) . '</h6>');
482  <li><a href="$thisurl?mycmd=read&mypage=$form{mypage}">$form{mypage}</a>へ行く。              $tocnum++;
483  </ul>          } elsif (/^\*\*\*\*([^\x0D\x0A]*)/) {
484  <hr />              push(@toc, qq(---- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
485  EOD              push(@result, splice(@saved), qq(<h5 @{[&id_and_name("i$tocnum")]}>) . &inline($1, const => \%const) . '</h5>');
486      print qq|<pre>\n|;              $tocnum++;
487      foreach (split(/\n/, $_)) {          } elsif (/^\*\*\*([^\x0D\x0A]*)/) {
488          if (/^\+(.*)/) {              push(@toc, qq(--- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
489              print qq|<font color="blue">$1</font>\n|;              push(@result, splice(@saved), qq(<h4 @{[&id_and_name("i$tocnum")]}>) . &inline($1, const => \%const) . '</h4>');
490          } elsif (/^\-(.*)/) {              $tocnum++;
491              print qq|<font color="red">$1</font>\n|;          } elsif (/^\*\*([^\x0D\x0A]*)/) {
492          } elsif (/^\=(.*)/) {          # if (/^\*\*(.*)/) {
493              print qq|$1\n|;          # Walrus mod (6) end
494          } else {              push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
495              print qq|??? $_\n|;              push(@result, splice(@saved), qq(<h3 @{[&id_and_name("i$tocnum")]}>) . &inline($1, const => \%const) . '</h3>');
496          }              $tocnum++;
497      }          } elsif (/^\*([^\x0D\x0A]*)/) {
498      print qq|</pre>\n|;              push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
499      &print_footer;              push(@result, splice(@saved), qq(<h2 @{[&id_and_name("i$tocnum")]}>) . &inline($1, const => \%const) . '</h2>');
500      &closediff;              $tocnum++;
501  }          } elsif (/^(={1,6})(.*)/) {
502                &back_push('ol', length($1), \@saved, \@result);
503  sub opendiff {              push(@result, '<li>' . &inline($2, const => \%const) . '</li>');
504      if ($dbmopen) {          } elsif (/^(-{1,6})(.*)/) {
505          if (!dbmopen(%diffbase, $diffdbname, 0666)) {            &back_push('ul', length($1), \@saved, \@result);
506              &print_error("(dbmopen) $diffdbname が作れません。");            my ($pf, $l) = ('', $2);
507          }            if (!$main::_EMBEDED && $l =~ s/^\s*\[([0-9]+)\]//) {
508      } else {              my $num = 0+$1;
509          if (!tie(%diffbase, "YukiWikiDB", $diffdbname)) {              $pf = qq(<a name="anchor-$num" id="anchor-$num" class="anchor">[$num]</a>);
510              &print_error("(tie error)");            }
511          }            push(@result, '<li>' . $pf . &inline ($l, const => \%const) . '</li>');
512      }          } elsif (/^:([^:]+):(.*)/) {
513  }              &back_push('dl', 1, \@saved, \@result);
514                push(@result, '<dt>' . &inline($1, const => \%const) . '</dt>', '<dd>' . &inline($2, const => \%const) . '</dd>');
515  sub closediff {          } elsif (/^(?!>>\d)(>{1,5})(.*)/) {
516      if ($dbmopen) {              &back_push('blockquote', length($1), \@saved, \@result);
517          dbmclose(%diffbase);              push @result, "<p>";
518      } else {              push(@result, &inline($2, const => \%const));
519          untie(%diffbase);              unshift @saved, "</p>";
520      }          } elsif (/^\s*$/) {
521  }              push(@result, splice(@saved));
522                push(@result, "<p>");
523  # フォームからの情報を連想配列 %form に入れる              unshift(@saved, "</p>");
524  # &init_form('euc');          } elsif (/^(\s+.*)$/) {
525  sub init_form {              &back_push('pre', 1, \@saved, \@result);
526      my ($charcode) = @_;              push(@result, &inline($1, const => \%const));
527      my $query;          } elsif (/^\,(.*?)[\x0D\x0A]*$/) {
528      if ($ENV{REQUEST_METHOD} =~ /^post$/i) {              &back_push('table', 1, \@saved, \@result);
529          read(STDIN, $query, $ENV{CONTENT_LENGTH});              #######
530      } else {              # This part is taken from Mr. Ohzaki's Perl Memo and Makio Tsukamoto's WalWiki.
531          $query = $ENV{QUERY_STRING};              # XXXXX
532      }              my $tmp = "$1,";
533      my @assocarray = split(/&/, $query);              my @value = map {/^"(.*)"$/ ? scalar($_ = $1, s/""/"/g, $_) : $_} ($tmp =~ /("[^"]*(?:""[^"]*)*"|[^,]*),/g);
534      foreach my $assoc (@assocarray) {              my @align = map {(s/^\s+//) ? ((s/\s+$//) ? ' align="center"' : ' align="right"') : ''} @value;
535          my ($property, $value) = split(/=/, $assoc);              my @colspan = map {($_ eq '==') ? 0 : 1} @value;
536          $value =~ tr/+/ /;              for (my $i = 0; $i < @value; $i++) {
537          $value =~ s/%([A-Fa-f0-9][A-Fa-f0-9])/pack("C", hex($1))/eg;                  if ($colspan[$i]) {
538          &jcode::convert(\$value, $charcode);                      while ($i + $colspan[$i] < @value and $value[$i + $colspan[$i]] eq '==') {
539          $form{$property} = $value;                          $colspan[$i]++;
540      }                      }
541  }                      $colspan[$i] = ($colspan[$i] > 1) ? sprintf(' colspan="%d"', $colspan[$i]) : '';
542                        $value[$i] = sprintf('<td%s%s>%s</td>', $align[$i], $colspan[$i], &inline($value[$i], const => \%const));
543  # エラーページを出力する                  } else {
544  sub print_error {                      $value[$i] = '';
545      my ($msg) = @_;                  }
546      &print_header('Error');              }
547      print "<h1>$IconTag$msg</h1></body></html>";              push(@result, join('', '<tr>', @value, '</tr>'));
548      exit(0);              # XXXXX
549  }              #######
550            } elsif (/^\[(INS|DEL|PRE)\[\s*$/) {
551  sub escape {              push @result, splice (@saved), '<'.lc($1).'>';
552      my ($line) = shift;              unshift @saved, "</p>";
553      $line =~ s|<|&lt;|g;              push @result, "<p>";
554      $line =~ s|>|&gt;|g;          } elsif (/^\](INS|DEL|PRE)\]\s*$/) {
555      $line =~ s|"|&quot;|g;              push @result, splice (@saved), '</'.lc($1).'>';
556      # $line =~ s|\&|&amp;|g;          } elsif (/^\[([0-9]+)\](.*)$/ && !$main::_EMBEDED) {
557      return $line;            my $num = 0+$1;
558  }            push @result, qq(<a name="anchor-$num" id="anchor-$num" class="anchor">[$num]</a>);
559              push @result, &inline ($2, const => \%const);
560  sub inline {          } else {
561      my ($line) = shift;              push(@result, &inline($_, const => \%const));
562      $line = &escape($line);          }
563      $line =~ s|'''([^']+?)'''|<i>$1</i>|g;              # Italic      }
564      $line =~ s|''([^']+?)''|<b>$1</b>|g;                # Bold      push(@result, splice(@saved));
565      $line =~ s!      
566                  (      my $toc = '';
567                      ((mailto|http|https|ftp):[\x21-\x7E]*) # Direct http://...      if ($option{toc}) {
568                          |          # Convert @toc (table of contents) to HTML.
569                      ($WikiName)                         # LocalLinkLikeThis          # This part is taken from Makio Tsukamoto's WalWiki.
570                          |          my (@tocsaved, @tocresult);
571                      ($BracketName)                      # [[日本語リンク]]          foreach (@toc,@toc2) {
572                  )              if (/^(-{1,6})(.*)$/) {
573              !                  &back_push('ul', length($1), \@tocsaved, \@tocresult);
574                  &make_link($1)                  push(@tocresult, '<li>' . $2 . '</li>');
575              !gex;              }
576      return $line;          }
577  }          push(@tocresult, splice(@tocsaved));
578            $toc = join("\n", @tocresult);
579  # ページのタイトルからページの内容を得る          $toc = $toc ? qq(<div id="wikipage-toc">$toc</div>) : '';
580  sub get_page {      }
581      my $page_name = shift;      $toc .= join("\n", @result);
582      return $database{$page_name};      $toc =~ s#<p>\n</p>##g;
583  }      $toc =~ s#[\x0D\x0A]+</#</#g;
584        $toc =~ s#<pre>\n#<pre>#g;
585  # ページの内容を与える      $toc;
586  # &set_page($title, $txt)  }
587  sub set_page {  
588      # ページを更新する  sub back_push {
589      my $title = $_[0];      my ($tag, $level, $savedref, $resultref, $attr) = @_;
590      $database{$title} = $_[1];      while (@$savedref > $level) {
591      # 空ページなら削除する          push(@$resultref, shift(@$savedref));
592      unless ($database{$title}) {      }
593          delete $database{$title};      if ($savedref->[0] ne "</$tag>") {
594      }          push(@$resultref, splice(@$savedref));
595      # RecentChangesを更新する      }
596      my $delim = ' - ';      while (@$savedref < $level) {
597      my @pages = split(/\n/, $database{$whatsnew});          unshift(@$savedref, "</$tag>");
598      my $datestr = &get_current_datestr;          push(@$resultref, "<$tag$attr>");
599      unshift(@pages, qq|-$datestr$delim$title|);      }
600      # 同一ページの更新は最新のもののみにし、  }
601      # 存在しないページはスキップする。  
602      my %count;  sub inline ($;%) {
603      my @newpages;      my ($line, %option) = @_;
604      foreach my $line (@pages) {      $line = &escape($line);
605          my ($prefix, $title) = split(/$delim/, $line);      $line =~ s{$embed_command{form}}{&make_custom_form ($1, $2, $3, $4)}ge;
606          $count{$title}++;      $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;
607          if ($count{$title} == 1 and exists($database{$title})) {      $line =~ s:\[(WEAK)\[(.+?)\]\]:<span class="@{[lc $1]}">$2</span>:g;
608              push(@newpages, qq|$prefix - $title|);      $line =~ s:\[ABBR\[([^]]+)\] \[([^]]+)\]\]:<acronym title="$2">$1</acronym>:g;
609          }      $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;
610      }      $line =~ s:\[RUBY\[([^]]+)\] \[([^]]+)\]\]:<ruby><rb>$1</rb><rp>(</rp><rt>$2</rt><rp>)</rp></ruby>:g;
611      # ここで本当に更新      $line =~ s:\[RUBYB\[([^]]+)\] \[([^]]+)\]\]:<span class="ruby"><span class="rb">$1</span><span class="rp"> (</span><span class="rt-below">$2</span><span class="rp">) </span></span>:g;
612      $database{$whatsnew} = join("\n", splice(@newpages, 0, $maxnew));      $line =~ s|'''([^']+)'''|<strong>$1</strong>|g;
613  }      $line =~ s|''([^']+)''|<em>$1</em>|g;
614        $line =~ s{
615  # ページのヘッダを出力        (\[\[(\#\S+?)\]\])
616  sub print_header {        |\[\[([^[]+?)](?:&gt;&gt;([0-9]+))?]
617      my $title = shift;        |&gt;&gt;([0-9]+)
618      print <<"EOD";        |&lt;([A-Za-z0-9%]+:(?:(?!&gt;).)+)&gt;
619  Content-type: text/html      }{
620          my ($l, $page,$anchor, $anum, $uri) = ($1, $3,$4, 0+$5, $6);
621  <html><head>        if ($l) {
622  <title>$title</title>          &embedded_to_html($1);
623  <style type="text/css">        } elsif (defined $page) {
624  <!--          &make_wikilink ($page, anchor => 0+$anchor);
625  $style        } elsif ($anum) {
626  -->          qq(<a href="#anchor-$anum" class="wiki-anchor">&gt;&gt;$anum</a>);
627  </style>        } elsif ($uri) {
628  </head>          &make_urilink ($uri);
629  <body bgcolor="white">        }
630  EOD      }gex;
631  }      return $line;
632    }
633  # ツールバーを出力  
634  sub print_toolbar {  sub make_wikilink ($%) {
635      my $page_name = shift;    my ($ename, %option) = @_;
636      my $percent_name = &encode_percent($page_name);    my $name = &unescape ($ename);
637      my $editlink = '';    if ($database{$name}) {
638      if ($page_name ne '' and &is_editable($page_name)) {      my $subject = &escape (&get_subjectline ($name, delimiter => ''));
639          $editlink = <<"EOD";      if ($option{anchor}) {
640  <a href="$thisurl?mycmd=edit&mypage=$percent_name">編集</a> |        return qq(<a title="$subject" href="$url_cgi?@{[&encode($name)]}#anchor-$option{anchor}" class="wiki">$ename&gt;&gt;$option{anchor}</a>);
641  <a href="$thisurl?mycmd=diff&mypage=$percent_name">差分</a> |      } else {
642  EOD        return qq(<a title="$subject" href="$url_cgi?@{[&encode($name)]}" class="wiki">$ename</a>);
643      }      }
644      print <<"EOD";    } else {
645  <p>      return qq(<a title="@{[&Resource('JumpAndEditWikiPage',escape=>1)]}" href="$url_cgi?@{[&escape($name)]}" class="wiki not-exist">$ename<span class="mark">@{[&Resource('JumpAndEditWikiPageMark',escape=>1)]}</span></a>);
646   [    }
647  <a href="$thisurl?mycmd=read&mypage=$toppage">トップ</a> |  }
648  <a href="$thisurl?mycmd=list">一覧</a> |  
649  $editlink  sub make_urilink ($;%) {
650  <a href="$thisurl?mycmd=search">単語検索</a> |    require URI;
651  <a href="$thisurl?mycmd=read&mypage=$whatsnew">最終更新</a>    my $uri = shift;
652   ]    if ($uri =~ s/^IW://) {       ## InterWiki (not URI)
653  </p>      $uri = &unescape ($uri);
654  EOD      if ($uri =~ /^([^\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+|"(?:\\.|[^"\\])+"):([^\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+|"(?:\\.|[^"\\])+")$/) {
655  }        my ($site, $name) = ($1, $2);
656          for ($site, $name) {
657  # ページのフッタを出力          if (s/^"//) { s/"$//; s/\\(.)/$1/g }
658  sub print_footer {        }
659      print <<"EOD";        &init_InterWikiName () unless $interwiki{'[[]]'};
660  <hr>        if ($interwiki{$site}) {
661  <p>          &load_formatter ('interwiki');
662  <a href="http://www.hyuki.com/yukiwiki/">YukiWiki</a> $version Copyright (C) 2000,2001 by <a href="http://www.hyuki.com/">Hiroshi Yuki.</a><br />          my $uri = &escape ($fmt{interwiki}->replace ($interwiki{$site} => {site => $site, name => $name}));
663  Modified by <a href="$modifierlink">$modifier</a>.<br/>          $site = &escape ($site); $name = &escape ($name);
664  </p>          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;);
665  </body></html>        } else {
666  EOD          qq(&lt;@{[&Resource('Error:UnknownInterWikiName=',escape=>1)]}@{[&escape ($site)]}&gt;);
667  }        }
668        } else {
669  # URLやページの名前からリンクを作る        qq(&lt;@{[&Resource('Error:InvalidInterWiki=',escape=>1)]}@{[&escape($uri)]}&gt;);
670  sub make_link {      }
671      my $name = shift;    } elsif ($uri =~ /^urn:/) {   ## URN
672      if ($name =~ /^(http|https|ftp).*?(\.gif|\.png|\.jpeg|\.jpg)?$/) {      my $uri2 = &escape (URI->new ('/uri-res/N2L?'.&unescape ($uri), 'http')->canonical);
673          if ($2) {      qq(&lt;<a href="$uri2" title="URI: &lt;$uri&gt; (via &lt;$uri2&gt;)" class="out-of-wiki urn">$uri</a>&gt;);
674              return qq|<a href="$name"><img border="0" src="$name" /></a>|;    } elsif ($uri =~ s/^MAIL://) {        ## mail address (not URI)
675          } else {      my $uri2 = &escape (URI->new ('mailto:'.&unescape ($uri))->canonical);
676              return qq|<a href="$name">$name</a>|;      qq(&lt;<a href="$uri2" class="out-of-wiki mail">$uri</a>&gt;);
677          }    } elsif ($uri =~ s/^IMG(?:\([^)]+\))?://) {   ## image (not URI itself)
678      } elsif ($name =~ /^mailto:(.*)/) {      my $uri2 = &escape (URI->new (&unescape ($uri))->canonical);
679          my $address = $1;      qq(<img src="$uri2" alt="" title="URI: &lt;$uri2&gt;" class="out-of-wiki">);
680          return qq|<a href="$name">$address</a>|;    } else {      ## misc. URI
681      } elsif ($database{$name}) {      CGI::Carp::warningsToBrowser (0);
682          my $percent_name = &encode_percent($name);      my $uri2 = &escape (URI->new (&unescape ($uri))->canonical);
683          return qq|<a href="$thisurl?mycmd=read&mypage=$percent_name">$name</a>|;      CGI::Carp::warningsToBrowser (1);
684      } else {      qq(&lt;<a href="$uri2" title="URI: &lt;$uri2&gt;" class="out-of-wiki">$uri</a>&gt;);
685          my $percent_name = &encode_percent($name);    }
686          return qq|$name<a href="$thisurl?mycmd=edit&mypage=$percent_name">?</a>|;  }
687      }  
688  }  {my $FormIndex = 0;
689    sub make_custom_form ($$$$) {
690  # %xx の形式にエンコードする      my ($wfname, $definition, $template, $option) = @_;
691  # これは、      ## $template and $option is currently not used in this procedure.
692  # http://www.hyuki.com/yukiwiki/yukiwiki.cgi?mycmd=read&mypage=%3C%8C%8B%8F%E9%8D_%3E      unless ($main::_EMBEDED) {
693  # という形式のために使われる。          $FormIndex++;
694  # '<結城浩>' → '%3C%8C%8B%8F%E9%8D_%3E'          if (length $definition) {
695  sub encode_percent {              my $param = bless {}, 'SuikaWiki::Plugin';
696      my $name = shift;              my $lastmodified = &get_info($form{mypage}, $info_LastModified);
697      my $encoded = '';              &load_formatter (qw/form_input form_option/);
698      foreach my $ch (split(//, $name)) {              $definition = &unescape ($definition);
699          if ($ch =~ /[A-Za-z0-9_]/) {              $definition =~ s/\\(.)/$1/g;
700              $encoded .= $ch;              $option = &unescape ($option);
701          } else {              $option =~ s/\\(.)/$1/g;
702              $encoded .= '%' . sprintf("%02X", ord($ch));              $fmt{form_option}->replace ($option, $param);
703          }              $param->{output}->{form} = 1 unless defined $param->{output}->{form};
704      }              $definition .= ' %submit;' if $definition !~ /%submit/ && !$param->{output}->{nosubmit} && $param->{output}->{form};
705      return $encoded;              my $target_page = $param->{output}->{page} || $form{mypage};
706  }              $param->{form_disabled} = 1 if $FixedPage{$target_page};
707                my $target_form = $param->{output}->{id};
708  # テキスト本体をHTMLに変換する              my $r = '';
709  sub convert_html {              $r = <<EOH if $param->{output}->{form};
710      my ($txt) = shift;  <form method="post" action="$url_cgi" id="wikiform-$FormIndex" class="wikiform">
711      my (@txt) = split(/\n/, $txt);    <input type="hidden" name="mycmd" value="@{[$param->{form_disabled}?'read':'wikiform']}">
712      foreach (@txt) {    <input type="hidden" name="mypage" value="@{[&escape($target_page)]}">
713          chomp;    <input type="hidden" name="myLastModified" value="$lastmodified">
714          if (/^\*\*(.*)/) {    <input type="hidden" name="mytouch" value="on">
715              push(@result, splice(@saved), '<h3>' . &inline($1) . '</h3>');    <input type="hidden" name="@{[$target_form? qq(wikiform_targetform" value="@{[&escape($target_form)]}) : qq(wikiform_index" value="$FormIndex)]}">
716          } elsif (/^\*(.*)/) {  EOH
717              push(@result, splice(@saved), '<h2>' . &inline($1) . '</h2>');              $r .= qq(<a name="wikiform-$FormIndex"></a>) if $UA =~ m#Mozilla/[12]\.#;
718          } elsif (/^----/) {              $r .= $fmt{form_input}->replace ($definition, $param);
719              push(@result, splice(@saved), '<hr>');              $r .= "</form>\n" if $param->{output}->{form};
720          } elsif (/^(-{1,3})(.*)/) {              $r;
721              &back_push('ul', length($1));         } else {  ## No input-interface WikiForm
722              push(@result, '<li>' . &inline($2) . '</li>');             qq(<a id="wikiform-$FormIndex" name="wikiform-$FormIndex"><!-- #form --></a>);
723          } elsif (/^:([^:]+):(.*)/) {         }
724              &back_push('dl', 1);      } else {
725              push(@result, '<dt>' . &inline($1) . '</dt>', '<dd>' . &inline($2) . '</dd>');          qq(<ins class="wiki-error">@{[&Resource('Error:WikiForm:EmbedIsNotSupported',escape=>1)]}</ins>);
726          } elsif (/^(>{1,3})(.*)/) {      }
727              &back_push('blockquote', length($1));  }}
728              push(@result, &inline($2));  
729          } elsif (/^\s*$/) {  sub print_message {
730              push(@result, splice(@saved));      my ($msg) = @_;
731              unshift(@saved, "</p>");      print qq(<p><strong>@{[&escape($msg)]}</strong></p>);
732              push(@result, "<p>");  }
733          } elsif (/^(\s+.*)$/) {  
734              &back_push('pre', 1);  sub init_form {
735              push(@result, &escape($1)); # Not &inline, but &escape      ## TODO: Support multipart/form-data
736          } else {      my $query = '';
737              push(@result, &inline($_));      if (uc $main::ENV{REQUEST_METHOD} eq 'POST') {
738          }        read STDIN, $query, $main::ENV{CONTENT_LENGTH};
739      }      }
740      push(@result, splice(@saved));      $query .= ($query ? ';' : '') . $main::ENV{QUERY_STRING};
741      return join("\n", @result);      if ($main::ENV{REQUEST_METHOD} ne 'POST' && $main::ENV{QUERY_STRING} && $main::ENV{QUERY_STRING} !~ /[&;=]/) {
742  }        my $query = &decode($main::ENV{QUERY_STRING});
743          $query = &code_convert(\$query, $kanjicode);
744  # &back_push($tag, $count)        if ($page_command{$query}) {
745  # $tagのタグを$levelレベルまで詰める。          $form{mycmd} = $page_command{$query};
746  sub back_push {          $form{mypage} = $query;
747      my ($tag, $level) = @_;        } else {
748      while (@saved > $level) {          $form{mypage} = $query;
749          push(@result, shift(@saved));          $form{mycmd} = $database{$form{mypage}} ? 'read' : 'edit';
750      }        }
751      if ($saved[0] ne "</$tag>") {      } else {
752          push(@result, splice(@saved));        for (split /[;&]/, $query) {
753      }          if (my ($n, $v) = split /=/, $_, 2) {
754      while (@saved < $level) {            for ($n, $v) {tr/+/ /; s/%([0-9A-Fa-f][0-9A-Fa-f])/pack 'C', hex $1/ge};
755          unshift(@saved, "</$tag>");            $form{$n} = $v;
756          push(@result, "<$tag>");          }
757      }        }
758  }        unless (defined $form{mypage}) {
759            $form{mypage} = $form{epage};
760  # 編集可能ページか?          $form{mypage} =~ s/([0-9A-F]{2})/ord hex $1/g;
761  sub is_editable {        }
762      my ($pagename) = @_;        if ($page_command{$form{mypage}} && $form{mycmd} eq 'read') {
763      foreach (@uneditable) {          $form{mypage} = &code_convert(\$form{mypage}, $kanjicode);
764          if ($pagename eq $_) {          $form{mycmd} = $page_command{$form{mypage}};
765              return 0;        }
766          }      }
767      }      $form{mypage} ||= 'HomePage';
768      if (&is_valid_name($pagename)) {      $form{mycmd} ||= 'read';
769          return 1;  
770      }      # mypreview_edit        -> do_edit, with preview.
771      return 0;      # mypreview_adminedit   -> do_adminedit, with preview.
772  }      # mypreview_write       -> do_write, without preview.
773        foreach (keys %form) {
774  # Validな名前か?          if (/^mypreview_(.*)$/) {
775  sub is_valid_name {              $form{mycmd} = $1;
776      my ($pagename) = @_;              $form{mypreview} = 1;
777      if ($pagename =~ /^$WikiName$/) {          }
778          return 1;      }
779      } elsif ($pagename =~ /^$BracketName$/) {  
780          return 1;      #
781      } else {      # $form{mycmd} is frozen here.
782          return 0;      #
783      }  
784  }      for (grep /^wikiform__/, keys %form) {
785            $form{$_} = &code_convert (\$form{$_}, $kanjicode);
786  # 現在時刻の文字列を得る      }
787  sub get_current_datestr {      $form{mymsg} = &code_convert(\$form{mymsg}, $kanjicode);
788      my (@wdays) = ( "日", "月", "火", "水", "木", "金", "土" );      $form{myname} = &code_convert(\$form{myname}, $kanjicode);
789      my ($sec, $min, $hour, $mday, $mon, $year, $wday) = localtime(time);  }
790      return sprintf("%4d-%02d-%02d (%s) %02d:%02d:%02d",  
791          $year + 1900, $mon + 1, $mday, $wdays[$wday], $hour, $min, $sec);  {my %SubjectLine;
792  }  sub get_subjectline {
793        my ($page, %option) = @_;
794  # URL?SomePageや、      unless (defined $SubjectLine{$page}) {
795  # URL?[[結城浩]]の形式だった場合、(not yet)        if (not &is_editable($page)) {
796  # 強制的にmycmdをreadにして$formの内容を設定する。          $SubjectLine{$page} = "";
797  sub normalize_form {        } else {
798      foreach my $key (keys %form) {          $SubjectLine{$page} = $database{$page};
799          if ($key =~ /^$WikiName$/) {          $SubjectLine{$page} =~ s!^\#\?[^\x0A\x0D]+[\x0A\x0D]*!!s;
800              $form{mycmd} = 'read';          $SubjectLine{$page} =~ s/\x0D?\x0A.*//s;
801              $form{mypage} = $1;        }
802              last;      }
803          } elsif ($key =~ /^$BracketName$/) {      if (length $SubjectLine{$page}) {
804              $form{mycmd} = 'read';        $option{delimiter} = defined $option{delimiter} ? $option{delimiter} : &Resource('Title-Summary Delimiter');
805              $form{mypage} = $1;        $option{delimiter}.$SubjectLine{$page}.$option{tail};
806              last;      } else {
807          }        '';
808      }      }
809  }  }}
810    
811  # 変換テストを行なうときのサンプル  sub open_db {
812  sub print_sample {      if ($modifier_dbtype eq 'dbmopen') {
813      my $txt = &convert_html(<<"EOD");          dbmopen(%database, $PathTo{WikiDataBase}, 0666) or &print_error("(dbmopen) $PathTo{WikiDataBase}");
814  *大見出し1          dbmopen(%infobase, $PathTo{WikiInfoBase}, 0666) or &print_error("(dbmopen) $PathTo{WikiInfoBase}");
815  **小見出し1-1      } elsif ($modifier_dbtype eq 'AnyDBM_File') {
816  -項目1          eval q{use AnyDBM_File};
817  -項目2          tie(%database, "AnyDBM_File", $PathTo{WikiDataBase}, O_RDWR|O_CREAT, 0666) or &print_error("(tie AnyDBM_File) $PathTo{WikiDataBase}");
818  -項目3          tie(%infobase, "AnyDBM_File", $PathTo{WikiInfoBase}, O_RDWR|O_CREAT, 0666) or &print_error("(tie AnyDBM_File) $PathTo{WikiInfoBase}");
819  段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1      } elsif ($modifier_dbtype eq 'YukiWikiDB') {
820  段落1段落1段落1段落1段落1段落''強調''1段落1段落1段落1段落1段落1          eval q{use Yuki::YukiWikiDB};
821  段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1          tie(%database, "Yuki::YukiWikiDB", $PathTo{WikiDataBase}) or &print_error("(tie Yuki::YukiWikiDB) $PathTo{WikiDataBase}");
822            tie(%infobase, "Yuki::YukiWikiDB", $PathTo{WikiInfoBase}) or &print_error("(tie Yuki::YukiWikiDB) $PathTo{WikiInfoBase}");
823  段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2      } else {
824  段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2          eval qq{use $modifier_dbtype};
825  段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2          $database = tie(%database, $modifier_dbtype => $PathTo{WikiDataBase}, -lock => 2, -backup => $wiki::diff::UseDiff) or &print_error("(tie $modifier_dbtype) $PathTo{WikiDataBase}");
826  **小見出し1-2          tie(%infobase, $modifier_dbtype => $PathTo{WikiInfoBase}, -lock => 2) or &print_error("(tie $modifier_dbtype) $PathTo{WikiInfoBase}");
827  :用語1:いろいろ書いた解説文1と''強調単語''      }
828  段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1  }
829  段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1  
830  段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1  sub close_db {
831  :用語2:いろいろ書いた解説文2      if ($modifier_dbtype eq 'dbmopen') {
832  :用語3:いろいろ書いた解説文3          dbmclose(%database);
833  ----          dbmclose(%infobase);
834  *大見出し2      } else {
835  **小見出し2-1          untie(%database);
836  http://www.hyuki.com/          untie(%infobase);
837  **小見出し2-2      }
838    }
839  [[結城浩]]  
840    sub print_editform {
841  段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1      my ($mymsg, $lastmodified, %mode) = @_;
842  段落1段落1段落1段落'''イタリック'''1段落1段落1段落1段落1段落1段落1段落1      my $frozen = &is_frozen($form{mypage});
843  段落1段落1段落1段落'''''イタボールド'''''1段落1段落1段落1段落1段落1段落1段落1段落1  
844  >段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2      if ($form{mypreview}) {
845  >段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2          if ($form{mymsg}) {
846  >段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2              unless ($mode{conflict}) {
847                    print qq(<h3>@{[&Resource('Preview:Title',escape=>1)]}</h3>\n);
848  レベル0レベル0レベル0レベル0レベル0レベル0                  print qq(<p>@{[&Resource('Preview:Notice',escape=>1)]}</p>\n);
849                    print qq(<div class="preview">\n);
850  >レベル1                  &print_content($form{mymsg});
851  >レベル1                  print qq(</div>\n);
852  >レベル1              }
853  >>レベル2          } else {
854  >>レベル2              print @{[&Resource('Preview:Empty',escape=>1)]};
855  >>レベル2          }
856  >>>レベル3          $mymsg = &escape($form{mymsg});
857  -はろ1      } else {
858  --はろ2          $mymsg = &escape($mymsg || $database{NewPageTemplate});
859  ろろろろ2      }
860  ---はろ3      my $magic = '';
861  --はろ2      $magic = $1 if $mymsg =~ m/^([^\x0A\x0D]+)/s;
862  ---はろ3  
863  --はろ2      my $edit = $mode{admin} ? 'adminedit' : 'edit';
864  ---はろ3      my $selected = 'read';
865  >>>レベル3      if ($form{after_edit_cmd}) {
866  >>>レベル3          $selected = $form{after_edit_cmd};
867  >>>レベル3      } elsif ($magic =~ /Const|Config|CSS/) {
868  EOD          $selected = 'edit';
869      print $txt;      }
870      exit;      my $afteredit = <<EOH;
871  }  <select name="after_edit_cmd">
872    <option value="read" label="@{[&Resource('Edit:SaveAndView',escape=>1)]}"@{[$selected eq 'read' ? ' selected="selected"':'']}>@{[&Resource('Edit:SaveAndView',escape=>1)]}</option>
873  sub diff_check {  <option value="edit" label="@{[&Resource('Edit:SaveAndEdit',escape=>1)]}"@{[$selected eq 'edit' ? ' selected="selected"':'']}>@{[&Resource('Edit:SaveAndEdit',escape=>1)]}</option>
874      traverse_sequences(  </select>
875              $msgrefA, $msgrefB,  EOH
876              {  
877                  MATCH => \&df_match,      print <<"EOD";
878                  DISCARD_A => \&df_delete,  <form action="$url_cgi" method="post">
879                  DISCARD_B => \&df_add,  <h2>@{[&Resource('Edit:Title',escape=>1)]}</h2>
880              }      @{[ $mode{conflict} ? '' : qq(<input type="submit" name="mypreview_write" value="@{[&Resource('Edit:Save',escape=>1)]}"><kbd>S</kbd>) ]}
881      );      @{[ $mode{admin} ? qq(<label>@{[&Resource('Edit:Password=',escape=>1)]}<input type="password" name="mypassword" value="" size="10"></label>) : "" ]} [@{[do {my $n = 0;
882      &diff_flush;                 $mymsg =~ s/(?:-+\s)?\[([0-9]+)\]/$n = $1 if $1 > $n; $&/mge;
883  }                 ++$n}]}]<br>
884        <input type="hidden" name="myLastModified" value="$lastmodified">
885  sub diff_flush {      <input type="hidden" name="mypage" value="@{[&escape($form{mypage})]}">
886      $diff_text .= join('', map { "-$_\n" } splice(@diff_deleted));      <textarea cols="@{[&Resource('Edit:Form:Cols')+0||80]}" rows="@{[&Resource('Edit:Form:Rows')+0||20]}" name="mymsg" tabindex="1">$mymsg</textarea><br>
887      $diff_text .= join('', map { "+$_\n" } splice(@diff_added));  @{[
888  }      $mode{admin} ?
889        qq(
890  sub df_match {      <label><input type="radio" name="myfrozen" value="1" @{[$frozen ? qq(checked="checked") : ""]}>@{[&Resource('Edit:Freeze',escape=>1)]}</label>
891      my ($a, $b) = @_;      <label><input type="radio" name="myfrozen" value="0" @{[$frozen ? "" : qq(checked="checked")]}>@{[&Resource('Edit:DontFreeze',escape=>1)]}</label><br>)
892      &diff_flush;      : ""
893      $diff_text .= "=$msgrefA->[$a]\n";  ]}
894  }  @{[
895        $mode{conflict} ? "" :
896  sub df_delete {      qq(
897      my ($a, $b) = @_;          <label><input type="checkbox" name="mytouch" value="on" checked="checked">@{[&Resource('Edit:UpdateTimeStamp',escape=>1)]}</label><br>
898      push(@diff_deleted, $msgrefA->[$a]);          <input type="submit" name="mypreview_$edit" value="@{[&Resource('Edit:Preview',escape=>1)]}">
899  }          <label><input type="submit" name="mypreview_write" value="@{[&Resource('Edit:Save',escape=>1)]}" accesskey="S"><kbd>S</kbd></label>
900           $afteredit
901  sub df_add {      )
902      my ($a, $b) = @_;  ]}
903      push(@diff_added, $msgrefB->[$b]);  </form>
904  }  EOD
905        unless ($mode{conflict}) {
906  sub calc_message_digest {   # You have to use MD5...          ## Show help text
907      my $text = shift;          my $help = $database{WikiEditHelp};
908      my @text = split(//, $text);          $help =~ s!^\#\?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:[^0-9.\x0D\x0A][^\x0D\x0A]*)?)[\x0D\x0A]+!!s;
909      my $len = length($text);          print &text_to_html ($help, toc => 0);
910      my $checksum = 0;      }
911      foreach (@text) {  }
912          $checksum += ord($_);  
913          $checksum = ($checksum * 2) % 65536 + (($checksum & 32768) ? 1 : 0); # 16bit rotate  sub is_editable {
914      }      my ($page) = @_;
915      return "$len:$checksum";      if ($FixedPage{$page} || $page =~ /\s/ || $page =~ /^\#/) {
916  }          return 0;
917        } else {
918  # Definition of YukiWikiDB          return 1;
919  package YukiWikiDB;      }
920    }
921  my $debug = 1;  
922    # armor_name:
923  # Constructor  #   WikiName -> WikiName
924  sub new {  #   not_wiki_name -> [[not_wiki_name]]
925      return shift->TIEHASH(@_);  sub armor_name { qq([[$_[0]]]) }
926  }  
927    # unarmor_name:
928  # tying  #   [[bracket_name]] -> bracket_name
929  sub TIEHASH {  #   WikiName -> WikiName
930      my ($class, $dbname) = @_;  sub unarmor_name {
931      my $self = {      my ($name) = @_;
932          dir => $dbname,      if ($name =~ /^\[\[(\S+?)\]\]$/) {
933          keys => [],          return $1;
934      };      } else {
935      if (not -d $self->{dir}) {          return $name;
936          if (!mkdir($self->{dir}, 0777)) {      }
937              print "mkdir(" . $self->{dir} . ") fail\n" if ($debug);  }
938              return undef;  
939          }  sub decode {
940      }      my ($s) = @_;
941      return bless($self, $class);      $s =~ tr/+/ /;
942  }      $s =~ s/%([A-Fa-f0-9][A-Fa-f0-9])/pack("C", hex($1))/eg;
943        return $s;
944  # Store  }
945  sub STORE {  
946      my ($self, $key, $val) = @_;  sub encode {
947      my $file = &make_filename($self, $key);      my ($s) = @_;
948      if (open(FILE,"> $file")) {      my $encoded = '';
949          binmode(FILE);      foreach my $ch (split(//, $s)) {
950          print FILE $val;          if ($ch =~ /[A-Za-z0-9_]/) {
951          close(FILE);              $encoded .= $ch;
952          return $self->{$key} = $val;          } else {
953      } else {              $encoded .= '%' . sprintf("%02X", ord($ch));
954          print "$file create error.";          }
955      }      }
956  }      return $encoded;
957    }
958  # Fetch  
959  sub FETCH {  sub conflict {
960      my ($self, $key) = @_;      my ($page, $rawmsg) = @_;
961      my $file = &make_filename($self, $key);      if ($form{myLastModified} eq &get_info($page, $info_LastModified)) {
962      if (open(FILE, $file)) {          return 0;
963          local $/;      }
964          $self->{$key} = <FILE>;      &print_header($page, -noindex => 1);
965          close(FILE);      &print_content(&Resource('Error:Conflict'));
966      }      &print_editform($rawmsg, $form{myLastModified}, frozen=>0, conflict=>1);
967      return $self->{$key};      &print_footer($page);
968  }      return 1;
969    }
970  # Exists  
971  sub EXISTS {  sub get_now {
972      my ($self, $key) = @_;      my ($sec, $min, $hour, $day, $mon, $year) = localtime(time);
973      my $file = &make_filename($self, $key);      $year += 1900;
974      return -e($file);      $mon++;
975  }      $mon = "0$mon" if $mon < 10;
976        $day = "0$day" if $day < 10;
977  # Delete      $hour = "0$hour" if $hour < 10;
978  sub DELETE {      $min = "0$min" if $min < 10;
979      my ($self, $key) = @_;      #$sec = "0$sec" if $sec < 10;
980      my $file = &make_filename($self, $key);      return "$year-$mon-$day $hour:$min";
981      unlink $file;  }
982      return delete $self->{$key};  
983  }  sub init_InterWikiName {
984      my @content = split /\n/, $database{InterWikiName};
985  sub FIRSTKEY {    for (@content) {
986      my ($self) = @_;      if (/^([^#]\S*)\s+(\S[^\x0A\x0D]+)/) {
987      opendir(DIR, $self->{dir}) or die $self->{dir};        $interwiki{$1} = $2;
988      @{$self->{keys}} = grep /\.txt$/, readdir(DIR);      }
989      foreach my $name (@{$self->{keys}}) {    }
990          $name =~ s/\.txt$//;    $interwiki{'[[]]'} = 1;       ## dummy
991          $name =~ s/[0-9A-F][0-9A-F]/pack("C", hex($&))/eg;  }
992      }  
993      return shift @{$self->{keys}};  
994  }  sub get_info {
995        my ($page, $key) = @_;
996  sub NEXTKEY {      my %info = map { split(/=/, $_, 2) } split(/\n/, $infobase{$page});
997      my ($self) = @_;      return $info{$key};
998      return shift @{$self->{keys}};  }
999  }  
1000    sub set_info {
1001  sub make_filename {      my ($page, $key, $value) = @_;
1002      my ($self, $key) = @_;      my %info = map { split(/=/, $_, 2) } split(/\n/, $infobase{$page});
1003      my $enkey = '';      $info{$key} = $value;
1004      foreach my $ch (split(//, $key)) {      my $s = '';
1005          $enkey .= sprintf("%02X", ord($ch));      for (keys %info) {
1006      }          $s .= "$_=$info{$_}\n";
1007      return $self->{dir} . "/$enkey.txt";      }
1008  }      $infobase{$page} = $s;
1009  __END__  }
1010    
1011  =head1 NAME  sub frozen_reject {
1012        my ($isfrozen) = &get_info($form{mypage}, $info_IsFrozen);
1013  YukiWiki - 自由にページを追加・削除・編集できるWebページ構築CGI      my ($willbefrozen) = $form{myfrozen};
1014        if (not $isfrozen and not $willbefrozen) {
1015      Copyright (C) 2000,2001 by Hiroshi Yuki.          # You need no check.
1016      結城浩 <hyuki@hyuki.com>          return 0;
1017      http://www.hyuki.com/      } elsif (valid_password($form{mypassword})) {
1018      http://www.hyuki.com/yukiwiki/          # You are admin.
1019            return 0;
1020  =head1 SYNOPSIS      } else {
1021            &print_error(&Resource('Error:PasswordIsIncorrect'));
1022      http://www.hyuki.com/yukiwiki/yukiwiki.cgi          return 1;
1023        }
1024  =head1 DESCRIPTION  }
1025    
1026  YukiWiki(結城ウィキィ)は参加者が自由にページを追加・削除・編集できる  sub is_frozen {
1027  不思議なWebページ群を作るCGIです。      my ($page) = @_;
1028  Webで動作する掲示板とちょっと似ていますが、      if (&get_info($page, $info_IsFrozen)) {
1029  Web掲示板が単にメッセージを追加するだけなのに対して、          return 1;
1030  YukiWikiは、Webページ全体を自由に変更することができます。      } else {
1031            return 0;
1032  YukiWikiは、Cunningham & CunninghamのWikiWikiWebの      }
1033  仕様を参考にして独自に作られました。  }
1034    
1035  YukiWikiはPerlで書かれたCGIスクリプトとして実現されていますので、  sub do_comment {
1036  Perlが動作するWebサーバならば比較的容易に設置できます。      my ($content) = $database{$form{mypage}};
1037        my $default_name;   ## this code does not strict.
1038  あとはdbmopenが使える環境ならば設置できます(Version 1.5.0以降ならdbmopenが使えなくても設置できます)。      $default_name = $1 if $content =~ /default-name="([^"]+)"/;
1039        my $datestr = '[WEAK['.&get_now.']]';
1040        my $namestr = $form{myname} || $default_name || &Resource('WikiForm:WikiComment:DefaultName');
1041  YukiWikiはフリーソフトです。      ($namestr = '', $datestr = '') if $form{myname} eq 'nodate';
1042  ご自由にお使いください。      if ($namestr =~ /^(?:>>)?[0-9]/) {
1043          $namestr = qq( ''$namestr'': );
1044  =head1 設置方法      } elsif (length $namestr) {
1045          $namestr = qq( ''[[$namestr]]'': );
1046  =head2 入手      }
1047        my $anchor = &get_new_anchor_index ($content);
1048  YukiWikiの最新版は、      my $i = 1;  my $o = 0;
1049  http://www.hyuki.com/yukiwiki/      $content =~ s{(\[\[\#r?comment\]\])}{
1050  から入手できます。        my $embed = $1;
1051          if ($i == $form{comment_index}) {
1052  =head2 ファイル一覧          if ($embed ne '[[#rcomment]]') {
1053              $embed = "- [$anchor] $datestr$namestr$form{mymsg}\n$embed";  $o = 1;
1054      readme.txt      ドキュメント          } else {
1055      yukiwiki.cgi    YukiWiki本体            $embed .= "\n- [$anchor] $datestr$namestr$form{mymsg}";  $o = 1;
1056      yukiwiki.gif    ロゴ(カラー版)          }
1057      yukimono.gif    ロゴ(モノクロ版)        }
1058      jcode.pl        漢字コードライブラリ        $i++; $embed;
1059        }ge;
1060  =head2 インストール      unless ($o) {
1061          $content = "#?SuikaWiki/0.9\n\n" unless $content;
1062  =over 4        $content .= "\n" unless $content =~ /\n$/s;
1063          $content .= "- [$anchor] $datestr$namestr$form{mymsg}\n";
1064  =item 1.      }
1065        $form{__comment_anchor_index} = $anchor;
1066  アーカイブを解く。      if ($form{mymsg} || $form{myname}) {
1067            $form{mymsg} = $content;
1068  =item 2.          $form{mytouch} = 'on';
1069            &do_write;
1070  yukiwiki.cgiのはじめの方にある設定を確認します。      } else {
1071  通常は何もしなくてよいが、          $form{mycmd} = 'read';
1072  はじめは$touchfileを''にした方がよいでしょう。          &do_read;
1073        }
1074  =item 3.  }
1075    
1076  yukiwiki.cgiとjcode.plを同じところに設置します。  sub get_new_anchor_index ($) {
1077        my $content = shift;
1078  =item 4.      my $anchor = 0;
1079        $content =~ s/^(?:[-=]+\s*)?\[([0-9]+)\]/$anchor = $1 if $1 > $anchor; $&/mge;
1080  サイズ0のyukiwiki.dbというファイルを設置します。      $anchor + 1;
1081  (Perlシステムによってはyukiwiki.pag, yukiwiki.dir)  }
1082    
1083  =item 5.  my $CommentIndex = 0;
1084    sub embedded_to_html {
1085  yukiwiki.cgiにブラウザからアクセスします。      my ($embedded) = @_;
1086        if ($embedded eq '[[#comment]]' or $embedded eq '[[#rcomment]]') {
1087  =back        unless ($main::_EMBEDED) {
1088            my $lastmodified = &get_info($form{mypage}, $info_LastModified);
1089  =head2 パーミッション          return <<"EOD";
1090    <form action="$url_cgi" method="post" id="x-comment-@{[++$CommentIndex]}" class="comment"><p>
1091          ファイル        パーミッション      転送モード      <input type="hidden" name="mycmd" value="comment">
1092          yukiwiki.cgi    755                 ASCII      <input type="hidden" name="mypage" value="$form{mypage}">
1093          yukiwiki.gif    644                 BINARY      <input type="hidden" name="myLastModified" value="$lastmodified">
1094          yukimono.gif    644                 BINARY      <input type="hidden" name="mytouch" value="on">
1095          jcode.pl        644                 ASCII      <input type="hidden" name="comment_index" value="$CommentIndex">
1096        @{[&Resource('WikiForm:WikiComment:Name=',escape=>1)]}
1097      $dbmopen = 1; にした場合:      <input type="text" name="myname" value="" size="10" class="comment-name">
1098          yukiwiki.db     666                 BINARY      <input type="text" name="mymsg" value="" size="60" class="comment-msg">
1099          (yukiwiki.pag, yukiwiki.dirの場合もあり)      <input type="submit" value="@{[&Resource('WikiForm:Add',escape=>1)]}" title="@{[&Resource('WikiForm:AddLong',escape=>1)]}" class="comment-submit">
1100    </p></form>
1101      $dbmopen = 0; にした場合: (カレントディレクトリを777にしておく)  EOD
1102          .               777                 (転送しない)       } else {
1103            return <<"EOD";
1104  =head1 データのバックアップ方法  <del><form action="$url_cgi" method="get">
1105        <input type="hidden" name="mycmd" value="read">
1106  $dbmopen = 1;の場合は、      <input type="hidden" name="mypage" value="$form{mypage}">
1107  データはすべてyukiwiki.db(.dir, .pag)に入る。      @{[&Resource('WikiForm:WikiComment:Name=',escape=>1)]}
1108  これをバックアップすればよい。      <input type="text" name="myname" value="" size="10" disabled="disabled">
1109        <input type="text" name="mymsg" value="" size="60" disabled="disabled">
1110  $dbmopen = 0;の場合は、  </form></del>
1111  yukiwikiというディレクトリができるので、  EOD
1112  これ以下をバックアップすればよい。      }
1113      } elsif ($embedded =~ /$embed_command{searched}/) {
1114  =head1 新しいページの作り方      return get_search_result ($1, -match_myself => 1);
1115      } elsif ($embedded =~ /^\[\[\#embed:(.+)\]\]$/) {
1116  =over 4      my ($name, $r) = ($1, '');
1117        if ($main::_EMBEDED != 1) {
1118  =item 1.        my ($content, $cf) = ($database{$name}, 'SuikaWiki/0.9');
1119          $cf = $1 if $content =~ s!^(?:[\#<]\?|/\*\s*)?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:[^0-9.][^\x0D\x0A]*)?)[\x0D\x0A]+!!s;
1120  まず、適当なページ(例えばFrontPage)を選び、        if ($cf =~ m!^(?:\#\?)?SuikaWiki/0.9(?:$|\s)!) {
1121  ページの下にある「編集」リンクをたどります。          $main::_EMBEDED = 1;
1122            $r = &text_to_html ($content, content_format => $cf);
1123  =item 2.          $main::_EMBEDED = 0;
1124          } elsif (length $content) {
1125  するとテキスト入力ができる状態になるので、          $r = "<pre>@{[&escape ($content)]}</pre>";
1126  そこにNewPageのような単語        } else {
1127  (大文字小文字混在している英文字列)          $r = &text_to_html ("[INS[\n[[$name]]: @{[&Resource('Embed:PageNotFound')]}\n]INS]\n", content_format => 'SuikaWiki/0.9');
1128  を書いて「保存」します。        }
1129        } else {    ## nested #EMBED
1130  =item 3.        $r = &text_to_html ("[INS[\n[[$name]]: @{[&Resource('Embed:Nested',escape=>1)]}\n]INS]\n", content_format => 'SuikaWiki/0.9');
1131        }
1132  保存すると、FrontPageのページが書き換わり、      return qq(<blockquote title="@{[&escape($name)]}" class="wiki-embed">$r<div class="cite-note">。リ<cite><a href="$url_cgi?@{[&encode($name)]}" class="wiki">@{[&escape($name)]}</a></cite>。ル</div></blockquote>);
1133  あなたが書いたNewPageという文字列の後ろに ? というリンクが表示されます。    } elsif ($embedded =~ /^\[\[\#randomlink:(.+)\]\]$/) {
1134  この ? はそのページがまだ存在しないことを示す印です。      return qq(<a href="$url_cgi?mycmd=RandomJump;x-param=@{[time.[0..9]->[rand 10]]}" class="wiki randomlink">$1</a>);
1135      } else {
1136  =item 4.      return $embedded;
1137      }
1138  その ? をクリックすると新しいページNewPageができますので、  }
1139  あなたの好きな文章をその新しいページに書いて保存します。  
1140    sub load_formatter (@) {
1141  =item 5.      for my $t (@_) {
1142            unless ($fmt{$t}) {
1143  NewPageページができるとFrontPageの ? は消えて、リンクとなります。              require Message::Util::Formatter;
1144                $fmt{$t} = Message::Util::Formatter->new;
1145  =back              for (@{$SuikaWiki::Plugin::List{'wiki'.$t}||[]}) {
1146                    $_->load_formatter ($fmt{$t}, type => 'wiki'.$t);
1147  =head1 テキスト整形のルール              }
1148            }
1149  =over 4      }
1150    }
1151  =item *  
1152    sub do_wikiform {
1153  連続した複数行はフィルされて表示されます。      my $content = $database{$form{mypage}};
1154        my $anchor = &get_new_anchor_index ($content);
1155  =item *      &load_formatter (qw/form_template form_option/);
1156        my $write = 0;
1157  空行は段落C<< <p> >>の区切りとなります。      my $i = 1;
1158        $content =~ s{$embed_command{form}}{
1159  =item *          my ($embed, $wfname, $template, $option) = ($&, $1, $3, $4);
1160            if (($wfname && $wfname eq $form{wikiform_targetform})
1161  HTMLのタグは書けません。              || $i == $form{wikiform_index}) {
1162                $template =~ s/\\(.)/$1/g;
1163  =item *              $option =~ s/\\(.)/$1/g;
1164                my $param = bless {}, 'SuikaWiki::Plugin';
1165  B<''ボールド''>のようにシングルクォート二つではさむと、              $param->{page} = $form{mypage};
1166  ボールドC<< <b> >>になります。              $param->{form_index} = $i;
1167                $param->{form_name} = $wfname;
1168  =item *              $param->{anchor_index} = $anchor;
1169                $param->{argv} = \%form;
1170  B<'''イタリック'''>のようにシングルクォート三つではさむと、              $param->{default_name} = $1 if $content =~ /default-name="([^"]+)"/;
1171  イタリックC<< <i> >>になります。              $param->{default_name} ||= &Resource('WikiForm:WikiComment:DefaultName');
1172                $fmt{form_option}->replace ($option, $param);
1173  =item *              my $t = 1;
1174                for (@{$param->{require}||[]}) {
1175  B<---->のようにマイナス4つがあると、                  (undef $t, last) unless length $param->{argv}->{'wikiform__'.$_};
1176  水平線C<< <hr> >>になります。              }
1177                $t = $fmt{form_template}->replace ($template, $param) if $t;
1178  =item *              if (length $t) {
1179                    if ($param->{output}->{reverse}) {
1180  行をB<*>ではじめると、                      $embed .= "\n" . $t;
1181  大見出しC<< <h2> >>になります。                  } else {
1182                        $embed = $t . "\n" . $embed;
1183  =item *                  }
1184                    $write = 1;
1185  行をB<**>ではじめると、                  $form{__comment_anchor_index} = $anchor
1186  小見出しC<< <h3> >>になります。                    if $param->{anchor_index_};  ## $anchor is used!
1187                }
1188  =item *              $form{__wikiform_anchor_index} = $i;
1189                undef $form{wikiform_targetform};  ## make sure never to match
1190  行をマイナス-ではじめると、              undef $form{wikiform_index};       ## with WikiForm in rest of page
1191  箇条書きC<< <ul> >>になります。          }
1192  マイナスの数が増えるとレベルが下がります(3レベルまで)          $i++; $embed;
1193        }ge;
1194      -項目1      unless ($write) {
1195      --項目1-1        #$content = "#?SuikaWiki/0.9\n\n" unless $content;
1196      --項目1-2        #$content .= "\n" unless $content =~ /\n$/s;
1197      -項目2        #
1198      -項目3      }
1199      --項目3-1      if ($write) {
1200      ---項目3-1-1          $form{mymsg} = $content;
1201      ---項目3-1-2          $form{mytouch} = 'on';
1202      --項目3-2          &do_write;
1203        } else {
1204  =item *          $form{mycmd} = 'read';
1205            &do_read;
1206  コロンを使うと、      }
1207  用語と解説文のリストC<< <dl> >>が書けます。  }
1208    
1209      :用語1:いろいろ書いた解説文1  sub code_convert {
1210      :用語2:いろいろ書いた解説文2    require Jcode;
1211      :用語3:いろいろ書いた解説文3      my ($contentref, $code) = (shift, shift || $kanjicode);
1212        $code = 'jis' if $code =~ /iso/;
1213  =item *      $code = 'euc' if $code =~ /euc/;
1214        $code = 'sjis' if $code =~ /shift/;
1215  リンク      $code = 'utf8' if $code =~ /utf/;
1216        $$contentref = Jcode->new ($contentref)->tr ("\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&,.:;?!`^_/|()[]{}+$%#*@='"~-><\ ))->$code;
1217  =over 4      return $$contentref;
1218    }
1219  =item *  
1220    sub do_diff {
1221  LinkToSomePageやFrontPageのように、      my $title = $form{mypage};
1222  英単語の最初の一文字を大文字にしたものが      &print_header($title, -noindex => 1);
1223  二つ以上連続したものはYukiWikiのページ名となり、      print qq(<h2>@{[&Resource('Diff:Title',escape=>1)]}</h2>);
1224  それが文章中に含まれるとリンクになります。      print qq(<p>@{[&Resource('Diff:Notice',escape=>1)]}</p>);
1225        print qq(<pre class="diff">);
1226  =item *      for (split(/\n/, &escape ($database->traverse_diff ($form{mypage})))) {
1227            if (/^\+(.*)/) {
1228  http://www.hyuki.com/ のようなURLは自動的にリンクになります。              print qq(<ins class="added">$1</ins>\n);
1229            } elsif (/^\-(.*)/) {
1230  =item *              print qq(<del class="deleted">$1</del>\n);
1231            } elsif (/^\=(.*)/) {
1232  二重の大かっこ[[ ]]でくくった文字列も、              print qq(<span class="same">$1</span>\n);
1233  YukiWikiのページ名になります。          } else {
1234  大かっこの中にはスペースを含めてはいけません。              print qq|??? $_\n|;
1235  日本語も使えます。          }
1236        }
1237  =back      print qq(</pre>);
1238        &print_footer($title);
1239  =item *  }
1240    
1241  行頭がスペースやタブで始まっていると、  sub do_rss {
1242  それは整形済みの段落C<< <pre> >>として扱われます。      eval q{use Yuki::RSS};
1243  プログラムの表示などに使うと便利です。      my $rss = new Yuki::RSS(
1244            version => '1.0',
1245            encoding => &get_charset_name ($kanjicode),
1246  =item *      );
1247        my $scheme = 'http';
1248  行を > ではじめると、      $scheme = lc $1 if $main::ENV{SERVER_PROTOCOL} =~ m#([A-Za-z0-9+.%-]+)#;
1249  引用文C<< <blockquote> >>が書けます。      my $myuri = "$scheme://$main::ENV{SERVER_NAME}:$main::ENV{SERVER_PORT}$url_cgi";
1250  >の数が多いとインデントが深くなります(3レベルまで)。      $rss->stylesheet (
1251          href      => $myuri . "?mycmd=TEXT_CSS;mypage=WikiStyle:RSS",
1252      >文章        type      => 'text/css',
1253      >文章      );
1254      >>さらなる引用      $rss->channel(
1255      >文章          title   => &Resource ('RSS:WikiTitle'),
1256            link    => $myuri,
1257  =back          description     => &Resource ('RSS:WikiDescription'),
1258            'dc:language'   => $lang,
1259  =head1 更新履歴      );
1260        my $recentchanges = $database{RecentChanges};
1261  =over 4      my $count = 0;
1262        foreach (split(/\n/, $recentchanges)) {
1263  =item *          last if ($count >= 15);
1264            if (/\[\[([^]]+)\]\]/) {
1265  2001年10月20日、Version 1.6.6。            my $title = $1;
1266              $rss->add_item (
1267  更新の衝突対策。              title       => &escape($title),
1268  元ページの簡単なチェックサムを取っておき、              link        => $myuri . '?' . &encode($title),
1269  更新前にチェックサムを比較する。              description => &escape(&get_subjectline($title,delimiter=>'')),
1270  修正個所はdigestという文字列を検索すれば分かる。              'dc:date'   => &get_info ($title, $info_LastModified),
1271  本来はMD5などでちゃんとやった方がいいのだけれど。            );
1272              $count++;
1273  衝突時に表示されるメッセージなどは「極悪」さんのページを参考にした。          }
1274        }
1275  =item *      # print RSS information (as XML).
1276        print <<"EOD"
1277  2001年10月17日、Version 1.6.5。  Content-type: application/xml; charset=@{[&get_charset_name ($kanjicode)]}
1278    
1279  プレビュー画面で、更新ボタンを押したときに送信される  @{[$rss->as_string]}
1280  メッセージの内容をinput要素のtype="hidden"を使って埋め込むのをやめる。  EOD
1281  代わりに、textarea要素を使う。  }
1282  再プレビュー用にmyspecial_を導入。でもきれいな対策ではない。  
1283    sub _rfc3339_date ($) {
1284  =item *    my @time = gmtime (shift);
1285      sprintf '%04d-%02d-%02dT%02d:%02d:%02d+00:00', $time[5]+1900,$time[4]+1,@time[3,2,1,0];
1286  2001年8月30日、Version 1.6.4。  }
1287    
1288  URLでダイレクトにページ名を指定しても、  sub is_exist_page {
1289  $WikiNameと$BracketName以外のページを作れないようにした。      my ($name) = @_;
1290  (is_valid_nameとis_editable参照)。      if ($use_exists) {
1291            return exists($database{$name});
1292  =item *      } else {
1293            return $database{$name};
1294  2001年8月30日、Version 1.6.3。      }
1295    }
1296  RecentChangesを編集・再編集不可とした。  
1297  編集不可ページは@uneditableにページ名を入れる。  sub __get_database ($) { $database{ $_[0] } }
1298    sub __set_database ($$) { $database{ $_[0] } = $_[1] }
1299  =item *  
1300    sub do_map {
1301  2001年2月25日、Version 1.6.1, 1.6.2。      my $page = $form{mypage};
1302        &print_header ($page);
1303  差分機能のバグ修正。      wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER});
1304  do_previewで'>'が扱えないバグを修正      wiki::useragent::add ($ENV{HTTP_USER_AGENT});
1305  (ユーザからの指摘)。      my ($r, $c) = get_search_result ($form{mypage});
1306        my $rl = wiki::referer::list_html ($form{mypage});
1307  =item *      print "<h2>@{[&Resource('Map:Title',escape=>1)]}</h2>\n<p>@{[&Resource('Map:Description',escape=>1)]}</p>\n";
1308        my %option = (level => 0+&Resource('Map:Depth'), weight_list => {}, not_exist => {},
1309  2001年2月22日、Version 1.6.0。        map_from_here => &Resource('Map:FromHere'),
1310  差分機能を実装した。        map_from_here_description => &Resource('Map:FromHereLong'));
1311        &wiki::map::make_list ($page, %option);
1312  =item *      print &wiki::map::list_to_html ($page, $option{weight_list}, %option);
1313        if ($c) {
1314  2001年2月19日、Version 1.5.4。        print qq{<h2 id="wikipage-see-also">@{[&Resource('SeeAlso',escape=>1)]}</h2>};
1315  画像ファイルへのリンクは画像にしてみた。        print $r;
1316        }
1317  =item *      if ($rl) {
1318          print qq(<div id="wikipage-referer"><h2>@{[&Resource('Referers',escape=>1)]}</h2>\n$rl</div>\n);
1319  2001年2月19日、Version 1.5.3。      }
1320  RecentChangesの中に削除したページがあるのをやめた。      &print_footer ($page);
1321  use strict;で引っかかる部分を少し整理(完全ではない)。  }
1322    
1323  =item *  my %_Resource;
1324    sub Resource ($;%) {
1325  2001年2月16日、Version 1.5.2。    my ($s, %o) = @_;
1326  textareaに表示およびプレビューする前に < や > を &lt; や &gt; に変換した    unless (defined $_Resource{$s}) {
1327  (do_preview, editpage, print_preview_buttons)。      $_Resource{$_[0]} = &wiki::resource::get ($s, $_Resource{__option});
1328      }
1329  =item *    $o{escape} ? &escape ($_Resource{$s}) : $_Resource{$s};
1330    }
1331  2000年12月27日、Version 1.5.1。  
1332  プレビュー画面を整理した。  package wiki::referer;
1333    sub add ($$) {
1334  =item *    my $page = shift;
1335      my $uri = shift;
1336  2000年12月22日、Version 1.5.0。    unless (ref $uri) {
1337  全体的にずいぶん書き直した。      require URI;
1338  一覧を別途作成するようにした(do_list)。      $uri = URI->new ($uri);
1339  書き込む前に確認画面を出すようにした(do_preview)。      ## Some schemes do not have query part.
1340  テキストの書き方を編集画面に入れた(do_edit, do_reedit)。      eval q{ $uri->query (undef) if $uri->query =~ /^[0-9]{6,8}$/ };
1341  WhatsNew→RecentChanges、TopPage→FrontPageに変更した。      $uri->fragment (undef);
1342      }
1343  =item *    $uri = $uri->canonical;
1344      return unless $uri;
1345  2000年12月20日、Version 1.1.0。    for my $regex (&get_dont_record) {
1346  tieを利用して、dbmopenが使えない場合でも動作するように修正。      return if $uri =~ /$regex/;
1347  利用者の1人である「極悪」さんから    }
1348  送っていただいたコードを元にしています。    my %list = get ($page);
1349      $list{ $uri }++;
1350  =item *    set ($page, \%list);
1351    }
1352  2000年9月5日、Version 1.0.2。  sub get ($) {
1353   <body color=...> → <body bgcolor=...>    my $page = shift;
1354  利用者からの指摘による。感謝。    split /"/, main::get_info ($page, 'Referer');
1355    }
1356  =item *  sub set ($%) {
1357      my $page = shift;
1358  2000年8月6日、Version 1.0.1を公開。    my $list = shift;
1359  C MAGAZINE(ソフトバンクパブリッシング)    main::set_info ($page, Referer => join '"', %$list);
1360  2000年10月号連載記事向け公開版。  }
1361  [[ ]] の最後が「望」のようにシフトJISで  
1362  0x5Dになる場合の回避を行なった。  sub get_dont_record () {
1363      map {s/\$/\\\$/g; s/\@/\\\@/g; $_}
1364  =item *    grep !/^#/,
1365      split /[\x0D\x0A]+/, &main::__get_database ('RefererDontRecord');
1366  2000年8月5日、Version 1.0.0を公開。  }
1367    sub get_site_name () {
1368  =item *    my @lines = grep /[^#]/, split /[\x0D\x0A]+/, &main::__get_database('RefererSiteName');
1369      my @item;
1370  2000年7月23日、Version 0.82を公開。    for (@lines) {
1371  編集時のリンクミス。      next if /^#/;
1372  <textarea>の属性変更。      my ($uri, $name) = split /\s+/, $_, 2;
1373        $uri =~ s/\$/\\\$/g;  $uri =~ s/\@/\\\@/g;  $uri =~ s/\//\\\//g;
1374  =item *      $name =~ s!([()/\\])!\\$1!g;  $name =~ s/\$([0-9]+)/).__decode (\${$1}).q(/g;
1375        push @item, [$uri, qq(q($name))];
1376  2000年7月22日、Version 0.81を公開。    }
1377  ロゴを組み込む。    @item;
1378    }
1379  =item *  
1380    sub list_html ($) {
1381  2000年7月21日、Version 0.80を公開。    my $page = shift;
1382  PODをCGI中に書き込む。    my %list = get ($page);
1383      my $r = '';
1384  =item *    my @name = get_site_name;
1385      for my $uri (sort keys %list) {
1386  2000年7月19日、Version 0.70を公開。      my $title;
1387  '''イタリック'''や、--、---、>>、>>>などを実装。      for my $item (@name) {
1388          if ($uri =~ /$item->[0]/) {
1389  =item *          $title = $uri;
1390            eval qq{\$title =~ s/^.*$item->[0].*\$/$item->[1]/e}
1391  2000年7月18日、Version 0.60を公開。            or die $@ ;#. qq{\$title =~ s/^.*$item->[0].*\$/$item->[1]/e};
1392  *太字*を''太字''に変更          last;
1393          }
1394  =item *      }
1395        my $euri = main::escape ($uri);
1396  2000年7月17日、Version 0.50を公開。      if ($title) {
1397          $r .= qq(<li>[$list{$uri}] <a href="$euri" title="URI: &lt;$euri&gt;">@{[main::escape ($title)]}</a></li>\n);
1398  =item *      } else {
1399          $r .= qq(<li>[$list{$uri}] &lt;<a href="$euri">$euri</a>&gt;</li>\n);
1400  2000年7月17日、さらにいろいろ追加する。      }
1401      }
1402  =item *    $r ? qq(<ul>$r</ul>\n) : '';
1403    }
1404  2000年7月16日、いろいろ追加。  
1405    sub __decode ($) {
1406  =item *    my $s = shift;
1407      $s =~ tr/+/ /;
1408  2000年7月15日、公開。    $s =~ s/%([0-9A-Fa-f][0-9A-Fa-f])/chr hex $1/ge;
1409      main::code_convert (\$s);
1410  =back  }
1411    
1412  =head1 TODO  package wiki::useragent;
1413    our $UseLog;
1414      - テキスト表示モード  
1415      - Charsetを明示。  sub add ($) {
1416      - textarea中の閉じタグ対応    my $s = shift;
1417      - メニューの英語表記付記    return unless length $s;
1418      - プレビューのボタンで、mymsgをinputのvalueに入れているが、改行をそのままvalueにいれてはいけないのではないか。    return unless $UseLog;
1419      - 「再編集」の機能はブラウザの back で充分ではないか。プレビューはもっとシンプルに。    $s =~ s/([\x00-\x08\x0A-\x1F\x25\x7F-\xFF])/sprintf '%%%02X', unpack 'C', $1/ge;
1420      - ページタイトル(Wikiname)が検索にかかるようにする。    my %ua;
1421      - InterWiki風の機能「URLを隠しつつ、リンクを張る」    for (split /\n/, &main::__get_database($main::PageName{UserAgentList})) {
1422        if (/^-\[(\d+)\] (.+)$/) {
1423  =head1 作者        my ($t, $n) = ($1, $2);
1424          $n =~ tr/\x0A\x0D//d;
1425      Copyright (C) 2000 by Hiroshi Yuki.        $ua{$n} = $t;
1426      結城浩 <hyuki@hyuki.com>      }
1427      http://www.hyuki.com/    }
1428      http://www.hyuki.com/yukiwiki/    $ua{$s}++;
1429      my $s = qq(#?SuikaWiki/0.9\n);
1430  質問、意見、バグ報告は hyuki@hyuki.com にメールしてください。    for (sort {$ua{$a} <=> $ua{$b}} keys %ua) {
1431        $s .= sprintf qq(-[%d] %s\n), $ua{$_}, $_;
1432  =head1 配布条件    }
1433      $main::database->STORE ($main::PageName{UserAgentList} => $s, -touch => 0);
1434  YukiWikiは、  }
1435  GNU General Public Licenseにて公開します。  
1436    package wiki::suikawikiconst;
1437  YukiWikiはフリーソフトです。  
1438  ご自由にお使いください。  sub to_hash ($;$) {
1439  自分好みのYukiWikiが作れるようにシンプルにしてあります。    my $page = shift;
1440      my $h = shift || {};
1441  =head1 謝辞    my $val;
1442      for my $line (split /\n/, $page) {
1443  本家のWikiWikiを作ったCunningham & Cunningham, Inc.に      $line =~ tr/\x0A\x0D//d;
1444  感謝します。      if ($val && $line =~ s/^\s+//) {
1445          $h->{$val} .= length $h->{$val} ? "\n" . $line : $line;
1446  YukiWikiを楽しんで使ってくださる      } elsif ($line =~ /^(.+):/) {
1447  ネット上の方々に感謝します。        $val = $1; $h->{$val} = '';
1448        }
1449  YukiWikiのロゴをデザインしてくださった橋本礼奈さん    }
1450  http://city.hokkai.or.jp/~reina/    $h;
1451  に感謝します。  }
1452    
1453  tieを使った版の元になるコードを送ってくださった  package SuikaWiki::Plugin;
1454  「極悪」さんに感謝します。    our $plugin_directory;  # defined in top of this file.
1455      our %List;
1456  =head1 参照リンク  
1457    sub escape ($$) { main::escape ($_[1]) }
1458  =over 4  sub unescape ($$) { main::unescape ($_[1]) }
1459    sub encode ($$) { main::encode ($_[1]) }
1460  =item *  sub decode ($$) { main::decode ($_[1]) }
1461    sub __get_datetime ($) { main::get_now () }
1462  YukiWikiホームページ  sub resource ($$;%) { shift; &main::Resource (@_) }
1463  http://www.hyuki.com/yukiwiki/  sub uri ($$) { $main::uri{$_[1]} }
1464    
1465  =item *  sub regist ($@) {
1466        my $pack = shift;
1467  本家のWikiWiki      for (@_) {
1468  http://c2.com/cgi/wiki?WikiWikiWeb          push @{$List{$_}}, $pack;
1469        }
1470  =item *  }
1471    
1472  本家のWikiWikiの作者(Cunningham & Cunningham, Inc.)  sub import_plugins () {
1473  http://c2.com/      opendir PDIR, $plugin_directory;
1474        my @plugin = grep {s/\.pm$//} readdir (PDIR);
1475  =item *      closedir PDIR;
1476        for (@plugin) {
1477  YukiWikiのロゴデザインをしてくださった橋本礼奈さんのページ          eval qq{ use SuikaWiki::Plugin::$_ } unless /[^A-Za-z0-9_]/;
1478  http://city.hokkai.or.jp/~reina/          push @{$List{_all}}, qq(SuikaWiki::Plugin::$_);
1479        }
1480  =back  }
1481    
1482  =cut  &import_plugins ();
1483    
1484    package wiki::conneg;
1485    
1486    ## BUG: this parser isn't strict.
1487    sub get_accept_lang (;$) {
1488      my $alang = shift || $main::ENV{HTTP_ACCEPT_LANGUAGE};
1489      my %alang = (ja => 0.0002, en => 0.0001);
1490      my $i = 0.1;
1491      for (split /\s*,\s*/, $alang) {
1492        tr/\x09\x0A\x0D\x20//d;
1493        if (/((?:(?!;q=).)+)(?:;q="?([0-9.]+)"?)?/) {
1494          my $l = lc $1; $l =~ tr/\x22\x5C//d;
1495          $alang{$l} = (defined $2 ? $2 : 1.000)*1000;
1496          $alang{$l} += $i unless $alang{$l} == 0;
1497          $i -= 0.001;
1498        }
1499      }
1500      \%alang;
1501    }
1502    
1503    package wiki::resource;
1504    
1505    sub get ($;\%) {
1506      my ($resname, $option) = @_;
1507      $option->{accept_language} ||= &wiki::conneg::get_accept_lang ();
1508      $option->{resource} ||= {};
1509      my $v;
1510      for my $lang (sort {$option->{accept_language}->{$b} <=> $option->{accept_language}->{$a}} grep {$option->{accept_language}->{$_}!=0} keys %{$option->{accept_language}}) {
1511        while (length $lang) {
1512          unless ($option->{accept_language}->{defined $option->{accept_language}->{$lang} ? $lang : '*'} == 0) {
1513            $option->{resource}->{$lang} ||= &wiki::suikawikiconst::to_hash (&main::__get_database('WikiResource:'.$lang));
1514            $v = $option->{resource}->{$lang}->{$resname};
1515            last if defined $v;
1516          }
1517          $lang =~ s/[^+-]*$//; $lang =~ s/[+-]$//;
1518        }
1519        last if defined $v;
1520      }
1521      defined $v ? $v : $resname;
1522    }
1523    
1524    package wiki::map;
1525    
1526    sub make_list ($;%) {
1527      my ($page, %option) = @_;
1528      $option{level} ||= 3;
1529      my %weight;
1530      my $content = &main::__get_database ($page);
1531      $content =~ s{^\#\?([^\x0A\x0D]+)}{
1532        if ($1 =~ /import="([^"]+)"/) {
1533          for (split /\s*,\s*/, $1) {
1534            $weight{$_} += 2;
1535          }
1536        }
1537        $&;
1538      }ges;
1539      ## Bug: this code does not support content type.
1540      $content =~ s{\[\[((?!\#)[^]]+)\](?:>>\d+)?\]}{
1541        $weight{$1}++; $&;
1542      }ge;
1543      delete $weight{$page};        ## Delete myself
1544      for my $page (keys %weight) {
1545        my $w = ($content =~ s/\Q$page\E/$&/g);
1546        $weight{$page} += $w + $weight{$page}; ## Weight of [[name]] is x2.
1547        ($weight{$page} *= 0.1, $option{not_exist}->{$page} = 1) unless &main::is_exist_page ($page);
1548      }
1549      $option{weight_list}->{$page} = \%weight;
1550      if (--$option{level}) {
1551        for my $page (keys %weight) {
1552          &make_list ($page, %option) unless $option{weight_list}->{$page};
1553        }
1554      }
1555      $option{weight_list};
1556    }
1557    
1558    sub list_to_html ($$;%) {
1559      my ($Page, $wlist, %option) = @_;
1560      my $r = '';
1561      $option{outputed}->{$Page} = 1;
1562      for my $page (sort {$wlist->{$Page}->{$b} <=> $wlist->{$Page}->{$a}} keys %{$wlist->{$Page}}) {
1563        $r .= qq(<li><span class="weight">[@{[0+$wlist->{$Page}->{$page}]}]</span> <a href="$main::url_cgi?@{[&main::encode($page)]}" class="wiki@{[$option{not_exist}->{$page}?' not-exist':'']}">@{[&main::escape ($page).($option{not_exist}->{$page}?qq(<span class="mark">@{[&main::Resource('JumpAndEditWikiPageMark',escape=>1)]}</span>):'')]}</a> <a href="$main::url_cgi?mycmd=map;mypage=@{[&main::encode($page)]}" class="wiki-cmd map-from-here" title="@{[&main::escape($option{map_from_here_description})]}">@{[&main::escape($option{map_from_here})]}</a> <span class="summary">@{[&main::escape(&main::get_subjectline($page))]}</span>);
1564        unless ($option{outputed}->{$page}) {
1565          $r .= &list_to_html ($page, $wlist, %option);
1566        }
1567        $r .= "</li>\n";
1568      }
1569      $r ? qq(<ul class="map">$r</ul>) : '';
1570    }
1571    
1572    package main;
1573    &main;
1574    exit 0;
1575    
1576    1;
1577    __END__
1578    =head1 NAME
1579    
1580    wiki.cgi --- SuikaWiki: Yet yet another Wiki engine
1581    
1582    =head1 AUTHORS
1583    
1584    Hiroshi Yuki <hyuki@hyuki.com> <http://www.hyuki.com/yukiwiki/>
1585    
1586    Makio Tsukamoto <http://digit.que.ne.jp/>
1587    
1588    Wakaba <w@suika.fam.cx>
1589    
1590    =head1 LICENSE
1591    
1592    Copyright (C) 2000-2003 AUTHORS
1593    
1594    This program is free software; you can redistribute it and/or
1595    modify it under the same terms as Perl itself.
1596    
1597    =cut

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.46

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24