/[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.5 by wakaba, Mon Feb 4 15:22:00 2002 UTC revision 1.14 by wakaba, Tue Apr 2 01:32:31 2002 UTC
# Line 75  my $preview_color = '#FFCCCC'; Line 75  my $preview_color = '#FFCCCC';
75  ##############################  ##############################
76  # 全ページのスタイル  # 全ページのスタイル
77  my $style = <<'EOD';  my $style = <<'EOD';
78  pre, dl, ul, ol, p, blockquote { line-height:120%; }  @import '/s/simpledoc';
79    pre, dl, ul, ol, p, blockquote { line-height:120%;
80    margin-bottom: 1em}
81    a.wiki .mark    {vertical-align: sub, color: GrayText}
82  a { text-decoration: none; }  a { text-decoration: none; }
83  a:link { color: #0000FF; background-color: #FFFFFF; }  a:link { color: #0000FF; background-color: #FFFFFF; }
84  a:visited { color: #9900CC; background-color: #FFFFFF; }  a:visited { color: #9900CC; background-color: #FFFFFF; }
# Line 108  my @uneditable = ( $whatsnew ); Line 111  my @uneditable = ( $whatsnew );
111  # 文字']'を1つ多くとるようにしている。  # 文字']'を1つ多くとるようにしている。
112  #  #
113  my $WikiName = '([A-Z][a-z]+([A-Z][a-z]+)+)';  my $WikiName = '([A-Z][a-z]+([A-Z][a-z]+)+)';
114  my $BracketName = '\[\[([^>\s]+?\]?)\]\]';  my $BracketName = '\[\[([^>\x09]+?\]?)\]\]';
115    
116  # アイコン部分のタグ  # アイコン部分のタグ
117  my $IconTag = ''; #<<"EOD";  my $IconTag = ''; #<<"EOD";
# Line 564  sub inline { Line 567  sub inline {
567      $line =~ s|'''([^']+?)'''|<strong>$1</strong>|g;      $line =~ s|'''([^']+?)'''|<strong>$1</strong>|g;
568      $line =~ s|''([^']+?)''|<em>$1</em>|g;                $line =~ s|''([^']+?)''|<em>$1</em>|g;          
569      $line =~ s!      $line =~ s!
570                  (         (
571                      (<(mailto|http|https|ftp|urn):[\x21-\x7E]*)> # Direct http://...           (?:&lt;(?:mailto|http|https|ftp|urn):[\x21-\x7E]*)&gt;
572                          |         #| (?:$WikiName)                         # LocalLinkLikeThis
573                      ($WikiName)                         # LocalLinkLikeThis         | (?:$BracketName)                      # [[日本語リンク]]
574                          |         )
                     ($BracketName)                      # [[日本語リンク]]  
                 )  
575              !              !
576                  &make_link($1)                  &make_link($1)
577              !gex;              !gex;
# Line 580  sub inline { Line 581  sub inline {
581  # ページのタイトルからページの内容を得る  # ページのタイトルからページの内容を得る
582  sub get_page {  sub get_page {
583      my $page_name = shift;      my $page_name = shift;
584      return $database{$page_name};      return $database{$page_name} || $database{'[['.$page_name.']]'};
585  }  }
586    
587  # ページの内容を与える  # ページの内容を与える
# Line 617  sub set_page { Line 618  sub set_page {
618  sub print_header {  sub print_header {
619      my $title = shift;      my $title = shift;
620      print <<"EOD";      print <<"EOD";
621  Content-type: text/html  Content-type: text/html; charset=${charset}
622    
623  <html><head>  <html><head>
624  <title>$title</title>  <title>$title</title>
# Line 647  EOD Line 648  EOD
648  <a href="$thisurl?mycmd=list">一覧</a> |  <a href="$thisurl?mycmd=list">一覧</a> |
649  $editlink  $editlink
650  <a href="$thisurl?mycmd=search">単語検索</a> |  <a href="$thisurl?mycmd=search">単語検索</a> |
651  <a href="$thisurl?mycmd=read;mypage=$whatsnew">最終更新</a>  <a href="$thisurl?mycmd=read;mypage=$whatsnew">最近の更新</a>
652   ]   ]
653  </p>  </p>
654  EOD  EOD
# Line 656  EOD Line 657  EOD
657  # ページのフッタを出力  # ページのフッタを出力
658  sub print_footer {  sub print_footer {
659      print <<"EOD";      print <<"EOD";
660  <address>  <div class="navigation">
 <a href="http://www.hyuki.com/yukiwiki/">YukiWiki</a> 1.6.6 Copyright (C) 2000,2001 by <a href="http://www.hyuki.com/">Hiroshi Yuki.</a>  
 + <a href="$modifierlink">$modifier</a> ${version}.  
661  [<a href="/" title="このサーバーの首頁">/</a>  [<a href="/" title="このサーバーの首頁">/</a>
662  <a href="/map" title="このサーバーの案内">地図</a>  <a href="/map" title="このサーバーの案内">地図</a>
663  <a href="/search/" title="このサーバーの検索">検索</a>]  <a href="/search/" title="このサーバーの検索">検索</a>]
664  </address>  </div>
 </body></html>  
665  EOD  EOD
666      print <<'EOH';
667    <div class="update">
668    <a href="http://www.hyuki.com/yukiwiki/">YukiWiki</a> 1.6.6 Copyright (C) 2000,2001 by <a href="http://www.hyuki.com/">Hiroshi Yuki.</a> ${version}
669    + <a href="$modifierlink">$modifier</a>.
670    <a href="/gate/cvs/wakaba/wiki/" title="CVS Repository">
671    $Revision$ $Date$
672    </a>
673    </div>
674    </body></html>
675    EOH
676  }  }
677    
678  # URLやページの名前からリンクを作る  # URLやページの名前からリンクを作る
679  sub make_link {  sub make_link {
680      my $name = shift;      my $name = shift;
681        $name =~ s/^&lt;(.*)&gt;$/$1/;
682        $name =~ s/^\[\[(.*)\]\]$/$1/;
683      if ($name =~ /^(http|https|ftp).*?(\.png|\.jpeg|\.jpg)?$/) {      if ($name =~ /^(http|https|ftp).*?(\.png|\.jpeg|\.jpg)?$/) {
684          if ($2) {          if ($2) {
685              return qq|<a href="$name"><img border="0" src="$name" /></a>|;              return qq|<a href="$name"><img border="0" src="$name" /></a>|;
# Line 679  sub make_link { Line 689  sub make_link {
689      } elsif ($name =~ /^mailto:(.*)/) {      } elsif ($name =~ /^mailto:(.*)/) {
690          my $address = $1;          my $address = $1;
691          return qq|&lt;<a href="$name">$address</a>&gt;|;          return qq|&lt;<a href="$name">$address</a>&gt;|;
692      } elsif ($name =~ /^urn:[0-9A-Za-z_:-]+/) {      } elsif ($name =~ m#^urn:[0-9A-Za-z_:;/.-]+#) {
693          return qq|&lt;<a href="/uri-res/N2L?${name}">$name</a>&gt;|;          return qq|&lt;<a href="/uri-res/N2L?${name}">$name</a>&gt;|;
     } elsif ($database{$name}) {  
         my $percent_name = &encode_percent($name);  
         return qq|<a href="$thisurl?mycmd=read;mypage=$percent_name">$name</a>|;  
694      } else {      } else {
695          my $percent_name = &encode_percent($name);        my $name2 = $name; $name2 =~ tr/\x20/-/;
696          return qq|$name<a href="$thisurl?mycmd=edit;mypage=$percent_name">?</a>|;        if ($database{$name2}) {
697            my $percent_name = &encode_percent($name2);
698            return qq|<a href="$thisurl?mycmd=read;mypage=$percent_name" class="wiki">$name</a>|;
699          } elsif ($database{'[['.$name2.']]'}) {
700            my $percent_name = &encode_percent('[['.$name2.']]');
701            return qq|<a href="$thisurl?mycmd=read;mypage=$percent_name" class="wiki">$name</a>|;
702          } else {
703            my $percent_name = &encode_percent($name2);
704            return qq|<a href="$thisurl?mycmd=edit;mypage=$percent_name" class="wiki newpage">$name<span class="mark">?</span></a>|;
705          }
706      }      }
707  }  }
708    
# Line 714  sub convert_html { Line 730  sub convert_html {
730      my (@txt) = split(/\n/, $txt);      my (@txt) = split(/\n/, $txt);
731      foreach (@txt) {      foreach (@txt) {
732          chomp;          chomp;
733          if (/^\*\*(.*)/) {          if (/^\*\*\*\*\*(.*)/) {
734                push(@result, splice(@saved), '<h6>' . &inline($1) . '</h6>');
735            } elsif (/^\*\*\*\*(.*)/) {
736                push(@result, splice(@saved), '<h5>' . &inline($1) . '</h5>');
737            } elsif (/^\*\*\*(.*)/) {
738                push(@result, splice(@saved), '<h4>' . &inline($1) . '</h4>');
739            } elsif (/^\*\*(.*)/) {
740              push(@result, splice(@saved), '<h3>' . &inline($1) . '</h3>');              push(@result, splice(@saved), '<h3>' . &inline($1) . '</h3>');
741          } elsif (/^\*(.*)/) {          } elsif (/^\*(.*)/) {
742              push(@result, splice(@saved), '<h2>' . &inline($1) . '</h2>');              push(@result, splice(@saved), '<h2>' . &inline($1) . '</h2>');
# Line 723  sub convert_html { Line 745  sub convert_html {
745          } elsif (/^(-{1,3})(.*)/) {          } elsif (/^(-{1,3})(.*)/) {
746              &back_push('ul', length($1));              &back_push('ul', length($1));
747              push(@result, '<li>' . &inline($2) . '</li>');              push(@result, '<li>' . &inline($2) . '</li>');
748            } elsif (/^(={1,3})(.*)/) {
749                &back_push('ol', length($1));
750                push(@result, '<li>' . &inline($2) . '</li>');
751          } elsif (/^:([^:]+):(.*)/) {          } elsif (/^:([^:]+):(.*)/) {
752              &back_push('dl', 1);              &back_push('dl', 1);
753              push(@result, '<dt>' . &inline($1) . '</dt>', '<dd>' . &inline($2) . '</dd>');              push(@result, '<dt>' . &inline($1) . '</dt>', '<dd>' . &inline($2) . '</dd>');
# Line 735  sub convert_html { Line 760  sub convert_html {
760              push(@result, "<p>");              push(@result, "<p>");
761          } elsif (/^(\s+.*)$/) {          } elsif (/^(\s+.*)$/) {
762              &back_push('pre', 1);              &back_push('pre', 1);
763              push(@result, &escape($1)); # Not &inline, but &escape              #push(@result, &escape($1)); # Not &inline, but &escape
764                push(@result, &inline($1)); # Not &inline, but &escape
765          } else {          } else {
766              push(@result, &inline($_));              push(@result, &inline($_));
767          }          }
# Line 761  sub back_push { Line 787  sub back_push {
787  }  }
788    
789  # 編集可能ページか?  # 編集可能ページか?
790  sub is_editable {  sub is_editable {return 1;
791    ## TODO: ...
792      my ($pagename) = @_;      my ($pagename) = @_;
793      foreach (@uneditable) {      foreach (@uneditable) {
794          if ($pagename eq $_) {          if ($pagename eq $_) {
# Line 774  sub is_editable { Line 801  sub is_editable {
801      return 0;      return 0;
802  }  }
803    
804  # Validな名前か?  # Validな名前か?
805  sub is_valid_name {  sub is_valid_name {
806      my ($pagename) = @_;      my ($pagename) = @_;
807      if ($pagename =~ /^$WikiName$/) {      if ($pagename =~ /^$WikiName$/) {

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.14

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24