/[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.18 by wakaba, Sun Jun 2 06:19:43 2002 UTC revision 1.22 by wakaba, Sun Jun 30 07:52:46 2002 UTC
# Line 117  my $wiki_name   = '\b([A-Z][a-z]+([A-Z][ Line 117  my $wiki_name   = '\b([A-Z][a-z]+([A-Z][
117  my $bracket_name = '\[\[(\S+?)\]\]';  my $bracket_name = '\[\[(\S+?)\]\]';
118  my $embedded_name = '\[\[(#\S+?)\]\]';  my $embedded_name = '\[\[(#\S+?)\]\]';
119  my $interwiki_definition = '\[\[(\S+?)\ (\S+?)\]\]';  my $interwiki_definition = '\[\[(\S+?)\ (\S+?)\]\]';
120  my $interwiki_name = '([^:]+):([^:].*)';  my $interwiki_name = '([^:]+):i:([^:].*)';
121  ##############################  ##############################
122  my $embed_comment = '[[#comment]]';  my $embed_comment = '[[#comment]]';
123  my $embed_rcomment = '[[#rcomment]]';  my $embed_rcomment = '[[#rcomment]]';
124  my $embed_interwiki = '^\[\[#(box|text|password):(\S+)\]\]$';    # Walrus add (5)  my $embed_interwiki = '^\[\[#(box|text|password):(\S+)\]\]$';    # Walrus add (5)
125    my %embed_command = (
126            searched        => '^\[\[#searched:([^\]]+)\]\]$',
127    );
128  ##############################  ##############################
129  my $info_LastModified = 'LastModified';  my $info_LastModified = 'LastModified';
130  my $info_IsFrozen = 'IsFrozen';  my $info_IsFrozen = 'IsFrozen';
# Line 200  sub main { Line 203  sub main {
203  sub do_read {  sub do_read {
204      &print_header($form{mypage});      &print_header($form{mypage});
205      &print_content($database{$form{mypage}});      &print_content($database{$form{mypage}});
206        my ($r, $c) = get_search_result ($form{mypage});
207        if ($c) {
208          print q{<h2>See also</h2>};
209          print $r;
210        }
211      &print_footer($form{mypage});      &print_footer($form{mypage});
212  }  }
213    
# Line 308  sub do_write { Line 316  sub do_write {
316              &update_recent_changes;              &update_recent_changes;
317          }          }
318          &set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen});          &set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen});
319          &print_header($CompletedSuccessfully);          &print_header($CompletedSuccessfully, -goto => $url_cgi.'?'.&encode($form{mypage}));
320          &print_message($resource{saved});          &print_message($resource{saved});
321          &print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}");          &print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}");
322          &print_footer($CompletedSuccessfully);          &print_footer($CompletedSuccessfully);
# Line 332  sub do_searchform { Line 340  sub do_searchform {
340  }  }
341    
342  sub do_search {  sub do_search {
343      my $word = &escape($form{mymsg});      my $word = $form{mymsg};
344      &print_header($SearchPage);      &print_header($SearchPage);
345      &print_searchform($word);      &print_searchform(&escape($word));
346      my $counter = 0;      print get_search_result ($word, -output_not_found => 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>|;  
     }  
347      &print_footer($SearchPage);      &print_footer($SearchPage);
348  }  }
349    
350    sub get_search_result ($;%) {
351      my $word = shift;
352      my %option = @_;
353      my $counter = 0;
354      my $r = '';
355      foreach my $page (sort keys %database) {
356        next if $page eq $RecentChanges;
357        if (   index ($database{$page}, $word) > 0
358            || index ($page, $word) > 0
359            || index ($word, $page) > 0
360           ) {
361          $r .= qq(<li><a href ="$url_cgi?@{[&encode($page)]}">$page</a>@{[&escape(&get_subjectline($page))]}</li>);
362          $counter++;
363        }
364      }
365      $r = qq|<ul>$r</ul>| if $r;
366      get_message ($resource{notfound})
367        if $counter == 0 && $option{-output_not_found};
368      wantarray? ($r, $counter): $r;
369    }
370    
371  sub do_create {  sub do_create {
372      &print_header($CreatePage);      &print_header($CreatePage);
373      print <<"EOD";      print <<"EOD";
# Line 386  sub print_error { Line 400  sub print_error {
400  }  }
401    
402  sub print_header {  sub print_header {
403      my ($page) = @_;      my ($page,%option) = @_;
404      my $bodyclass = "normal";      my $bodyclass = "normal";
     my $editable = 0;  
     my $admineditable = 0;  
405      if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) {      if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) {
         $editable = 0;  
         $admineditable = 1;  
406          $bodyclass = "frozen";          $bodyclass = "frozen";
407      } elsif (&is_editable($page) and $form{mycmd} =~ /^(read|write)$/) {      }
408          $admineditable = 1;      if ($option{-goto}) {
409          $editable = 1;        print qq{Refresh: 0; url="$option{-goto}"\n};
     } else {  
         $editable = 0;  
410      }      }
411      my $cookedpage = &encode($page);      my $cookedpage = &encode($page);
412      print <<"EOD";      print <<"EOD";
# Line 417  Content-Style-Type: text/css Line 425  Content-Style-Type: text/css
425      <link rel="stylesheet" type="text/css" href="$url_stylesheet">      <link rel="stylesheet" type="text/css" href="$url_stylesheet">
426  </head>  </head>
427  <body class="$bodyclass">  <body class="$bodyclass">
428    EOD
429      &print_navigate_links ($page);
430      print <<EOD;
431    <h1 class="header"><a
432        title="$resource{searchthispage}"
433        href="$url_cgi?mycmd=search;mymsg=$cookedpage">$page</a>@{[&escape(&get_subjectline($page))]}</h1>
434    EOD
435    }
436    
437    sub print_navigate_links (@) {
438      my ($page) = @_;
439        my $editable = 0;
440        my $admineditable = 0;
441        if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) {
442            $editable = 0;
443            $admineditable = 1;
444        } elsif (&is_editable($page) and $form{mycmd} =~ /^(read|write)$/) {
445            $admineditable = 1;
446            $editable = 1;
447        } else {
448            $editable = 0;
449        }
450        my $cookedpage = &encode($page);
451      print <<EOH;
452  <div class="tools">  <div class="tools">
453      @{[ $admineditable      @{[ $admineditable
454          ? 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> | )
455          : qq()          : qq()
456      ]}      ]}
457      @{[ $editable      @{[ $editable
458          ? 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> | )
459          : qq()          : qq()
460      ]}      ]}
461      @{[ $admineditable      @{[ $admineditable
# Line 437  Content-Style-Type: text/css Line 469  Content-Style-Type: text/css
469      <a href="$url_cgi?$SearchPage">$resource{searchbutton}</a> |      <a href="$url_cgi?$SearchPage">$resource{searchbutton}</a> |
470      <a href="$url_cgi?$RecentChanges">$resource{recentchangesbutton}</a>      <a href="$url_cgi?$RecentChanges">$resource{recentchangesbutton}</a>
471  </div>  </div>
472  <h1 class="header"><a  EOH
     title="$resource{searchthispage}"  
     href="$url_cgi?mycmd=search;mymsg=$cookedpage">$page</a>@{[&escape(&get_subjectline($page))]}</h1>  
 EOD  
473  }  }
474    
475  sub print_footer {  sub print_footer {
476      my ($page) = @_;      my ($page) = @_;
477      $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)
478      # Walrus mod (1) start      # Walrus mod (1) start
479      print <<"EOD";    my $cvslog = '$Revision$ $Date$';
480      print_navigate_links ($page);
481      print <<"EOD";
482  <div class="footer">  <div class="footer">
483  <p>  <p>
484  <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="http://digit.que.ne.jp/work/">WalWiki</a> $walversion &copy; 2000-2002 by <a href="http://digit.que.ne.jp/">Makio Tsukamoto</a>.<br />
485  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 />  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 />
486  <a href="/gate/cvs/wakaba/wiki/" title="CVS Repository">  <a href="/gate/cvs/wakaba/wiki/" title="CVS Repository">
487  $Revision$ $Date$  $cvslog
488  </a>  </a>
489  </p>  </p>
490  <div class="navigation">  <div class="navigation">
# Line 462  $Revision$ $Date$ Line 493  $Revision$ $Date$
493  <a href="/search/" title="このサーバーの検索">検索</a>]  <a href="/search/" title="このサーバーの検索">検索</a>]
494  </div>  </div>
495  </div>  </div>
496  $walrus_log <!-- Walrus add (debug) -->  $walrus_log
497  </body>  </body>
498  </html>  </html>
499  EOD  EOD
# Line 518  sub text_to_html { Line 549  sub text_to_html {
549      foreach (@txt) {      foreach (@txt) {
550          chomp;          chomp;
551          # Walrus mod (6) start          # Walrus mod (6) start
552          if ($saved[0] eq '</html>') {          #if ($saved[0] eq '</html>') {
553              if (/<\/html>/i) { splice(@saved); }          #    if (/<\/html>/i) { splice(@saved); }
554              else { push (@result, &html_to_ignored_html($_)); }          #    else { push (@result, &html_to_ignored_html($_)); }
555          } elsif (/^<html>/i and &is_ignore_html($form{mypage})) {          #} elsif (/^<html>/i and &is_ignore_html($form{mypage})) {
556              push(@result, splice(@saved));          #    push(@result, splice(@saved));
557              push(@saved, '</html>');          #    push(@saved, '</html>');
558            #} els
559          if (/^\*\*\*\*\*(.*)/) {          if (/^\*\*\*\*\*(.*)/) {
560              push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));              push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));
561              push(@result, splice(@saved), qq(<h6 id="i$tocnum">) . &inline($1) . '</h6>');              push(@result, splice(@saved), qq(<h6 id="i$tocnum">) . &inline($1) . '</h6>');
# Line 654  sub inline { Line 686  sub inline {
686  sub make_link {  sub make_link {
687      my $chunk = shift;      my $chunk = shift;
688      # Walrus add (3) start      # Walrus add (3) start
689        $chunk =~ s/^&lt;(.*)&gt;$/$1/;
690      my $name  = $chunk;      my $name  = $chunk;
     $name =~ s/^&lt;(.*)&gt;$/$1/;  
691      if ($chunk =~ /^\[\[([^ ]+?) ([^ ]+?)\]\]$/ and $form{mypage} ne $InterWikiName) {      if ($chunk =~ /^\[\[([^ ]+?) ([^ ]+?)\]\]$/ and $form{mypage} ne $InterWikiName) {
692          ($name, $chunk) = ($1, $2);          ($name, $chunk) = ($1, $2);
693      } elsif ($chunk =~ /^mailto:(.*)$/) {      } elsif ($chunk =~ /^mailto:(.*)$/) {
# Line 673  sub make_link { Line 705  sub make_link {
705  #       } else {  #       } else {
706  #           return qq(<a href="$chunk">$chunk</a>);  #           return qq(<a href="$chunk">$chunk</a>);
707  #       }  #       }
708          return qq(<a href="$chunk">$name</a>);          return qq(&lt;<a href="$chunk">$name</a>&gt;);
709          # Walrus mod (3) end          # Walrus mod (3) end
710      } elsif ($chunk =~ m#^urn:[0-9A-Za-z_:;/.-]+#) {      } elsif ($chunk =~ m#^urn:[0-9A-Za-z_:;/.-]+#) {
711          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 707  sub make_link { Line 739  sub make_link {
739              return qq(<a title="$subject" href="$url_cgi?$cookedchunk">$name</a>);   # Walrus add (3)              return qq(<a title="$subject" href="$url_cgi?$cookedchunk">$name</a>);   # Walrus add (3)
740          } elsif ($page_command{$chunk}) {          } elsif ($page_command{$chunk}) {
741  #           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)
742              return qq(<a title="$chunk" href="$url_cgi?$cookedchunk">$name</a>);     # Walrus add (3)              return qq(<a title="$chunk" href="$url_cgi?$cookedchunk" class="wiki">$name</a>);     # Walrus add (3)
743          } else {          } else {
744  #           return qq($chunk<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit&amp;mypage=$cookedchunk">$editchar</a>); # Walrus del (3)              return qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedchunk" class="wiki">$name<span class="mark">$editchar</span></a>);
             return qq($name<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit&amp;mypage=$cookedchunk">$editchar</a>);  # Walrus add (3)  
745          }          }
746      }      }
747  }  }
# Line 753  sub print_message { Line 784  sub print_message {
784      print qq(<p><strong>$msg</strong></p>);      print qq(<p><strong>$msg</strong></p>);
785  }  }
786    
787    sub get_message {
788        my ($msg) = @_;
789        qq(<p><strong>$msg</strong></p>);
790    }
791    
792  sub init_form {  sub init_form {
793      if (param()) {      if (param()) {
794          foreach my $var (param()) {          foreach my $var (param()) {
# Line 945  sub print_editform { Line 981  sub print_editform {
981      @{[ $mode{admin} ? qq($resource{frozenpassword} <input type="password" name="mypassword" value="$form{mypassword}" size="10"><br>) : "" ]}      @{[ $mode{admin} ? qq($resource{frozenpassword} <input type="password" name="mypassword" value="$form{mypassword}" size="10"><br>) : "" ]}
982      <input type="hidden" name="myLastModified" value="$lastmodified">      <input type="hidden" name="myLastModified" value="$lastmodified">
983      <input type="hidden" name="mypage" value="$form{mypage}">      <input type="hidden" name="mypage" value="$form{mypage}">
984      <textarea cols="$cols" rows="$rows" name="mymsg" wrap="off">$mymsg</textarea><br>      <textarea cols="$cols" rows="$rows" name="mymsg" wrap="off" tabindex="1">$mymsg</textarea><br>
985  @{[  @{[
986      $mode{admin} ?      $mode{admin} ?
987      qq(      qq(
# Line 958  sub print_editform { Line 994  sub print_editform {
994      qq(      qq(
995          <input type="checkbox" name="mytouch" value="on" checked="checked">$resource{touch}<br>          <input type="checkbox" name="mytouch" value="on" checked="checked">$resource{touch}<br>
996          <input type="submit" name="mypreview_$edit" value="$resource{previewbutton}">          <input type="submit" name="mypreview_$edit" value="$resource{previewbutton}">
997          <input type="submit" name="mypreview_write" value="$resource{savebutton}"><br>          <input type="submit" name="mypreview_write" value="$resource{savebutton}" accesskey="S"><kbd>S</kbd><br>
998      )      )
999  ]}  ]}
1000  </form>  </form>
# Line 1216  sub embedded_to_html { Line 1252  sub embedded_to_html {
1252      <input type="submit" value="$resource{commentbutton}">      <input type="submit" value="$resource{commentbutton}">
1253  </form>  </form>
1254  EOD  EOD
1255      } elsif ($embedded =~ /$embed_command{searched}/) {
1256        return get_search_result ($1);
1257      # Walrus add (5) start      # Walrus add (5) start
1258      } elsif ($embedded =~ /$embed_interwiki/ and my $remoteurl = $interwiki{$2}) {      } elsif ($embedded =~ /$embed_interwiki/ and my $remoteurl = $interwiki{$2}) {
1259          $_ = &make_interwiki_box($1, $2);          $_ = &make_interwiki_box($1, $2);

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.22

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24