/[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.20 by wakaba, Sun Jun 2 06:37:36 2002 UTC revision 1.30 by wakaba, Wed Nov 13 08:28:15 2002 UTC
# Line 70  my $modifier_dbtype = 'YukiWikiDB'; Line 70  my $modifier_dbtype = 'YukiWikiDB';
70  # my $modifier_sendmail = '/usr/sbin/sendmail -t -n'; # Your sendmail.  # my $modifier_sendmail = '/usr/sbin/sendmail -t -n'; # Your sendmail.
71  my $modifier_sendmail = ''; # If you don't need mail notification.  my $modifier_sendmail = ''; # If you don't need mail notification.
72  my $modifier_dir_data = './wikidata'; # Your data directory.  my $modifier_dir_data = './wikidata'; # Your data directory.
73  my $modifier_rss_title = "WalWiki $walversion";  my $modifier_rss_title = "SuikaWiki $walversion";
74  my $modifier_rss_link = 'http://suika.fam.cx/~wakaba/-temp/wiki2/wiki'; # Blank is not allowed.  my $modifier_rss_link = 'http://suika.fam.cx/~wakaba/-temp/wiki2/wiki'; # Blank is not allowed.
75  my $modifier_rss_description = 'This is WalWiki, yet another Wiki clone based on YukiWiki';  my $modifier_rss_description = 'This is SuikaWiki';
76  ##############################  ##############################
77  #  #
78  # You MAY modify following variables.  # You MAY modify following variables.
# Line 82  my $file_resource = "$modifier_dir_data/ Line 82  my $file_resource = "$modifier_dir_data/
82  my $file_FrontPage = "$modifier_dir_data/frontpage.txt";  my $file_FrontPage = "$modifier_dir_data/frontpage.txt";
83  my $file_conflict = "$modifier_dir_data/conflict.txt";  my $file_conflict = "$modifier_dir_data/conflict.txt";
84  my $file_format = "$modifier_dir_data/format.txt";  my $file_format = "$modifier_dir_data/format.txt";
85  my $url_cgi = 'wiki';  my $url_cgi = '/~wakaba/-temp/wiki/wiki';       ## MUST be started from '/'
86  my $url_stylesheet = 'wiki-style.css';  my $url_stylesheet = $url_cgi.'?mycmd=TEXT_CSS;mypage=WikiHTMLStyle';
87  my $icontag = '<img src="/icons/folder" alt="*" width="40" height="40" />';  my $icontag = '<img src="/icons/folder" alt="*" width="40" height="40" />';
88  my $maxrecent = 50;  my $maxrecent = 50;
89  my $cols = 80;  my $cols = 80;
# Line 110  my $SearchPage = 'SearchPage'; Line 110  my $SearchPage = 'SearchPage';
110  my $CreatePage = 'CreatePage';  my $CreatePage = 'CreatePage';
111  my $ErrorPage = 'ErrorPage';  my $ErrorPage = 'ErrorPage';
112  my $RssPage = 'RssPage';  my $RssPage = 'RssPage';
113    my $NAME_OF_WikiPageLicense = 'WikiPageLicense';
114  my $AdminSpecialPage = 'Admin Special Page'; # must include spaces.  my $AdminSpecialPage = 'Admin Special Page'; # must include spaces.
115  ##############################  ##############################
116  # my $wiki_name = '\b([A-Z][a-z]+([A-Z][a-z]+)+)\b';        # Walrus del (2)  # my $wiki_name = '\b([A-Z][a-z]+([A-Z][a-z]+)+)\b';        # Walrus del (2)
# Line 117  my $wiki_name   = '\b([A-Z][a-z]+([A-Z][ Line 118  my $wiki_name   = '\b([A-Z][a-z]+([A-Z][
118  my $bracket_name = '\[\[(\S+?)\]\]';  my $bracket_name = '\[\[(\S+?)\]\]';
119  my $embedded_name = '\[\[(#\S+?)\]\]';  my $embedded_name = '\[\[(#\S+?)\]\]';
120  my $interwiki_definition = '\[\[(\S+?)\ (\S+?)\]\]';  my $interwiki_definition = '\[\[(\S+?)\ (\S+?)\]\]';
121  my $interwiki_name = '([^:]+):([^:].*)';  my $interwiki_name = 'i:([^:]+):([^:].*)';
122  ##############################  ##############################
123  my $embed_comment = '[[#comment]]';  my $embed_comment = '[[#comment]]';
124  my $embed_rcomment = '[[#rcomment]]';  my $embed_rcomment = '[[#rcomment]]';
125    my $embed_comment_Name_Prompt = '名前:';
126    my $DEFAULT_embed_comment_name = '名無しさん';
127  my $embed_interwiki = '^\[\[#(box|text|password):(\S+)\]\]$';    # Walrus add (5)  my $embed_interwiki = '^\[\[#(box|text|password):(\S+)\]\]$';    # Walrus add (5)
128    my %embed_command = (
129            searched        => '^\[\[#searched:([^\]]+)\]\]$',
130    );
131  ##############################  ##############################
132  my $info_LastModified = 'LastModified';  my $info_LastModified = 'LastModified';
133  my $info_IsFrozen = 'IsFrozen';  my $info_IsFrozen = 'IsFrozen';
# Line 158  my %page_command = ( Line 164  my %page_command = (
164  );  );
165  my %command_do = (  my %command_do = (
166      read => \&do_read,      read => \&do_read,
167        TEXT_CSS => \&do_output_css,
168      edit => \&do_edit,      edit => \&do_edit,
169      adminedit => \&do_adminedit,      adminedit => \&do_adminedit,
170      adminchangepasswordform => \&do_adminchangepasswordform,      adminchangepasswordform => \&do_adminchangepasswordform,
# Line 170  my %command_do = ( Line 177  my %command_do = (
177      createresult => \&do_createresult,      createresult => \&do_createresult,
178      FrontPage => \&do_FrontPage,      FrontPage => \&do_FrontPage,
179      comment => \&do_comment,      comment => \&do_comment,
180        RandomJump  => \&do_random_jump,
181      rss => \&do_rss,      rss => \&do_rss,
182      diff => \&do_diff,      diff => \&do_diff,
183      interwikibox => \&do_interwiki_box, # Walrus add (5)      interwikibox => \&do_interwiki_box, # Walrus add (5)
# Line 198  sub main { Line 206  sub main {
206  }  }
207    
208  sub do_read {  sub do_read {
209      &print_header($form{mypage});    my $content = $database{$form{mypage}};
210      &print_content($database{$form{mypage}});    my $lm = &get_info($form{mypage}, $info_LastModified);
211      &print_footer($form{mypage});    wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER});
212      my ($r, $c) = get_search_result ($form{mypage});
213      my $rl = wiki::referer::list_html ($form{mypage});
214      my @toc;
215      push @toc, qq(-<a href="#wikipage-see-also">See Also</a>) if $c;
216      push @toc, qq(-<a href="#wikipage-referer">参照元</a>) if $rl;
217        my $cf = 'SuikaWiki/0.9';
218        ## Should be support at least:
219        ## - 'SuikaWiki/0.9' CRLF
220        ## - 'H2H/' ("0.9" / "1.0" / "1.1") CRLF
221        ## - "/*" WSP* 'W3C-CSS/' ("1.0" / "2.0") "*/" CRLF
222        $cf = $1 if $content =~ s#^(?:/\*\s*|[\#<]\?)?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:[^0-9.][^\x0D\x0A]*)?)[\x0D\x0A]+##s;
223        if ($cf =~ m!^(?:\#\?)?SuikaWiki/0.9(?:$|\s)!) {
224          &print_header ($form{mypage}, -last_modified => $lm,
225            -content_format => $cf, -noindex => $cf =~ /obsoleted="yes"/);
226          &print_content ($content, content_format => $cf, last_modified => $lm,
227            -toc => \@toc);
228          print &text_to_html (q([[#comment]])) unless $cf =~ /obsoleted="yes"/;
229        } else {
230          &print_header($form{mypage}, -last_modified => $lm);
231          print "<pre>@{[&escape($content)]}</pre>";
232        }
233        if ($c) {
234          print q{<h2 id="wikipage-see-also">See also</h2>};
235          print $r;
236        }
237        if ($rl) {
238          print qq(<div id="wikipage-referer"><h2>参照元</h2>\n$rl</div>\n);
239        }
240      &print_footer($form{mypage}, $lm);
241    }
242    
243    sub do_output_css {
244      my $content = $database{$form{mypage}};
245      if ($content =~ m#^\s*/\*\s*W3C-CSS#) {
246        my $lm = &get_info($form{mypage}, $info_LastModified);
247        print "Content-Type: text/css; charset=$charset\n";
248        print "Last-Modified: $lm\n";
249        print "\n";
250        print $content;
251      } else {
252        print "Status: 406 Unsupported Media Type\n";
253        &print_header('WikiPageIsNotCSS', -noindex => 1);
254        &print_content($database{WikiPageIsNotCSS});
255        &print_footer('WikiPageIsNotCSS');
256      }
257  }  }
258    
259  sub do_edit {  sub do_edit {
260      my ($page) = &unarmor_name(&armor_name($form{mypage}));      my ($page) = &unarmor_name(&armor_name($form{mypage}));
261      &print_header($page);      &print_header($page, -noindex => 1);
262      if (not &is_editable($page)) {      if (not &is_editable($page)) {
263          &print_message($resource{cantchange});          &print_message($resource{cantchange});
264      } elsif (&is_frozen($page)) {      } elsif (&is_frozen($page)) {
# Line 213  sub do_edit { Line 266  sub do_edit {
266      } else {      } else {
267          &print_editform($database{$page}, &get_info($page, $info_LastModified), admin=>0);          &print_editform($database{$page}, &get_info($page, $info_LastModified), admin=>0);
268      }      }
269        wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER});
270        my ($r, $c) = get_search_result ($form{mypage});
271        my $rl = wiki::referer::list_html ($form{mypage});
272        if ($c) {
273          print q{<h2 id="wikipage-see-also">See also</h2>};
274          print $r;
275        }
276        if ($rl) {
277          print qq(<div id="wikipage-referer"><h2>参照元</h2>\n$rl</div>\n);
278        }
279      &print_footer($page);      &print_footer($page);
280  }  }
281    
282  sub do_adminedit {  sub do_adminedit {
283      my ($page) = &unarmor_name(&armor_name($form{mypage}));      my ($page) = &unarmor_name(&armor_name($form{mypage}));
284      &print_header($page);      &print_header($page, -noindex => 1);
285      if (not &is_editable($page)) {      if (not &is_editable($page)) {
286          &print_message($resource{cantchange});          &print_message($resource{cantchange});
287      } else {      } else {
# Line 229  sub do_adminedit { Line 292  sub do_adminedit {
292  }  }
293    
294  sub do_adminchangepasswordform {  sub do_adminchangepasswordform {
295      &print_header($AdminChangePassword);      &print_header($AdminChangePassword, -noindex => 1);
296      &print_passwordform;      &print_passwordform;
297      &print_footer($AdminChangePassword);      &print_footer($AdminChangePassword);
298  }  }
# Line 256  EOD Line 319  EOD
319      my $crypted = crypt($form{mynewpassword}, "$salt1$salt2");      my $crypted = crypt($form{mynewpassword}, "$salt1$salt2");
320      &set_info($AdminSpecialPage, $info_AdminPassword, $crypted);      &set_info($AdminSpecialPage, $info_AdminPassword, $crypted);
321    
322      &print_header($CompletedSuccessfully);      &print_header($CompletedSuccessfully, -noindex => 1);
323      &print_message($resource{passwordchanged});      &print_message($resource{passwordchanged});
324      &print_footer($CompletedSuccessfully);      &print_footer($CompletedSuccessfully);
325  }  }
# Line 266  sub do_index { Line 329  sub do_index {
329      print qq(<ul>);      print qq(<ul>);
330      foreach my $page (sort keys %database) {      foreach my $page (sort keys %database) {
331          if (&is_editable($page)) {          if (&is_editable($page)) {
332              print qq(<li><a href="$url_cgi?@{[&encode($page)]}">$page</a>@{[&escape(&get_subjectline($page))]}</li>);              print qq(<li><a href="$url_cgi?@{[&encode($page)]}">@{[&escape($page)]}</a>@{[&escape(&get_subjectline($page))]}</li>);
333              # print qq(<li>@{[&get_info($page, $info_IsFrozen)]}</li>);              # print qq(<li>@{[&get_info($page, $info_IsFrozen)]}</li>);
334              # print qq(<li>@{[0 + &is_frozen($page)]}</li>);              # print qq(<li>@{[0 + &is_frozen($page)]}</li>);
335          }          }
# Line 281  sub do_write { Line 344  sub do_write {
344      }      }
345    
346      if (not &is_editable($form{mypage})) {      if (not &is_editable($form{mypage})) {
347          &print_header($form{mypage});          &print_header($form{mypage}, -noindex => 1);
348          &print_message($resource{cantchange});          &print_message($resource{cantchange});
349          &print_footer($form{mypage});          &print_footer($form{mypage});
350          return;          return;
# Line 308  sub do_write { Line 371  sub do_write {
371              &update_recent_changes;              &update_recent_changes;
372          }          }
373          &set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen});          &set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen});
374          &print_header($CompletedSuccessfully);          &print_header($CompletedSuccessfully, -noindex => 1, -goto => $url_cgi.'?'.&encode($form{mypage}).($form{__comment_anchor_index}?"#anchor-$form{__comment_anchor_index}":''));
375          &print_message($resource{saved});          &print_message($resource{saved});
376          &print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}");          &print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}");
377          &print_footer($CompletedSuccessfully);          &print_footer($CompletedSuccessfully);
# Line 319  sub do_write { Line 382  sub do_write {
382          if ($form{mytouch}) {          if ($form{mytouch}) {
383              &update_recent_changes;              &update_recent_changes;
384          }          }
385          &print_header($form{mypage});          &print_header($form{mypage}, -noindex => 1);
386          &print_message($resource{deleted});          &print_message($resource{deleted});
387          &print_footer($form{mypage});          &print_footer($form{mypage});
388      }      }
# Line 332  sub do_searchform { Line 395  sub do_searchform {
395  }  }
396    
397  sub do_search {  sub do_search {
398      my $word = &escape($form{mymsg});      my $word = $form{mymsg};
399      &print_header($SearchPage);      &print_header($SearchPage);
400      &print_searchform($word);      &print_searchform(&escape($word));
401      my $counter = 0;      print scalar get_search_result ($word, -output_not_found => 1, -match_myself => 1);
     foreach my $page (sort keys %database) {  
         next if $page =~ /^$RecentChanges$/;  
         if ($database{$page} =~ /\Q$form{mymsg}\E/ or $page =~ /\Q$form{mymsg}\E/) {  
             if ($counter == 0) {  
                 print qq|<ul>|;  
             }  
             print qq(<li><a href ="$url_cgi?@{[&encode($page)]}">$page</a>@{[&escape(&get_subjectline($page))]}</li>);  
             $counter++;  
         }  
     }  
     if ($counter == 0) {  
         &print_message($resource{notfound});  
     } else {  
         print qq|</ul>|;  
     }  
402      &print_footer($SearchPage);      &print_footer($SearchPage);
403  }  }
404    
405    sub get_search_result ($;%) {
406      my $word = shift;
407      my %option = @_;
408      my @r;
409      foreach my $page (keys %database) {
410        next if $page eq $RecentChanges || ($page eq $word && !$option{-match_myself});
411        my $content = $database{$page};
412        my $cf = 'SuikaWiki/0.9';
413        $cf = $1 if $content =~ s/^\#\?([^\x0A\x0D]+)//s;
414        next if $cf =~ /obsoleted="yes"/;
415        if (index ($page, $word) > -1) {
416          my $c = $content =~ s/\Q$word\E/$word/g;
417          push @r, [$page, $c+20];
418        } elsif (index ($word, $page) > -1) {
419          my $c = $content =~ s/\Q$word\E/$word/g;
420          push @r, [$page, $c+10];
421        } elsif (my $c = $content =~ s/\Q$word\E/$word/g) {
422          push @r, [$page, $c];
423        }
424      }
425      my $em = sub { my $s = shift; $s =~ s#(\Q$word\E)#<em>$1</em>#g; $s };
426      my $r = join "\n", map {qq(<li>[$_->[1]] <a href ="$url_cgi?@{[&encode($_->[0])]}" class="wiki">@{[&$em(&escape($_->[0]))]}</a> <span class="wikipage-summary">@{[&$em(&escape(&get_subjectline($_->[0])))]}</span></li>)} sort {$b->[1] <=> $a->[1] || $a->[0] cmp $b->[0]} @r;
427      $r = qq|<ul class="search-result">$r</ul>| if $r;
428      get_message ($resource{notfound}) if @r == 0 && $option{-output_not_found};
429      wantarray? ($r, scalar @r): $r;
430    }
431    
432  sub do_create {  sub do_create {
433      &print_header($CreatePage);      &print_header($CreatePage);
434      print <<"EOD";      print <<"EOD";
# Line 367  EOD Line 442  EOD
442      &print_footer($CreatePage);      &print_footer($CreatePage);
443  }  }
444    
445    sub do_random_jump {
446      my @list = keys %database;
447      my $name = &encode ($list[rand @list]);
448      my ($scheme) = 'http';
449      $scheme = $1 if $main::ENV{SERVER_PROTOCOL} =~ m#([A-Za-z0-9+.%-]+)#;
450      print "Location: $scheme://$main::ENV{SERVER_NAME}:$main::ENV{SERVER_PORT}$url_cgi?$name\n";
451      print "\n";
452    }
453    
454  sub do_FrontPage {  sub do_FrontPage {
455      open(FILE, $file_FrontPage) or &print_error("($file_FrontPage)");      open(FILE, $file_FrontPage) or &print_error("($file_FrontPage)");
456      my $content = join('', <FILE>);      my $content = join('', <FILE>);
# Line 379  sub do_FrontPage { Line 463  sub do_FrontPage {
463    
464  sub print_error {  sub print_error {
465      my ($msg) = @_;      my ($msg) = @_;
466      &print_header($ErrorPage);      &print_header($ErrorPage, -noindex => 1);
467      print qq(<p><strong class="error">$msg</strong></p>);      print qq(<p><strong class="error">$msg</strong></p>);
468      &print_footer($ErrorPage);      &print_footer($ErrorPage);
469      exit(0);      exit(0);
470  }  }
471    
472  sub print_header {  sub print_header ($;%) {
473      my ($page) = @_;      my ($page, %option) = @_;
474      my $bodyclass = "normal";      my $bodyclass = "normal";
     my $editable = 0;  
     my $admineditable = 0;  
475      if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) {      if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) {
         $editable = 0;  
         $admineditable = 1;  
476          $bodyclass = "frozen";          $bodyclass = "frozen";
     } elsif (&is_editable($page) and $form{mycmd} =~ /^(read|write)$/) {  
         $admineditable = 1;  
         $editable = 1;  
     } else {  
         $editable = 0;  
477      }      }
478        $bodyclass .= " wiki-page-obsoleted" if $option{-content_format} =~ /obsoleted="yes"/;
479        print qq{Refresh: 0; url="$option{-goto}"\n} if $option{-goto};
480        print qq{Last-Modified: $option{-last_modified}\n} if $option{-last_modified};
481      my $cookedpage = &encode($page);      my $cookedpage = &encode($page);
482        my $escapedpage = &escape($page);
483      print <<"EOD";      print <<"EOD";
484  Content-type: text/html; charset=$charset  Content-type: text/html; charset=$charset
485  Content-Language: $lang  Content-Language: $lang
486  Content-Style-Type: text/css  Content-Style-Type: text/css
487    
488    <!--
489  <!DOCTYPE html  <!DOCTYPE html
490      PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"      PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
491      "http://www.w3.org/TR/html4/loose.dtd">      "http://www.w3.org/TR/html4/loose.dtd"> + RUBY -->
492  <html lang="$lang">  <html lang="$lang">
493  <head>  <head>
494      <title>$page @{[&escape(&get_subjectline($page))]}</title>      <title>$escapedpage</title>
495      <link rel="index" href="$url_cgi?$IndexPage">      <link rel="index" href="$url_cgi?$IndexPage">
496      <link rev="made" href="mailto:$modifier_mail">      <link rel="help" href="$url_cgi?WikiHelp">
497      <link rel="stylesheet" type="text/css" href="$url_stylesheet">      <link rel="copyright" href="$url_cgi?$NAME_OF_WikiPageLicense">
498        <link rel="stylesheet" type="text/css" href="@{[&escape($url_stylesheet)]}">
499        @{[$option{-noindex} ? q(<meta name="ROBOTS" content="NOINDEX">) : '']}
500  </head>  </head>
501  <body class="$bodyclass">  <body class="$bodyclass">
502    EOD
503      &print_navigate_links ($page);
504      print <<EOD;
505    <h1 class="header">@{[&escape($page)]}</h1>
506    EOD
507    }
508    
509    sub print_navigate_links (@) {
510      my ($page) = @_;
511        my $editable = 0;
512        my $admineditable = 0;
513        if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) {
514            $editable = 0;
515            #$admineditable = 1;
516        } elsif (&is_editable($page) and $form{mycmd} =~ /^(read|write)$/) {
517            #$admineditable = 1;
518            $editable = 1;
519        } else {
520            $editable = 0;
521        }
522        my $cookedpage = &encode($page);
523      print <<EOH;
524  <div class="tools">  <div class="tools">
525      @{[ $admineditable      @{[ $admineditable
526          ? qq(<a title="$resource{admineditthispage}" href="$url_cgi?mycmd=adminedit;mypage=$cookedpage">$resource{admineditbutton}</a> | )          ? qq(<a title="$resource{admineditthispage}" href="$url_cgi?mycmd=adminedit;mypage=$cookedpage">$resource{admineditbutton}</a> | )
527          : qq()          : qq()
528      ]}      ]}
529      @{[ $editable      @{[ $editable
530          ? qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedpage">$resource{editbutton}</a> | )          ? #qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedpage" accesskey="E">$resource{editbutton} <kbd>E</kbd></a> | )
531            qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedpage" accesskey="E">編集</a> | )
532          : qq()          : qq()
533      ]}      ]}
534      @{[ $admineditable      @{[ $admineditable
535          ? qq(<a href="$url_cgi?mycmd=diff;mypage=$cookedpage">$resource{diffbutton}</a> | )          ? qq(<a href="$url_cgi?mycmd=diff;mypage=$cookedpage">$resource{diffbutton}</a> | )
536          : qq()          : qq()
537      ]}      ]}
538      <a href="$url_cgi?$CreatePage">$resource{createbutton}</a> |      <a href="$url_cgi?$CreatePage" class="wiki">新規</a> |
539      <a href="$url_cgi?$IndexPage">$resource{indexbutton}</a> |      <a href="$url_cgi?$IndexPage" class="wiki">$resource{indexbutton}</a> |
540      <a href="$url_cgi?$RssPage">$resource{rssbutton}</a> |      <a href="$url_cgi?$FrontPage" class="wiki">首頁</a> |
541      <a href="$url_cgi?$FrontPage">$FrontPage</a> |      <a href="$url_cgi?$SearchPage" class="wiki">$resource{searchbutton}</a> |
542      <a href="$url_cgi?$SearchPage">$resource{searchbutton}</a> |      <a href="$url_cgi?mycmd=RandomJump;x-param=@{[time.[0..9]->[rand 10]]}" class="wiki randomlink">どこか</a> |
543      <a href="$url_cgi?$RecentChanges">$resource{recentchangesbutton}</a>      <a href="$url_cgi?$RecentChanges" class="wiki">最新</a>
544  </div>  </div>
545  <h1 class="header"><a  EOH
546      title="$resource{searchthispage}"  <<EOH;  ## temp
547      href="$url_cgi?mycmd=search;mymsg=$cookedpage">$page</a>@{[&escape(&get_subjectline($page))]}</h1>      <a href="$url_cgi?$CreatePage" class="wiki">$resource{createbutton}</a> |
548  EOD      <a href="$url_cgi?$IndexPage" class="wiki">$resource{indexbutton}</a> |
549    <!--    <a href="$url_cgi?$RssPage" class="wiki">$resource{rssbutton}</a> | -->
550        <a href="$url_cgi?$FrontPage" class="wiki">$FrontPage</a> |
551        <a href="$url_cgi?$SearchPage" class="wiki">$resource{searchbutton}</a> |
552        <a href="$url_cgi?mycmd=RandomJump;x-param=@{[time.[0..9]->[rand 10]]}" class="wiki randomlink">どこか</a> |
553        <a href="$url_cgi?$RecentChanges" class="wiki">$resource{recentchangesbutton}</a>
554    </div>
555    EOH
556  }  }
557    
558  sub print_footer {  sub print_footer {
559      my ($page) = @_;      my ($page, $lm) = @_;
560      $walrus_log = ($walrus_debugging) ? &text_to_html("----\n$walrus_log") : '';    # Walrus add (debug)      $walrus_log = ($walrus_debugging) ? &text_to_html("----\n$walrus_log") : '';    # Walrus add (debug)
561      # Walrus mod (1) start      # Walrus mod (1) start
562  my $cvslog = '$Revision$ $Date$';    my $cvslog1 = q$Revision$;
563      print <<"EOD";    my $cvslog2 = q$Date$;
564      print_navigate_links ($page);
565      print <<"EOD";
566    @{[ $lm ? qq(<div id="wikipage-last-modified">Last modified: $lm</div>) : '' ]}
567  <div class="footer">  <div class="footer">
568  <p>  <a href="http://www.hyuki.com/yukiwiki/" title="$version &copy; 2000-2002 by Hiroshi Yuki">YukiWiki</a> <a href="http://digit.que.ne.jp/work/" title="$walversion &copy; 2000-2002 by Makio Tsukamoto">WalWiki</a>
569  <a href="http://digit.que.ne.jp/work/">WalWiki</a> $walversion &copy; 2000-2002 by <a href="http://digit.que.ne.jp/">Makio Tsukamoto</a>.<br />  <a href="/gate/cvs/wakaba/wiki/" title="CVS Repository of this script ($cvslog2)">SuikaWiki $cvslog1</a>
 based on <a href="http://www.hyuki.com/yukiwiki/">YukiWiki</a> $version &copy; 2000-2002 by <a href="http://www.hyuki.com/">Hiroshi Yuki</a>.<br />  
 <a href="/gate/cvs/wakaba/wiki/" title="CVS Repository">  
 $cvslog  
 </a>  
 </p>  
570  <div class="navigation">  <div class="navigation">
571  [<a href="/" title="このサーバーの首頁">/</a>  [<a href="/" title="このサーバーの首頁">/</a>
572  <a href="/map" title="このサーバーの案内">地図</a>  <a href="/map" title="このサーバーの案内">地図</a>
# Line 486  EOD Line 596  EOD
596  sub escape {  sub escape {
597      my $s = shift;      my $s = shift;
598      $s =~ s|\r\n|\n|g;      $s =~ s|\r\n|\n|g;
599      $s =~ s|\&|&amp;|g;      $s =~ s|&|&amp;|g;
600      $s =~ s|<|&lt;|g;      $s =~ s|<|&lt;|g;
601      $s =~ s|>|&gt;|g;      $s =~ s|>|&gt;|g;
602      $s =~ s|"|&quot;|g;      $s =~ s|"|&quot;|g;
# Line 496  sub escape { Line 606  sub escape {
606  sub unescape {  sub unescape {
607      my $s = shift;      my $s = shift;
608      # $s =~ s|\n|\r\n|g;      # $s =~ s|\n|\r\n|g;
609      $s =~ s|\&amp;|\&|g;      $s =~ s|&lt;|<|g;
610      $s =~ s|\&lt;|\<|g;      $s =~ s|&gt;|>|g;
611      $s =~ s|\&gt;|\>|g;      $s =~ s|&quot;|"|g;
612      $s =~ s|\&quot;|\"|g;      $s =~ s|&amp;|&|g;
613      return $s;      return $s;
614  }  }
615    
616  sub print_content {  sub print_content ($;$) {
617      my ($rawcontent) = @_;      my ($rawcontent, %option) = @_;
618      print &text_to_html($rawcontent, toc=>1);      print &text_to_html($rawcontent, toc=>1, %option);
619  }  }
620    
621  sub text_to_html {  sub text_to_html {
622      my ($txt, %option) = @_;      my ($txt, %option) = @_;
623      my (@txt) = split(/\n/, $txt);      my (@txt) = split(/\n/, $txt);
624      my (@toc);      my @toc;
625        my @toc2 = @{$option{-toc}||[]};
626      my $tocnum = 0;      my $tocnum = 0;
627      my (@saved, @result);      my (@saved, @result);
628      unshift(@saved, "</p>");      unshift(@saved, "</p>");
629      push(@result, "<p>");      push(@result, "<p>");
630      foreach (@txt) {      foreach (@txt) {
631          chomp;          chomp;
632          # Walrus mod (6) start          if (/^\*\*\*\*\*([^\x0D\x0A]*)/) {
633          #if ($saved[0] eq '</html>') {              push(@toc, qq(----- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
         #    if (/<\/html>/i) { splice(@saved); }  
         #    else { push (@result, &html_to_ignored_html($_)); }  
         #} elsif (/^<html>/i and &is_ignore_html($form{mypage})) {  
         #    push(@result, splice(@saved));  
         #    push(@saved, '</html>');  
         #} els  
         if (/^\*\*\*\*\*(.*)/) {  
             push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));  
634              push(@result, splice(@saved), qq(<h6 id="i$tocnum">) . &inline($1) . '</h6>');              push(@result, splice(@saved), qq(<h6 id="i$tocnum">) . &inline($1) . '</h6>');
635              $tocnum++;              $tocnum++;
636          } elsif (/^\*\*\*\*(.*)/) {          } elsif (/^\*\*\*\*([^\x0D\x0A]*)/) {
637              push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));              push(@toc, qq(---- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
638              push(@result, splice(@saved), qq(<h5 id="i$tocnum">) . &inline($1) . '</h5>');              push(@result, splice(@saved), qq(<h5 id="i$tocnum">) . &inline($1) . '</h5>');
639              $tocnum++;              $tocnum++;
640          } elsif (/^\*\*\*(.*)/) {          } elsif (/^\*\*\*([^\x0D\x0A]*)/) {
641              push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));              push(@toc, qq(--- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
642              push(@result, splice(@saved), qq(<h4 id="i$tocnum">) . &inline($1) . '</h4>');              push(@result, splice(@saved), qq(<h4 id="i$tocnum">) . &inline($1) . '</h4>');
643              $tocnum++;              $tocnum++;
644          } elsif (/^\*\*(.*)/) {          } elsif (/^\*\*([^\x0D\x0A]*)/) {
645          # if (/^\*\*(.*)/) {          # if (/^\*\*(.*)/) {
646          # Walrus mod (6) end          # Walrus mod (6) end
647              push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));              push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
648              push(@result, splice(@saved), qq(<h3><a name="i$tocnum"> </a>) . &inline($1) . '</h3>');              push(@result, splice(@saved), qq(<h3><a name="i$tocnum"> </a>) . &inline($1) . '</h3>');
649              $tocnum++;              $tocnum++;
650          } elsif (/^\*(.*)/) {          } elsif (/^\*([^\x0D\x0A]*)/) {
651              push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));              push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
652              push(@result, splice(@saved), qq(<h2><a name="i$tocnum"> </a>) . &inline($1) . '</h2>');              push(@result, splice(@saved), qq(<h2><a name="i$tocnum"> </a>) . &inline($1) . '</h2>');
653              $tocnum++;              $tocnum++;
654          #} elsif (/^----/) {          } elsif (/^(={1,6})(.*)/) {
         #    push(@result, splice(@saved), '<hr>');  
         } elsif (/^(={1,5})(.*)/) {  
655              &back_push('ol', length($1), \@saved, \@result);              &back_push('ol', length($1), \@saved, \@result);
656              push(@result, '<li>' . &inline($2) . '</li>');              push(@result, '<li>' . &inline($2) . '</li>');
657          } elsif (/^(-{1,5})(.*)/) {          } elsif (/^(-{1,6})(.*)/) {
658              &back_push('ul', length($1), \@saved, \@result);            &back_push('ul', length($1), \@saved, \@result);
659              push(@result, '<li>' . &inline($2) . '</li>');            my ($pf, $l) = ('', $2);
660              if (!$main::_EMBEDED && $l =~ s/^\s*\[([0-9]+)\]//) {
661                my $num = 0+$1;
662                $pf = qq(<a name="anchor-$num" id="anchor-$num" class="anchor">[$num]</a>);
663              }
664              push(@result, '<li>' . $pf . &inline ($l) . '</li>');
665          } elsif (/^:([^:]+):(.*)/) {          } elsif (/^:([^:]+):(.*)/) {
666              &back_push('dl', 1, \@saved, \@result);              &back_push('dl', 1, \@saved, \@result);
667              push(@result, '<dt>' . &inline($1) . '</dt>', '<dd>' . &inline($2) . '</dd>');              push(@result, '<dt>' . &inline($1) . '</dt>', '<dd>' . &inline($2) . '</dd>');
668          } elsif (/^(>{1,5})(.*)/) {          } elsif (/^(?!>>\d)(>{1,5})(.*)/) {
669              &back_push('blockquote', length($1), \@saved, \@result);              &back_push('blockquote', length($1), \@saved, \@result);
670                push @result, "<p>";
671              push(@result, &inline($2));              push(@result, &inline($2));
672                unshift @saved, "</p>";
673          } elsif (/^\s*$/) {          } elsif (/^\s*$/) {
674              push(@result, splice(@saved));              push(@result, splice(@saved));
             unshift(@saved, "</p>");  
675              push(@result, "<p>");              push(@result, "<p>");
676                unshift(@saved, "</p>");
677          } elsif (/^(\s+.*)$/) {          } elsif (/^(\s+.*)$/) {
678              &back_push('pre', 1, \@saved, \@result);              &back_push('pre', 1, \@saved, \@result);
679              #push(@result, &escape($1)); # Not &inline, but &escape              #push(@result, &escape($1)); # Not &inline, but &escape
680              push(@result, &inline($1)); # Not &inline, but &escape              push(@result, &inline($1));
681  #       } elsif (/^\,(.*)$/) {             # Walrus del (BF)  #       } elsif (/^\,(.*)$/) {             # Walrus del (BF)
682          } elsif (/^\,(.*?)[\x0D\x0A]*$/) { # Walrus add (BF)          } elsif (/^\,(.*?)[\x0D\x0A]*$/) { # Walrus add (BF)
683              &back_push('table', 1, \@saved, \@result, ' border="1"');              &back_push('table', 1, \@saved, \@result, ' border="1"');
# Line 594  sub text_to_html { Line 702  sub text_to_html {
702              push(@result, join('', '<tr>', @value, '</tr>'));              push(@result, join('', '<tr>', @value, '</tr>'));
703              # XXXXX              # XXXXX
704              #######              #######
705            } elsif (/^\[(INS|DEL|PRE)\[\s*$/) {
706                push @result, splice (@saved), '<'.lc($1).'>';
707                unshift @saved, "</p>";
708                push @result, "<p>";
709            } elsif (/^\](INS|DEL|PRE)\]\s*$/) {
710                push @result, splice (@saved), '</'.lc($1).'>';
711            } elsif (/^\[([0-9]+)\](.*)$/ && !$main::_EMBEDED) {
712              my $num = 0+$1;
713              push @result, qq(<a name="anchor-$num" id="anchor-$num" class="anchor">[$num]</a>);
714              push @result, &inline ($2);
715          } else {          } else {
716              push(@result, &inline($_));              push(@result, &inline($_));
717          }          }
718      }      }
719      push(@result, splice(@saved));      push(@result, splice(@saved));
720        
721        my $toc = '';
722      if ($option{toc}) {      if ($option{toc}) {
723          # Convert @toc (table of contents) to HTML.          # Convert @toc (table of contents) to HTML.
724          # This part is taken from Makio Tsukamoto's WalWiki.          # This part is taken from Makio Tsukamoto's WalWiki.
725          my (@tocsaved, @tocresult);          my (@tocsaved, @tocresult);
726          foreach (@toc) {          foreach (@toc,@toc2) {
727              if (/^(-{1,3})(.*)/) {              if (/^(-{1,6})(.*)$/) {
728                  &back_push('ul', length($1), \@tocsaved, \@tocresult);                  &back_push('ul', length($1), \@tocsaved, \@tocresult);
729                  push(@tocresult, '<li>' . $2 . '</li>');                  push(@tocresult, '<li>' . $2 . '</li>');
730              }              }
731          }          }
732          push(@tocresult, splice(@tocsaved));          push(@tocresult, splice(@tocsaved));
733          return join("\n", @tocresult, @result);          $toc = join("\n", @tocresult);
734      } else {          $toc = $toc ? qq(<div id="wikipage-toc">$toc</div>) : '';
         return join("\n", @result);  
735      }      }
736        $toc .= join("\n", @result);
737        $toc =~ s#<p>\n</p>##g;
738        $toc =~ s#[\x0D\x0A]+</#</#g;
739        $toc =~ s#<pre>\n#<pre>#g;
740        $toc;
741  }  }
742    
743  sub back_push {  sub back_push {
# Line 634  sub back_push { Line 757  sub back_push {
757  sub inline {  sub inline {
758      my ($line) = @_;      my ($line) = @_;
759      $line = &escape($line);      $line = &escape($line);
760      $line =~ s|'''([^']+?)'''|<strong>$1</strong>|g;      $line =~ s{\[(INS|DEL|SUP|SUB|VAR|CODE|KBD)(?:\(([A-Za-z0-9\x20-]+)\))?\[(.+?)\]\]}{<@{[lc $1]}@{[$2 ? qq( class="$2") : '']}>$3</@{[lc $1]}>}g;
761      $line =~ s|''([^']+?)''|<em>$1</em>|g;      $line =~ s:\[(WEAK)\[(.+?)\]\]:<span class="@{[lc $1]}">$2</span>:g;
762      $line =~ s|(\d\d\d\d-\d\d-\d\d \(\w\w\w\) \d\d:\d\d:\d\d)|<span class="date">$1</span>|g;   # Date      $line =~ s:\[ABBR\[([^]]+)\] \[([^]]+)\]\]:<acronym title="$2">$1</acronym>:g;
763        $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;
764        $line =~ s:\[RUBY\[([^]]+)\] \[([^]]+)\]\]:<ruby><rb>$1</rb><rp>(</rp><rt>$2</rt><rp>)</rp></ruby>:g;
765        $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;
766        $line =~ s%\[Q\[([^]]+)\](?: \[&lt;([\x21-\x5A\x5E-\x7E]+)&gt;\])?\]%「<q@{[$2?qq( cite="$2"):'']}>$1</q>」%g;
767        $line =~ s|'''([^']+)'''|<strong>$1</strong>|g;
768        $line =~ s|''([^']+)''|<em>$1</em>|g;
769      $line =~ s!      $line =~ s!
770        (        (
771          (?:&lt;(?:mailto|http|https|ftp|urn):[\x21-\x7E]*)&gt;          (?:&lt;(?:mailto|http|https|ftp|urn|news):[\x21-\x7E]*)&gt;
772        |        |
773          ($bracket_name) # [[likethis]], [[#comment]], [[Friend:remotelink]]          (?:$bracket_name))      # [[likethis]], [[#comment]], [[Friend:remotelink]]
774        |        |\[\[([^[]+?)]&gt;&gt;([0-9]+)]   # [[WikiName]>>1]
775          ($interwiki_definition) # [[Friend http://somewhere/?q=sjis($1)]]        |&gt;&gt;([0-9]+)
776        #|      !
777        #  ($wiki_name)        my ($l, $page,$anchor, $anum) = ($1, $3,$4, 0+$5);
778        )        if ($l) {
779              !          &make_link($l)
780                  &make_link($1)        } elsif (defined $page) {
781              !gex;          &make_wikilink ($page, anchor => 0+$anchor);
782          } elsif ($anum) {
783            qq(<a href="#anchor-$anum" class="wiki-anchor">&gt;&gt;$anum</a>);
784          }
785        !gex;
786      return $line;      return $line;
787  }  }
788    
789    sub make_wikilink ($%) {
790      my ($ename, %option) = @_;
791      my $name = &unescape ($ename);
792      if ($database{$name}) {
793        my $subject = &escape (&get_subjectline ($name, delimiter => ''));
794        if ($option{anchor}) {
795          return qq(<a title="$subject" href="$url_cgi?@{[&encode($name)]}#anchor-$option{anchor}" class="wiki">$ename&gt;&gt;$option{anchor}</a>);
796        } else {
797          return qq(<a title="$subject" href="$url_cgi?@{[&encode($name)]}" class="wiki">$ename</a>);
798        }
799      } else {
800        return qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=@{[&escape($name)]}" class="wiki not-exist">$ename<span class="mark">$editchar</span></a>);
801      }
802    }
803    
804  sub make_link {  sub make_link {
805      my $chunk = shift;      my $chunk = shift;
806      # Walrus add (3) start      # Walrus add (3) start
807        $chunk =~ s/^&lt;(.*)&gt;$/$1/;
808      my $name  = $chunk;      my $name  = $chunk;
     $name =~ s/^&lt;(.*)&gt;$/$1/;  
809      if ($chunk =~ /^\[\[([^ ]+?) ([^ ]+?)\]\]$/ and $form{mypage} ne $InterWikiName) {      if ($chunk =~ /^\[\[([^ ]+?) ([^ ]+?)\]\]$/ and $form{mypage} ne $InterWikiName) {
810          ($name, $chunk) = ($1, $2);          ($name, $chunk) = ($1, $2);
811      } elsif ($chunk =~ /^mailto:(.*)$/) {      } elsif ($chunk =~ /^mailto:(.*)$/) {
812          $name = $1;          $name = $1;
813      }      }
814      if ($use_autoimg and $name =~ /^(http|https|ftp|):.+\.(png|gif|jpe?g)/) {      if ($use_autoimg and $name =~ /^(http|https|ftp):.+\.(png|gif|jpe?g)/) {
815          $name = qq(<img src="$name">) ;          $name = qq(<img src="$name">) ;
816      }      }
817      $name = &unarmor_name($name);      $name = &unarmor_name($name);
818      # Walrus add (3) end      # Walrus add (3) end
819      if ($chunk =~ /^(http|https|ftp):/) {      if ($chunk =~ /^(http|https|ftp|news):/) {
820          # Walrus mod (3) start          # Walrus mod (3) start
821  #       if ($use_autoimg and $chunk =~ /\.(gif|png|jpeg|jpg)$/) {  #       if ($use_autoimg and $chunk =~ /\.(gif|png|jpeg|jpg)$/) {
822  #           return qq(<a href="$chunk"><img src="$chunk"></a>);  #           return qq(<a href="$chunk"><img src="$chunk"></a>);
823  #       } else {  #       } else {
824  #           return qq(<a href="$chunk">$chunk</a>);  #           return qq(<a href="$chunk">$chunk</a>);
825  #       }  #       }
826          return qq(<a href="$chunk">$name</a>);          return qq(&lt;<a href="$chunk">$name</a>&gt;);
827          # Walrus mod (3) end          # Walrus mod (3) end
828      } elsif ($chunk =~ m#^urn:[0-9A-Za-z_:;/.-]+#) {      } elsif ($chunk =~ m#^urn:[0-9A-Za-z_:;/.-]+#) {
829          return qq|&lt;<a href="/uri-res/N2L?${name}">$name</a>&gt;|;          return qq|&lt;<a href="/uri-res/N2L?${name}">$name</a>&gt;|;
# Line 698  sub make_link { Line 846  sub make_link {
846  #               $remoteurl =~ s/\b(euc|sjis|ykwk|asis)\(\$1\)/&interwiki_convert($1, $localname)/e;      # Walrus del (4)  #               $remoteurl =~ s/\b(euc|sjis|ykwk|asis)\(\$1\)/&interwiki_convert($1, $localname)/e;      # Walrus del (4)
847                  $remoteurl =~ s/\b(euc|sjis|ykwk|asis|isbn)\(\$1\)/&interwiki_convert($1, $localname)/e; # Walrus add (4)                  $remoteurl =~ s/\b(euc|sjis|ykwk|asis|isbn)\(\$1\)/&interwiki_convert($1, $localname)/e; # Walrus add (4)
848  #               return qq(<a href="$remoteurl">$chunk</a>); # Walrus del (3)  #               return qq(<a href="$remoteurl">$chunk</a>); # Walrus del (3)
849                  return qq(<a href="$remoteurl">$name</a>);  # Walrus add (3)                  return qq(<a href="$remoteurl">@{[&escape($name)]}</a>);  # Walrus add (3)
850              } else {              } else {
851  #               return $chunk;                              # Walrus del (3)  #               return $chunk;                              # Walrus del (3)
852                  return $name;                               # Walrus add (3)                  return &escape($name);                               # Walrus add (3)
853              }              }
854          } elsif ($database{$chunk}) {          } elsif ($database{$chunk}) {
855              my $subject = &escape(&get_subjectline($chunk, delimiter => ''));              my $subject = &escape(&get_subjectline($chunk, delimiter => ''));
856  #           return qq(<a title="$subject" href="$url_cgi?$cookedchunk">$chunk</a>);  # Walrus del (3)  #           return qq(<a title="$subject" href="$url_cgi?$cookedchunk">$chunk</a>);  # Walrus del (3)
857              return qq(<a title="$subject" href="$url_cgi?$cookedchunk">$name</a>);   # Walrus add (3)              return qq(<a title="$subject" href="$url_cgi?$cookedchunk" class="wiki">@{[&escape($name)]}</a>);   # Walrus add (3)
858          } elsif ($page_command{$chunk}) {          } elsif ($page_command{$chunk}) {
859  #           return qq(<a title="$chunk" href="$url_cgi?$cookedchunk">$chunk</a>);    # Walrus del (3)  #           return qq(<a title="$chunk" href="$url_cgi?$cookedchunk">$chunk</a>);    # Walrus del (3)
860              return qq(<a title="$chunk" href="$url_cgi?$cookedchunk" class="wiki">$name</a>);     # Walrus add (3)              return qq(<a title="$chunk" href="$url_cgi?$cookedchunk" class="wiki">@{[&escape($name)]}</a>);     # Walrus add (3)
861          } else {          } else {
862              return qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedchunk" class="wiki">$name<span class="mark">$editchar</span></a>);              return qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedchunk" class="wiki">@{[&escape($name)]}<span class="mark">$editchar</span></a>);
863          }          }
864      }      }
865  }  }
866    
 # Walrus add (6) start  
 sub is_ignore_html {  
     my ($pagename) = @_;  
     foreach (@ignore_html_page) {  
         return 1 if ($pagename eq $_);  
     }  
     return 0;  
 }  
 # Walrus add (6) end  
   
 # Walrus add (6) start  
 sub html_to_ignored_html {  
     my $str = shift(@_);  
     my $text_regex        = q{[^<]*};  
     my $tag_regex_        = q{[^"'<>]*(?:"[^"]*"[^"'<>]*|'[^']*'[^"'<>]*)*(?:>|(?=<)|$(?!\n))}; #'}}}}  
     my $comment_tag_regex = '<!(?:--[^-]*-(?:[^-]+-)*?-(?:[^>-]*(?:-[^>-]+)*?)??)*(?:>|$(?!\n)|--.*$)';  
     my $tag_regex         = qq{$comment_tag_regex|<$tag_regex_};  
     my $ignored           = join('|', @ignore_html_tags);  
     my $result = '';  
     while ($str =~ /($text_regex)($tag_regex)?/gso) {  
       last if $1 eq '' and $2 eq '';  
       $result .= $1;  
       my $tag_tmp = $2;  
       $result .= ($tag_tmp =~ /^<\/?($ignored)(?![0-9A-Za-z])/i) ? $tag_tmp : &escape($tag_tmp);  
       if ($tag_tmp =~ /^<(XMP|PLAINTEXT|SCRIPT)(?![0-9A-Za-z])/i) {  
         $str =~ /(.*?)(?:<\/$1(?![0-9A-Za-z])$tag_regex_|$)/gsi;  
         $result .= &escape($1);  
       }  
     }  
     return $result;  
 }  
 # Walrus add (6) end  
   
