/[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.28 by wakaba, Thu Oct 17 07:56:58 2002 UTC revision 1.29 by wakaba, Mon Oct 21 06:28:02 2002 UTC
# Line 208  sub main { Line 208  sub main {
208  sub do_read {  sub do_read {
209    my $content = $database{$form{mypage}};    my $content = $database{$form{mypage}};
210    my $lm = &get_info($form{mypage}, $info_LastModified);    my $lm = &get_info($form{mypage}, $info_LastModified);
   &print_header($form{mypage}, -last_modified => $lm);  
211    wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER});    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';      my $cf = 'SuikaWiki/0.9';
218      ## Should be support at least:      ## Should be support at least:
219      ## - 'SuikaWiki/0.9' CRLF      ## - 'SuikaWiki/0.9' CRLF
# Line 217  sub do_read { Line 221  sub do_read {
221      ## - "/*" WSP* 'W3C-CSS/' ("1.0" / "2.0") "*/" CRLF      ## - "/*" 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;      $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)!) {      if ($cf =~ m!^(?:\#\?)?SuikaWiki/0.9(?:$|\s)!) {
224        &print_content($content, content_format => $cf, last_modified => $lm);        &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]]));        print &text_to_html (q([[#comment]]));
229      } else {      } else {
230          &print_header($form{mypage}, -last_modified => $lm);
231        print "<pre>@{[&escape($content)]}</pre>";        print "<pre>@{[&escape($content)]}</pre>";
232      }      }
   my ($r, $c) = get_search_result ($form{mypage});  
233      if ($c) {      if ($c) {
234        print q{<h2 id="SEE-ALSO">See also</h2>};        print q{<h2 id="wikipage-see-also">See also</h2>};
235        print $r;        print $r;
236      }      }
237    my $r = wiki::referer::list_html ($form{mypage});      if ($rl) {
238      if ($r) {        print qq(<div id="wikipage-referer"><h2>参照元</h2>\n$rl</div>\n);
       print qq(<div id="wikipage-referer"><h2>参照元</h2>\n$r</div>\n);  
239      }      }
240    &print_footer($form{mypage}, $lm);    &print_footer($form{mypage}, $lm);
241  }  }
# Line 237  sub do_read { Line 243  sub do_read {
243  sub do_output_css {  sub do_output_css {
244    my $content = $database{$form{mypage}};    my $content = $database{$form{mypage}};
245    if ($content =~ m#^\s*/\*\s*W3C-CSS#) {    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";      print "Content-Type: text/css; charset=$charset\n";
248        print "Last-Modified: $lm\n";
249      print "\n";      print "\n";
250      print $content;      print $content;
251    } else {    } else {
252      print "Status: 406 Unsupported Media Type\n";      print "Status: 406 Unsupported Media Type\n";
253      &print_header('WikiPageIsNotCSS');      &print_header('WikiPageIsNotCSS', -noindex => 1);
254      &print_content($database{WikiPageIsNotCSS});      &print_content($database{WikiPageIsNotCSS});
255      &print_footer('WikiPageIsNotCSS');      &print_footer('WikiPageIsNotCSS');
256    }    }
# Line 250  sub do_output_css { Line 258  sub do_output_css {
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 263  sub do_edit { Line 271  sub do_edit {
271    
272  sub do_adminedit {  sub do_adminedit {
273      my ($page) = &unarmor_name(&armor_name($form{mypage}));      my ($page) = &unarmor_name(&armor_name($form{mypage}));
274      &print_header($page);      &print_header($page, -noindex => 1);
275      if (not &is_editable($page)) {      if (not &is_editable($page)) {
276          &print_message($resource{cantchange});          &print_message($resource{cantchange});
277      } else {      } else {
# Line 274  sub do_adminedit { Line 282  sub do_adminedit {
282  }  }
283    
284  sub do_adminchangepasswordform {  sub do_adminchangepasswordform {
285      &print_header($AdminChangePassword);      &print_header($AdminChangePassword, -noindex => 1);
286      &print_passwordform;      &print_passwordform;
287      &print_footer($AdminChangePassword);      &print_footer($AdminChangePassword);
288  }  }
# Line 301  EOD Line 309  EOD
309      my $crypted = crypt($form{mynewpassword}, "$salt1$salt2");      my $crypted = crypt($form{mynewpassword}, "$salt1$salt2");
310      &set_info($AdminSpecialPage, $info_AdminPassword, $crypted);      &set_info($AdminSpecialPage, $info_AdminPassword, $crypted);
311    
312      &print_header($CompletedSuccessfully);      &print_header($CompletedSuccessfully, -noindex => 1);
313      &print_message($resource{passwordchanged});      &print_message($resource{passwordchanged});
314      &print_footer($CompletedSuccessfully);      &print_footer($CompletedSuccessfully);
315  }  }
# Line 326  sub do_write { Line 334  sub do_write {
334      }      }
335    
336      if (not &is_editable($form{mypage})) {      if (not &is_editable($form{mypage})) {
337          &print_header($form{mypage});          &print_header($form{mypage}, -noindex => 1);
338          &print_message($resource{cantchange});          &print_message($resource{cantchange});
339          &print_footer($form{mypage});          &print_footer($form{mypage});
340          return;          return;
# Line 353  sub do_write { Line 361  sub do_write {
361              &update_recent_changes;              &update_recent_changes;
362          }          }
363          &set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen});          &set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen});
364          &print_header($CompletedSuccessfully, -goto => $url_cgi.'?'.&encode($form{mypage}).($form{comment_index}?"#x-comment-$form{comment_index}":''));          &print_header($CompletedSuccessfully, -noindex => 1, -goto => $url_cgi.'?'.&encode($form{mypage}).($form{__comment_anchor_index}?"#anchor-$form{__comment_anchor_index}":''));
365          &print_message($resource{saved});          &print_message($resource{saved});
366          &print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}");          &print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}");
367          &print_footer($CompletedSuccessfully);          &print_footer($CompletedSuccessfully);
# Line 364  sub do_write { Line 372  sub do_write {
372          if ($form{mytouch}) {          if ($form{mytouch}) {
373              &update_recent_changes;              &update_recent_changes;
374          }          }
375          &print_header($form{mypage});          &print_header($form{mypage}, -noindex => 1);
376          &print_message($resource{deleted});          &print_message($resource{deleted});
377          &print_footer($form{mypage});          &print_footer($form{mypage});
378      }      }
# Line 423  EOD Line 431  EOD
431  sub do_random_jump {  sub do_random_jump {
432    my @list = keys %database;    my @list = keys %database;
433    my $name = &encode ($list[rand @list]);    my $name = &encode ($list[rand @list]);
434    print "Location: $url_cgi?$name\n";    my ($scheme) = 'http';
435      $scheme = $1 if $main::ENV{SERVER_PROTOCOL} =~ m#([A-Za-z0-9+.%-]+)#;
436      print "Location: $scheme://$main::ENV{SERVER_NAME}:$main::ENV{SERVER_PORT}$url_cgi?$name\n";
437    print "\n";    print "\n";
438  }  }
439    
# Line 439  sub do_FrontPage { Line 449  sub do_FrontPage {
449    
450  sub print_error {  sub print_error {
451      my ($msg) = @_;      my ($msg) = @_;
452      &print_header($ErrorPage);      &print_header($ErrorPage, -noindex => 1);
453      print qq(<p><strong class="error">$msg</strong></p>);      print qq(<p><strong class="error">$msg</strong></p>);
454      &print_footer($ErrorPage);      &print_footer($ErrorPage);
455      exit(0);      exit(0);
# Line 451  sub print_header ($;%) { Line 461  sub print_header ($;%) {
461      if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) {      if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) {
462          $bodyclass = "frozen";          $bodyclass = "frozen";
463      }      }
464        $bodyclass .= " wiki-page-obsoleted" if $option{-content_format} =~ /obsoleted="yes"/;
465      print qq{Refresh: 0; url="$option{-goto}"\n} if $option{-goto};      print qq{Refresh: 0; url="$option{-goto}"\n} if $option{-goto};
466      print qq{Last-Modified: $option{-last_modified}\n} if $option{-last_modified};      print qq{Last-Modified: $option{-last_modified}\n} if $option{-last_modified};
467      my $cookedpage = &encode($page);      my $cookedpage = &encode($page);
# Line 466  Content-Style-Type: text/css Line 477  Content-Style-Type: text/css
477      "http://www.w3.org/TR/html4/loose.dtd"> + RUBY -->      "http://www.w3.org/TR/html4/loose.dtd"> + RUBY -->
478  <html lang="$lang">  <html lang="$lang">
479  <head>  <head>
480      <title>$escapedpage @{[&escape(&get_subjectline($page))]}</title>      <title>$escapedpage</title>
481      <link rel="index" href="$url_cgi?$IndexPage">      <link rel="index" href="$url_cgi?$IndexPage">
482      <link rel="copyright" href="$url_cgi?$NAME_OF_WikiPageLicense">      <link rel="copyright" href="$url_cgi?$NAME_OF_WikiPageLicense">
483      <link rev="made" href="mailto:@{[&escape($modifier_mail)]}">      <link rev="made" href="mailto:@{[&escape($modifier_mail)]}">
484      <link rel="stylesheet" type="text/css" href="@{[&escape($url_stylesheet)]}">      <link rel="stylesheet" type="text/css" href="@{[&escape($url_stylesheet)]}">
485        @{[$option{-noindex} ? q(<meta name="ROBOTS" content="NOINDEX">) : '']}
486  </head>  </head>
487  <body class="$bodyclass">  <body class="$bodyclass">
488  EOD  EOD
489    &print_navigate_links ($page);    &print_navigate_links ($page);
490    print <<EOD;    print <<EOD;
491  <h1 class="header">@{[&escape($page)]}  <h1 class="header">@{[&escape($page)]}</h1>
   <span class="wikipage-summary">@{[&escape(&get_subjectline($page))]}</span></h1>  
