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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24