867  sub print_message {  sub print_message {
868      my ($msg) = @_;      my ($msg) = @_;
869      print qq(<p><strong>$msg</strong></p>);      print qq(<p><strong>$msg</strong></p>);
870  }  }
871    
872    sub get_message {
873        my ($msg) = @_;
874        qq(<p><strong>$msg</strong></p>);
875    }
876    
877  sub init_form {  sub init_form {
878      if (param()) {      if (param()) {
879          foreach my $var (param()) {          foreach my $var (param()) {
880              $form{$var} = param($var);              $form{$var} = param($var);
881          }        }
     } else {  
         $ENV{QUERY_STRING} = $FrontPage;  
882      }      }
883        if ($main::ENV{QUERY_STRING} && $main::ENV{QUERY_STRING} !~ /[&;]/) {
884      my $query = &decode($ENV{QUERY_STRING});        my $query = &decode($main::ENV{QUERY_STRING});
885      if ($page_command{$query}) {        if ($page_command{$query}) {
886          $form{mycmd} = $page_command{$query};          $form{mycmd} = $page_command{$query};
887          $form{mypage} = $query;          $form{mypage} = $query;
888      } elsif ($query =~ /^($wiki_name)$/) {        } else {
         $form{mycmd} = 'read';  
         $form{mypage} = $1;  
     } elsif ($database{$query}) {  
         $form{mycmd} = 'read';  
889          $form{mypage} = $query;          $form{mypage} = $query;
890            $form{mycmd} = $database{$form{mypage}} ? 'read' : 'edit';
891          }
892      }      }
893        $form{mypage} ||= 'HomePage';
894    
895      # mypreview_edit        -> do_edit, with preview.      # mypreview_edit        -> do_edit, with preview.
896      # mypreview_adminedit   -> do_adminedit, with preview.      # mypreview_adminedit   -> do_adminedit, with preview.
# Line 785  sub init_form { Line 902  sub init_form {
902          }          }
903      }      }
904    
905      #      #
906      # $form{mycmd} is frozen here.      # $form{mycmd} is frozen here.
907      #      #
908    
909      $form{mymsg} = &code_convert(\$form{mymsg}, $kanjicode);      $form{mymsg} = &code_convert(\$form{mymsg}, $kanjicode);
910      $form{myname} = &code_convert(\$form{myname}, $kanjicode);      $form{myname} = &code_convert(\$form{myname}, $kanjicode);
911  }  }
912    
913  sub update_recent_changes {  sub update_recent_changes {
914      my $update = "- @{[&get_now]} @{[&armor_name($form{mypage})]} @{[&get_subjectline($form{mypage})]}";      my $update = "- @{[&get_now]} [[@{[&escape($form{mypage})]}]] @{[&get_subjectline($form{mypage})]}";
915      my @oldupdates = split(/\r?\n/, $database{$RecentChanges});      my @oldupdates = split(/\r?\n/, $database{$RecentChanges});
916      my @updates;      my @updates;
917      foreach (@oldupdates) {      foreach (@oldupdates) {
918          /^\- \d\d\d\d\-\d\d\-\d\d \(...\) \d\d:\d\d:\d\d (\S+)/;    # date format.          /^\- \d\d\d\d\-\d\d\-\d\d \([^)]+\) \d\d:\d\d \[\[(\S+?)\]\]/;
919          my $name = &unarmor_name($1);          my $name = $1;
920          if (&is_exist_page($name) and ($name ne $form{mypage})) {          if ($name ne $form{mypage}) {
921              push(@updates, $_);              push @updates, $_;
922          }          }
923      }      }
924      if (&is_exist_page($form{mypage})) {      if (&is_exist_page($form{mypage})) {
925          unshift(@updates, $update);        unshift @updates, $update;
926      }      }
927      splice(@updates, $maxrecent + 1);      splice(@updates, $maxrecent + 1);
928      $database{$RecentChanges} = join("\n", @updates);      $database{$RecentChanges} = join("\n", @updates);
# Line 829  sub get_subjectline { Line 946  sub get_subjectline {
946    
947          # Get the subject of the page.          # Get the subject of the page.
948          my $subject = $database{$page};          my $subject = $database{$page};
949            $subject =~ s#^(?:\#\?)?SuikaWiki/0.9[^\x0D\x0A]*[\x0D\x0A]+##s;
950          $subject =~ s/\r?\n.*//s;          $subject =~ s/\r?\n.*//s;
951          return "$delim$subject";          return "$delim$subject".$option{tail};
952      }      }
953  }  }
954    
# Line 936  sub print_editform { Line 1054  sub print_editform {
1054          }          }
1055          $mymsg = &escape($form{mymsg});          $mymsg = &escape($form{mymsg});
1056      } else {      } else {
1057          $mymsg = &escape($mymsg);          $mymsg = &escape($mymsg || $database{NewPageTemplate});
1058      }      }
1059    
1060      my $edit = $mode{admin} ? 'adminedit' : 'edit';      my $edit = $mode{admin} ? 'adminedit' : 'edit';
1061        my $escapedmypage = &escape($form{mypage});
1062        my $escapedmypassword = &escape($form{mypassword});
1063    
1064      print <<"EOD";      print <<"EOD";
1065  <form action="$url_cgi" method="post">  <form action="$url_cgi" method="post">
1066      @{[ $mode{admin} ? qq($resource{frozenpassword} <input type="password" name="mypassword" value="$form{mypassword}" size="10"><br>) : "" ]}  <h2>$escapedmypageの編集</h2>
1067        @{[ $mode{admin} ? qq($resource{frozenpassword} <input type="password" name="mypassword" value="$escapedmypassword" size="10"><br>) : "" ]}
1068      <input type="hidden" name="myLastModified" value="$lastmodified">      <input type="hidden" name="myLastModified" value="$lastmodified">
1069      <input type="hidden" name="mypage" value="$form{mypage}">      <input type="hidden" name="mypage" value="$escapedmypage">
1070      <textarea cols="$cols" rows="$rows" name="mymsg" wrap="off">$mymsg</textarea><br>      <textarea cols="$cols" rows="$rows" name="mymsg" tabindex="1">$mymsg</textarea><br>
1071  @{[  @{[
1072      $mode{admin} ?      $mode{admin} ?
1073      qq(      qq(
# Line 959  sub print_editform { Line 1080  sub print_editform {
1080      qq(      qq(
1081          <input type="checkbox" name="mytouch" value="on" checked="checked">$resource{touch}<br>          <input type="checkbox" name="mytouch" value="on" checked="checked">$resource{touch}<br>
1082          <input type="submit" name="mypreview_$edit" value="$resource{previewbutton}">          <input type="submit" name="mypreview_$edit" value="$resource{previewbutton}">
1083          <input type="submit" name="mypreview_write" value="$resource{savebutton}"><br>          <input type="submit" name="mypreview_write" value="$resource{savebutton}" accesskey="S"><kbd>S</kbd>
1084            [@{[do {my $n = 0;
1085                   $mymsg =~ s/(?:-+\s)?\[([0-9]+)\]/$n = $1 if $1 > $n; $&/mge;
1086                   ++$n}]}]<br>
1087      )      )
1088  ]}  ]}
1089  </form>  </form>
1090  EOD  EOD
1091      unless ($mode{conflict}) {      unless ($mode{conflict}) {
1092          # Show the format rule.          # Show the format rule.
1093          open(FILE, $file_format) or &print_error("($file_format)");          my $help = $database{'WikiEditHelp'};
1094          my $content = join('', <FILE>);          $help =~ s!^\#\?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:[^0-9.\x0D\x0A][^\x0D\x0A]*)?)[\x0D\x0A]+!!s;
1095          &code_convert(\$content, $kanjicode);          print &text_to_html ($help, toc => 0);
1096          close(FILE);      #    open(FILE, $file_format) or &print_error("($file_format)");
1097          print &text_to_html($content, toc=>0);      #    my $content = join('', <FILE>);
1098        #    &code_convert(\$content, $kanjicode);
1099        #    close(FILE);
1100        #    print &text_to_html($content, toc=>0);
1101      }      }
1102  }  }
1103    
# Line 1008  sub is_editable { Line 1135  sub is_editable {
1135  #   not_wiki_name -> [[not_wiki_name]]  #   not_wiki_name -> [[not_wiki_name]]
1136  sub armor_name {  sub armor_name {
1137      my ($name) = @_;      my ($name) = @_;
1138      if ($name =~ /^$wiki_name$/) {      #if ($name =~ /^$wiki_name$/) {
1139          return $name;      #    return $name;
1140      } else {      #} else {
1141          return "[[$name]]";          return "[[$name]]";
1142      }      #}
1143  }  }
1144    
1145  # unarmor_name:  # unarmor_name:
# Line 1076  sub conflict { Line 1203  sub conflict {
1203      my $content = join('', <FILE>);      my $content = join('', <FILE>);
1204      &code_convert(\$content, $kanjicode);      &code_convert(\$content, $kanjicode);
1205      close(FILE);      close(FILE);
1206      &print_header($page);      &print_header($page, -noindex => 1);
1207      &print_content($content);      &print_content($content);
1208      &print_editform($rawmsg, $form{myLastModified}, frozen=>0, conflict=>1);      &print_editform($rawmsg, $form{myLastModified}, frozen=>0, conflict=>1);
1209      &print_footer($page);      &print_footer($page);
# Line 1085  sub conflict { Line 1212  sub conflict {
1212    
1213  sub get_now {  sub get_now {
1214      my (@week) = qw(Sun Mon Tue Wed Thu Fri Sat);      my (@week) = qw(Sun Mon Tue Wed Thu Fri Sat);
1215        my (@week) = qw(日 月 火 水 木 金 土);
1216      my ($sec, $min, $hour, $day, $mon, $year, $weekday) = localtime(time);      my ($sec, $min, $hour, $day, $mon, $year, $weekday) = localtime(time);
1217      $year += 1900;      $year += 1900;
1218      $mon++;      $mon++;
# Line 1092  sub get_now { Line 1220  sub get_now {
1220      $day = "0$day" if $day < 10;      $day = "0$day" if $day < 10;
1221      $hour = "0$hour" if $hour < 10;      $hour = "0$hour" if $hour < 10;
1222      $min = "0$min" if $min < 10;      $min = "0$min" if $min < 10;
1223      $sec = "0$sec" if $sec < 10;      #$sec = "0$sec" if $sec < 10;
1224      $weekday = $week[$weekday];      $weekday = $week[$weekday];
1225      return "$year-$mon-$day ($weekday) $hour:$min:$sec";      return "$year-$mon-$day ($weekday) $hour:$min";
1226  }  }
1227    
1228  # [[YukiWiki http://www.hyuki.com/yukiwiki/wiki.cgi?euc($1)]]  # [[YukiWiki http://www.hyuki.com/yukiwiki/wiki.cgi?euc($1)]]
# Line 1184  sub is_frozen { Line 1312  sub is_frozen {
1312    
1313  sub do_comment {  sub do_comment {
1314      my ($content) = $database{$form{mypage}};      my ($content) = $database{$form{mypage}};
1315      my $datestr = &get_now;      my $default_name;   ## this code does not strict.
1316      my $namestr = $form{myname} ? " ''[[$form{myname}]]'' : " : " ";      $default_name = $1 if $content =~ /default-name="([^"]+)"/;
1317      if ($content =~ s/(\Q$embed_comment\E)/- $datestr$namestr$form{mymsg}\n$1/) {      my $datestr = '[WEAK['.&get_now.']]';
1318          ;      my $namestr = $form{myname} || $default_name || $DEFAULT_embed_comment_name;
1319      } else {      ($namestr = '', $datestr = '') if $form{myname} eq 'nodate';
1320          $content =~ s/(\Q$embed_rcomment\E)/$1\n- $datestr$namestr$form{mymsg}/;      if ($namestr =~ /^(?:>>)?[0-9]/) {
1321          $namestr = qq( ''$namestr'': );
1322        } elsif (length $namestr) {
1323          $namestr = qq( ''[[$namestr]]'': );
1324        }
1325        my $anchor = 0;
1326        $content =~ s/(?:-+\s)?\[([0-9]+)\]/$anchor = $1 if $1 > $anchor; $&/mge;
1327        $anchor++;
1328        my $i = 1;  my $o = 0;
1329        $content =~ s{(\Q$embed_comment\E|\Q$embed_rcomment\E)}{
1330          my $embed = $1;
1331          if ($i == $form{comment_index}) {
1332            if ($embed eq $embed_comment) {
1333              $embed = "- [$anchor] $datestr$namestr$form{mymsg}\n$embed";  $o = 1;
1334            } else {
1335              $embed .= "\n- [$anchor] $datestr$namestr$form{mymsg}";  $o = 1;
1336            }
1337          }
1338          $i++; $embed;
1339        }ge;
1340        unless ($o) {
1341          $content = "#?SuikaWiki/0.9\n\n" unless $content;
1342          $content .= "\n" unless $content =~ /\n$/s;
1343          $content .= "- [$anchor] $datestr$namestr$form{mymsg}\n";
1344      }      }
1345      if ($form{mymsg}) {      $form{__comment_anchor_index} = $anchor;
1346        if ($form{mymsg} || $form{myname}) {
1347          $form{mymsg} = $content;          $form{mymsg} = $content;
1348          $form{mytouch} = 'on';          $form{mytouch} = 'on';
1349          &do_write;          &do_write;
# Line 1201  sub do_comment { Line 1353  sub do_comment {
1353      }      }
1354  }  }
1355    
1356    my $CommentIndex = 0;
1357  sub embedded_to_html {  sub embedded_to_html {
1358      my ($embedded) = @_;      my ($embedded) = @_;
1359      if ($embedded eq $embed_comment or $embedded eq $embed_rcomment) {      if ($embedded eq $embed_comment or $embedded eq $embed_rcomment) {
1360          unless ($main::_EMBEDED) {
1361          my $lastmodified = &get_info($form{mypage}, $info_LastModified);          my $lastmodified = &get_info($form{mypage}, $info_LastModified);
1362          return <<"EOD";          return <<"EOD";
1363  <form action="$url_cgi" method="post">  <form action="$url_cgi" method="post" id="x-comment-@{[++$CommentIndex]}" class="comment"><p>
1364      <input type="hidden" name="mycmd" value="comment">      <input type="hidden" name="mycmd" value="comment">
1365      <input type="hidden" name="mypage" value="$form{mypage}">      <input type="hidden" name="mypage" value="$form{mypage}">
1366      <input type="hidden" name="myLastModified" value="$lastmodified">      <input type="hidden" name="myLastModified" value="$lastmodified">
1367      <input type="hidden" name="mytouch" value="on">      <input type="hidden" name="mytouch" value="on">
1368      $resource{yourname}      <input type="hidden" name="comment_index" value="$CommentIndex">
1369      <input type="text" name="myname" value="" size="10">      $embed_comment_Name_Prompt
1370      <input type="text" name="mymsg" value="" size="40">      <input type="text" name="myname" value="" size="10" class="comment-name">
1371      <input type="submit" value="$resource{commentbutton}">      <input type="text" name="mymsg" value="" size="60" class="comment-msg">
1372  </form>      <input type="submit" value="$resource{commentbutton}" class="comment-submit">
1373    </p></form>
1374  EOD  EOD
1375         } else {
1376            return <<"EOD";
1377    <del><form action="$url_cgi" method="get">
1378        <input type="hidden" name="mycmd" value="read">
1379        <input type="hidden" name="mypage" value="$form{mypage}">
1380        $embed_comment_Name_Prompt
1381        <input type="text" name="myname" value="" size="10" disabled="disabled">
1382        <input type="text" name="mymsg" value="" size="60" disabled="disabled">
1383        <input type="submit" value="$resource{commentbutton}" disabled="disabled">
1384    </form></del>
1385    EOD
1386        }
1387      } elsif ($embedded =~ /$embed_command{searched}/) {
1388        return get_search_result ($1, -match_myself => 1);
1389      # Walrus add (5) start      # Walrus add (5) start
1390      } elsif ($embedded =~ /$embed_interwiki/ and my $remoteurl = $interwiki{$2}) {      } elsif ($embedded =~ /$embed_interwiki/ and my $remoteurl = $interwiki{$2}) {
1391          $_ = &make_interwiki_box($1, $2);          $_ = &make_interwiki_box($1, $2);
1392          return ($_) ? $_ : $embedded;          return ($_) ? $_ : $embedded;
1393      # Walrus add (5) end      # Walrus add (5) end
1394      } else {    } elsif ($embedded =~ /^\[\[\#embed:(.+)\]\]$/) {
1395          return $embedded;      my ($name, $r) = ($1, '');
1396        if ($main::_EMBEDED != 1) {
1397          my ($content, $cf) = ($database{$name}, 'SuikaWiki/0.9');
1398          $cf = $1 if $content =~ s!^(?:[\#<]\?|/\*\s*)?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:[^0-9.][^\x0D\x0A]*)?)[\x0D\x0A]+!!s;
1399          if ($cf =~ m!^(?:\#\?)?SuikaWiki/0.9(?:$|\s)!) {
1400            $main::_EMBEDED = 1;
1401            $r = &text_to_html ($content, content_format => $cf);
1402            $main::_EMBEDED = 0;
1403          } elsif (length $content) {
1404            $r = "<pre>@{[&escape ($content)]}</pre>";
1405          } else {
1406            $r = &text_to_html ("[INS[\n埋め込まれている [[$name]] はまだ書かれていません。\n]INS]\n", content_format => 'SuikaWiki/0.9');
1407          }
1408        } else {    ## nested #EMBED
1409          $r = &text_to_html ("[INS[\n[[$name]] の埋め込みは (入り組んでいるので) 解決されませんでした。\n]INS]\n", content_format => 'SuikaWiki/0.9');
1410      }      }
1411        return qq(<blockquote title="@{[&escape($name)]}">$r<div class="cite-note">『<cite><a href="$url_cgi?@{[&encode($name)]}" class="wiki">@{[&escape($name)]}</a></cite>』</div></blockquote>);
1412      } elsif ($embedded =~ /^\[\[\#randomlink:(.+)\]\]$/) {
1413        return qq(<a href="$url_cgi?mycmd=RandomJump;x-param=@{[time.[0..9]->[rand 10]]}" class="wiki randomlink">$1</a>);
1414      } else {
1415        return $embedded;
1416      }
1417  }  }
1418    
1419  # Walrus add (5) start  # Walrus add (5) start
# Line 1263  EOD Line 1452  EOD
1452  # Walrus add (5) end  # Walrus add (5) end
1453    
1454  sub code_convert {  sub code_convert {
1455      my ($contentref, $kanjicode) = @_;      my ($contentref, $code) = (shift, shift || $kanjicode);
1456  #   &Jcode::convert($contentref, $kanjicode);       # for Jcode.pm  #   &Jcode::convert($contentref, $code);       # for Jcode.pm
1457      &jcode::convert($contentref, $kanjicode);       # for jcode.pl      &jcode::convert($contentref, $code);       # for jcode.pl
1458      return $$contentref;      return $$contentref;
1459  }  }
1460    
# Line 1339  sub do_diff { Line 1528  sub do_diff {
1528      }      }
1529      &open_diff;      &open_diff;
1530      my $title = $form{mypage};      my $title = $form{mypage};
1531      &print_header($title);      &print_header($title, -noindex => 1);
1532      $_ = &escape($diffbase{$form{mypage}});      $_ = &escape($diffbase{$form{mypage}});
1533      &close_diff;      &close_diff;
1534      print qq(<h3>$resource{difftitle}</h3>);      print qq(<h3>$resource{difftitle}</h3>);
# Line 1375  sub do_rss { Line 1564  sub do_rss {
1564      my $count = 0;      my $count = 0;
1565      foreach (split(/\n/, $recentchanges)) {      foreach (split(/\n/, $recentchanges)) {
1566          last if ($count >= 15);          last if ($count >= 15);
1567          /^\- \d\d\d\d\-\d\d\-\d\d \(...\) \d\d:\d\d:\d\d (\S+)/;    # date format.          /^\- \d\d\d\d\-\d\d\-\d\d \([^)]+\) \d\d:\d\d:\d\d (\S+)/;    # date format.
1568          my $title = &unarmor_name($1);          my $title = &unarmor_name($1);
1569          my $escaped_title = &escape($title);          my $escaped_title = &escape($title);
1570          my $link = $modifier_rss_link . '?' . &encode($title);          my $link = $modifier_rss_link . '?' . &encode($title);
# Line 1404  sub is_exist_page { Line 1593  sub is_exist_page {
1593      }      }
1594  }  }
1595    
1596    sub __get_database ($) { $database{ $_[0] } }
1597    
1598    package wiki::referer;
1599    sub add ($$) {
1600      my $page = shift;
1601      my $uri = shift;
1602      unless (ref $uri) {
1603        require URI;
1604        $uri = URI->new ($uri);
1605        ## Some schemes do not have query part.
1606        eval q{ $uri->query (undef) if $uri->query =~ /^[0-9]{6,8}$/ };
1607        $uri->fragment (undef);
1608      }
1609      $uri = $uri->canonical;
1610      return unless $uri;
1611      for my $regex (&get_dont_record) {
1612        return if $uri =~ /$regex/;
1613      }
1614      my %list = get ($page);
1615      $list{ $uri }++;
1616      set ($page, \%list);
1617    }
1618    sub get ($) {
1619      my $page = shift;
1620      split /"/, main::get_info ($page, 'Referer');
1621    }
1622    sub set ($%) {
1623      my $page = shift;
1624      my $list = shift;
1625      main::set_info ($page, Referer => join '"', %$list);
1626    }
1627    
1628    sub get_dont_record () {
1629      map {s/\$/\\\$/g; s/\@/\\\@/g; $_}
1630      grep !/^#/,
1631      split /[\x0D\x0A]+/, &main::__get_database ('RefererDontRecord');
1632    }
1633    sub get_site_name () {
1634      my @lines = grep /[^#]/, split /[\x0D\x0A]+/, &main::__get_database('RefererSiteName');
1635      my @item;
1636      for (@lines) {
1637        next if /^#/;
1638        my ($uri, $name) = split /\s+/, $_, 2;
1639        $uri =~ s/\$/\\\$/g;  $uri =~ s/\@/\\\@/g;  $uri =~ s/\//\\\//g;
1640        $name =~ s!([()/\\])!\\$1!g;  $name =~ s/\$([0-9]+)/).__decode (\${$1}).q(/g;
1641        push @item, [$uri, qq(q($name))];
1642      }
1643      @item;
1644    }
1645    
1646    sub list_html ($) {
1647      my $page = shift;
1648      my %list = get ($page);
1649      my $r = '';
1650      my @name = get_site_name;
1651      for my $uri (sort keys %list) {
1652        my $title;
1653        for my $item (@name) {
1654          if ($uri =~ /$item->[0]/) {
1655            $title = $uri;
1656            eval qq{\$title =~ s/^.*$item->[0].*\$/$item->[1]/e}
1657              or die $@ ;#. qq{\$title =~ s/^.*$item->[0].*\$/$item->[1]/e};
1658            last;
1659          }
1660        }
1661        my $euri = main::escape ($uri);
1662        if ($title) {
1663          $r .= qq(<li>[$list{$uri}] <a href="$euri" title="URI: &lt;$euri>">@{[main::escape ($title)]}</a></li>\n);
1664        } else {
1665          $r .= qq(<li>[$list{$uri}] &lt;<a href="$euri">$euri</a>&gt;</li>\n);
1666        }
1667      }
1668      $r ? qq(<ul>$r</ul>\n) : '';
1669    }
1670    
1671    sub __decode ($) {
1672      my $s = shift;
1673      $s =~ tr/+/ /;
1674      $s =~ s/%([0-9A-Fa-f][0-9A-Fa-f])/chr hex $1/ge;
1675      main::code_convert (\$s);
1676    }
1677    
1678  1;  1;
1679  __END__  __END__
1680  =head1 NAME  =head1 NAME

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.30

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24