492  EOD  EOD
493  }  }
494    
# Line 487  sub print_navigate_links (@) { Line 498  sub print_navigate_links (@) {
498      my $admineditable = 0;      my $admineditable = 0;
499      if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) {      if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) {
500          $editable = 0;          $editable = 0;
501          $admineditable = 1;          #$admineditable = 1;
502      } elsif (&is_editable($page) and $form{mycmd} =~ /^(read|write)$/) {      } elsif (&is_editable($page) and $form{mycmd} =~ /^(read|write)$/) {
503          $admineditable = 1;          #$admineditable = 1;
504          $editable = 1;          $editable = 1;
505      } else {      } else {
506          $editable = 0;          $editable = 0;
# Line 502  sub print_navigate_links (@) { Line 513  sub print_navigate_links (@) {
513          : qq()          : qq()
514      ]}      ]}
515      @{[ $editable      @{[ $editable
516          ? qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedpage" accesskey="E">$resource{editbutton} <kbd>E</kbd></a> | )          ? #qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedpage" accesskey="E">$resource{editbutton} <kbd>E</kbd></a> | )
517            qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedpage" accesskey="E">編集</a> | )
518          : qq()          : qq()
519      ]}      ]}
520      @{[ $admineditable      @{[ $admineditable
521          ? qq(<a href="$url_cgi?mycmd=diff;mypage=$cookedpage">$resource{diffbutton}</a> | )          ? qq(<a href="$url_cgi?mycmd=diff;mypage=$cookedpage">$resource{diffbutton}</a> | )
522          : qq()          : qq()
523      ]}      ]}
524      <a href="$url_cgi?$CreatePage">$resource{createbutton}</a> |      <a href="$url_cgi?$CreatePage" class="wiki">新規</a> |
525      <a href="$url_cgi?$IndexPage">$resource{indexbutton}</a> |      <a href="$url_cgi?$IndexPage" class="wiki">$resource{indexbutton}</a> |
526      <a href="$url_cgi?$RssPage">$resource{rssbutton}</a> |      <a href="$url_cgi?$FrontPage" class="wiki">首頁</a> |
527      <a href="$url_cgi?$FrontPage">$FrontPage</a> |      <a href="$url_cgi?$SearchPage" class="wiki">$resource{searchbutton}</a> |
528      <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> |
529      <a href="$url_cgi?$RecentChanges">$resource{recentchangesbutton}</a>      <a href="$url_cgi?$RecentChanges" class="wiki">最新</a>
530    </div>
531    EOH
532    <<EOH;  ## temp
533        <a href="$url_cgi?$CreatePage" class="wiki">$resource{createbutton}</a> |
534        <a href="$url_cgi?$IndexPage" class="wiki">$resource{indexbutton}</a> |
535    <!--    <a href="$url_cgi?$RssPage" class="wiki">$resource{rssbutton}</a> | -->
536        <a href="$url_cgi?$FrontPage" class="wiki">$FrontPage</a> |
537        <a href="$url_cgi?$SearchPage" class="wiki">$resource{searchbutton}</a> |
538        <a href="$url_cgi?mycmd=RandomJump;x-param=@{[time.[0..9]->[rand 10]]}" class="wiki randomlink">どこか</a> |
539        <a href="$url_cgi?$RecentChanges" class="wiki">$resource{recentchangesbutton}</a>
540  </div>  </div>
541  EOH  EOH
542  }  }
# Line 523  sub print_footer { Line 545  sub print_footer {
545      my ($page, $lm) = @_;      my ($page, $lm) = @_;
546      $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)
547      # Walrus mod (1) start      # Walrus mod (1) start
548    my $cvslog = '$Revision$ $Date$';    my $cvslog1 = q$Revision$;
549      my $cvslog2 = q$Date$;
550    print_navigate_links ($page);    print_navigate_links ($page);
551    print <<"EOD";    print <<"EOD";
552  @{[ $lm ? qq(<div id="wikipage-last-modified">Last modified: $lm</div>) : '' ]}  @{[ $lm ? qq(<div id="wikipage-last-modified">Last modified: $lm</div>) : '' ]}
553  <div class="footer">  <div class="footer">
554  <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>
555  <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>  
556  <div class="navigation">  <div class="navigation">
557  [<a href="/" title="このサーバーの首頁">/</a>  [<a href="/" title="このサーバーの首頁">/</a>
558  <a href="/map" title="このサーバーの案内">地図</a>  <a href="/map" title="このサーバーの案内">地図</a>
# Line 583  sub unescape { Line 601  sub unescape {
601    
602  sub print_content ($;$) {  sub print_content ($;$) {
603      my ($rawcontent, %option) = @_;      my ($rawcontent, %option) = @_;
604      print &text_to_html($rawcontent, toc=>1);      print &text_to_html($rawcontent, toc=>1, %option);
605  }  }
606    
607  sub text_to_html {  sub text_to_html {
608      my ($txt, %option) = @_;      my ($txt, %option) = @_;
609      my (@txt) = split(/\n/, $txt);      my (@txt) = split(/\n/, $txt);
610      my (@toc);      my @toc;
611        my @toc2 = @{$option{-toc}||[]};
612      my $tocnum = 0;      my $tocnum = 0;
613      my (@saved, @result);      my (@saved, @result);
614      unshift(@saved, "</p>");      unshift(@saved, "</p>");
# Line 667  sub text_to_html { Line 686  sub text_to_html {
686              push(@result, join('', '<tr>', @value, '</tr>'));              push(@result, join('', '<tr>', @value, '</tr>'));
687              # XXXXX              # XXXXX
688              #######              #######
689          } elsif (/^\[(INS|DEL|PRE)\[/) {          } elsif (/^\[(INS|DEL|PRE)\[\s*$/) {
690              push @result, splice (@saved), '<'.lc($1).'>';              push @result, splice (@saved), '<'.lc($1).'>';
691              unshift @saved, "</p>";              unshift @saved, "</p>";
692              push @result, "<p>";              push @result, "<p>";
693          } elsif (/^\](INS|DEL|PRE)\]/) {          } elsif (/^\](INS|DEL|PRE)\]\s*$/) {
694              push @result, splice (@saved), '</'.lc($1).'>';              push @result, splice (@saved), '</'.lc($1).'>';
695          } elsif (/^\[([0-9]+)\](.*)$/ && !$main::_EMBEDED) {          } elsif (/^\[([0-9]+)\](.*)$/ && !$main::_EMBEDED) {
696            my $num = 0+$1;            my $num = 0+$1;
# Line 688  sub text_to_html { Line 707  sub text_to_html {
707          # Convert @toc (table of contents) to HTML.          # Convert @toc (table of contents) to HTML.
708          # This part is taken from Makio Tsukamoto's WalWiki.          # This part is taken from Makio Tsukamoto's WalWiki.
709          my (@tocsaved, @tocresult);          my (@tocsaved, @tocresult);
710          foreach (@toc) {          foreach (@toc,@toc2) {
711              if (/^(-{1,6})(.*)$/) {              if (/^(-{1,6})(.*)$/) {
712                  &back_push('ul', length($1), \@tocsaved, \@tocresult);                  &back_push('ul', length($1), \@tocsaved, \@tocresult);
713                  push(@tocresult, '<li>' . $2 . '</li>');                  push(@tocresult, '<li>' . $2 . '</li>');
# Line 1158  sub conflict { Line 1177  sub conflict {
1177      my $content = join('', <FILE>);      my $content = join('', <FILE>);
1178      &code_convert(\$content, $kanjicode);      &code_convert(\$content, $kanjicode);
1179      close(FILE);      close(FILE);
1180      &print_header($page);      &print_header($page, -noindex => 1);
1181      &print_content($content);      &print_content($content);
1182      &print_editform($rawmsg, $form{myLastModified}, frozen=>0, conflict=>1);      &print_editform($rawmsg, $form{myLastModified}, frozen=>0, conflict=>1);
1183      &print_footer($page);      &print_footer($page);
# Line 1268  sub is_frozen { Line 1287  sub is_frozen {
1287  sub do_comment {  sub do_comment {
1288      my ($content) = $database{$form{mypage}};      my ($content) = $database{$form{mypage}};
1289      my $datestr = &get_now;      my $datestr = &get_now;
1290      my $namestr = " ''[[@{[$form{myname}||$DEFAULT_embed_comment_name]}]]'': ";      my $namestr = $form{myname} || $DEFAULT_embed_comment_name;
1291        if ($namestr =~ /^(?:>>)?[0-9]/) {
1292          $namestr = qq( ''$namestr'': );
1293        } else {
1294          $namestr = qq( ''[[$namestr]]'': );
1295        }
1296      my $anchor = 0;      my $anchor = 0;
1297      $content =~ s/(?:-+\s)?\[([0-9]+)\]/$anchor = $1 if $1 > $anchor; $&/mge;      $content =~ s/(?:-+\s)?\[([0-9]+)\]/$anchor = $1 if $1 > $anchor; $&/mge;
1298      $anchor++;      $anchor++;
# Line 1287  sub do_comment { Line 1311  sub do_comment {
1311      unless ($o) {      unless ($o) {
1312        $content .= "- [$anchor] $datestr$namestr$form{mymsg}\n";        $content .= "- [$anchor] $datestr$namestr$form{mymsg}\n";
1313      }      }
1314        $form{__comment_anchor_index} = $anchor;
1315      if ($form{mymsg}) {      if ($form{mymsg}) {
1316          $form{mymsg} = $content;          $form{mymsg} = $content;
1317          $form{mytouch} = 'on';          $form{mytouch} = 'on';
# Line 1472  sub do_diff { Line 1497  sub do_diff {
1497      }      }
1498      &open_diff;      &open_diff;
1499      my $title = $form{mypage};      my $title = $form{mypage};
1500      &print_header($title);      &print_header($title, -noindex => 1);
1501      $_ = &escape($diffbase{$form{mypage}});      $_ = &escape($diffbase{$form{mypage}});
1502      &close_diff;      &close_diff;
1503      print qq(<h3>$resource{difftitle}</h3>);      print qq(<h3>$resource{difftitle}</h3>);

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24