/[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.24 by wakaba, Fri Aug 30 04:31:11 2002 UTC revision 1.25 by wakaba, Sat Sep 28 09:43:07 2002 UTC
# Line 83  my $file_FrontPage = "$modifier_dir_data Line 83  my $file_FrontPage = "$modifier_dir_data
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 = 'wiki';
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 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 = '([^:]+):i:([^:].*)';  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_comment_Name_Prompt = '名前:';
125    my $DEFAULT_embed_comment_name = '名無しさん';
126  my $embed_interwiki = '^\[\[#(box|text|password):(\S+)\]\]$';    # Walrus add (5)  my $embed_interwiki = '^\[\[#(box|text|password):(\S+)\]\]$';    # Walrus add (5)
127  my %embed_command = (  my %embed_command = (
128          searched        => '^\[\[#searched:([^\]]+)\]\]$',          searched        => '^\[\[#searched:([^\]]+)\]\]$',
# Line 161  my %page_command = ( Line 163  my %page_command = (
163  );  );
164  my %command_do = (  my %command_do = (
165      read => \&do_read,      read => \&do_read,
166        TEXT_CSS => \&do_output_css,
167      edit => \&do_edit,      edit => \&do_edit,
168      adminedit => \&do_adminedit,      adminedit => \&do_adminedit,
169      adminchangepasswordform => \&do_adminchangepasswordform,      adminchangepasswordform => \&do_adminchangepasswordform,
# Line 203  sub main { Line 206  sub main {
206  sub do_read {  sub do_read {
207      &print_header($form{mypage});      &print_header($form{mypage});
208      &print_content($database{$form{mypage}});      &print_content($database{$form{mypage}});
209        print &text_to_html (q([[#comment]]));
210      my ($r, $c) = get_search_result ($form{mypage});      my ($r, $c) = get_search_result ($form{mypage});
211      if ($c) {      if ($c) {
212        print q{<h2>See also</h2>};        print q{<h2>See also</h2>};
# Line 211  sub do_read { Line 215  sub do_read {
215      &print_footer($form{mypage});      &print_footer($form{mypage});
216  }  }
217    
218    sub do_output_css {
219      my $content = $database{$form{mypage}};
220      if ($content =~ m#^\s*/\*\s*W3C-CSS#) {
221        print "Content-Type: text/css; charset=$charset\n";
222        print "\n";
223        print $content;
224      } else {
225        print "Status: 406 Unsupported Media Type\n";
226        &print_header('WikiPageIsNotCSS');
227        &print_content($database{WikiPageIsNotCSS});
228        &print_footer('WikiPageIsNotCSS');
229      }
230    }
231    
232  sub do_edit {  sub do_edit {
233      my ($page) = &unarmor_name(&armor_name($form{mypage}));      my ($page) = &unarmor_name(&armor_name($form{mypage}));
234      &print_header($page);      &print_header($page);
# Line 536  sub unescape { Line 554  sub unescape {
554    
555  sub print_content {  sub print_content {
556      my ($rawcontent) = @_;      my ($rawcontent) = @_;
557        $rawcontent =~ s#^SuikaWiki/0.9[^\x0D\x0A]*[\x0D\x0A]+##s;
558      print &text_to_html($rawcontent, toc=>1);      print &text_to_html($rawcontent, toc=>1);
559  }  }
560    
# Line 549  sub text_to_html { Line 568  sub text_to_html {
568      push(@result, "<p>");      push(@result, "<p>");
569      foreach (@txt) {      foreach (@txt) {
570          chomp;          chomp;
571          if (/^\*\*\*\*\*(.*)/) {          if (/^\*\*\*\*\*([^\x0D\x0A]*)/) {
572              push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));              push(@toc, qq(----- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
573              push(@result, splice(@saved), qq(<h6 id="i$tocnum">) . &inline($1) . '</h6>');              push(@result, splice(@saved), qq(<h6 id="i$tocnum">) . &inline($1) . '</h6>');
574              $tocnum++;              $tocnum++;
575          } elsif (/^\*\*\*\*(.*)/) {          } elsif (/^\*\*\*\*([^\x0D\x0A]*)/) {
576              push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));              push(@toc, qq(---- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
577              push(@result, splice(@saved), qq(<h5 id="i$tocnum">) . &inline($1) . '</h5>');              push(@result, splice(@saved), qq(<h5 id="i$tocnum">) . &inline($1) . '</h5>');
578              $tocnum++;              $tocnum++;
579          } elsif (/^\*\*\*(.*)/) {          } elsif (/^\*\*\*([^\x0D\x0A]*)/) {
580              push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));              push(@toc, qq(--- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
581              push(@result, splice(@saved), qq(<h4 id="i$tocnum">) . &inline($1) . '</h4>');              push(@result, splice(@saved), qq(<h4 id="i$tocnum">) . &inline($1) . '</h4>');
582              $tocnum++;              $tocnum++;
583          } elsif (/^\*\*(.*)/) {          } elsif (/^\*\*([^\x0D\x0A]*)/) {
584          # if (/^\*\*(.*)/) {          # if (/^\*\*(.*)/) {
585          # Walrus mod (6) end          # Walrus mod (6) end
586              push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));              push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
587              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>');
588              $tocnum++;              $tocnum++;
589          } elsif (/^\*(.*)/) {          } elsif (/^\*([^\x0D\x0A]*)/) {
590              push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));              push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
591              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>');
592              $tocnum++;              $tocnum++;
593          #} elsif (/^----/) {          } elsif (/^(={1,6})(.*)/) {
         #    push(@result, splice(@saved), '<hr>');  
         } elsif (/^(={1,5})(.*)/) {  
594              &back_push('ol', length($1), \@saved, \@result);              &back_push('ol', length($1), \@saved, \@result);
595              push(@result, '<li>' . &inline($2) . '</li>');              push(@result, '<li>' . &inline($2) . '</li>');
596          } elsif (/^(-{1,5})(.*)/) {          } elsif (/^(-{1,6})(.*)/) {
597              &back_push('ul', length($1), \@saved, \@result);              &back_push('ul', length($1), \@saved, \@result);
598              push(@result, '<li>' . &inline($2) . '</li>');              push(@result, '<li>' . &inline($2) . '</li>');
599          } elsif (/^:([^:]+):(.*)/) {          } elsif (/^:([^:]+):(.*)/) {
# Line 628  sub text_to_html { Line 645  sub text_to_html {
645          # This part is taken from Makio Tsukamoto's WalWiki.          # This part is taken from Makio Tsukamoto's WalWiki.
646          my (@tocsaved, @tocresult);          my (@tocsaved, @tocresult);
647          foreach (@toc) {          foreach (@toc) {
648              if (/^(-{1,3})(.*)/) {              if (/^(-{1,6})(.*)$/) {
649                  &back_push('ul', length($1), \@tocsaved, \@tocresult);                  &back_push('ul', length($1), \@tocsaved, \@tocresult);
650                  push(@tocresult, '<li>' . $2 . '</li>');                  push(@tocresult, '<li>' . $2 . '</li>');
651              }              }
# Line 662  sub inline { Line 679  sub inline {
679      $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|(\d\d\d\d-\d\d-\d\d \(\w\w\w\) \d\d:\d\d:\d\d)|<span class="date">$1</span>|g;   # Date
680      $line =~ s!      $line =~ s!
681        (        (
682          (?:&lt;(?:mailto|http|https|ftp|urn):[\x21-\x7E]*)&gt;          (?:&lt;(?:mailto|http|https|ftp|urn|news):[\x21-\x7E]*)&gt;
683        |        |
684          ($bracket_name) # [[likethis]], [[#comment]], [[Friend:remotelink]]          ($bracket_name) # [[likethis]], [[#comment]], [[Friend:remotelink]]
685        |        |
# Line 686  sub make_link { Line 703  sub make_link {
703      } elsif ($chunk =~ /^mailto:(.*)$/) {      } elsif ($chunk =~ /^mailto:(.*)$/) {
704          $name = $1;          $name = $1;
705      }      }
706      if ($use_autoimg and $name =~ /^(http|https|ftp|):.+\.(png|gif|jpe?g)/) {      if ($use_autoimg and $name =~ /^(http|https|ftp):.+\.(png|gif|jpe?g)/) {
707          $name = qq(<img src="$name">) ;          $name = qq(<img src="$name">) ;
708      }      }
709      $name = &unarmor_name($name);      $name = &unarmor_name($name);
710      # Walrus add (3) end      # Walrus add (3) end
711      if ($chunk =~ /^(http|https|ftp):/) {      if ($chunk =~ /^(http|https|ftp|news):/) {
712          # Walrus mod (3) start          # Walrus mod (3) start
713  #       if ($use_autoimg and $chunk =~ /\.(gif|png|jpeg|jpg)$/) {  #       if ($use_autoimg and $chunk =~ /\.(gif|png|jpeg|jpg)$/) {
714  #           return qq(<a href="$chunk"><img src="$chunk"></a>);  #           return qq(<a href="$chunk"><img src="$chunk"></a>);
# Line 824  sub get_subjectline { Line 841  sub get_subjectline {
841    
842          # Get the subject of the page.          # Get the subject of the page.
843          my $subject = $database{$page};          my $subject = $database{$page};
844            $subject =~ s#^SuikaWiki/0.9[^\x0D\x0A]*[\x0D\x0A]+##s;
845          $subject =~ s/\r?\n.*//s;          $subject =~ s/\r?\n.*//s;
846          return "$delim$subject";          return "$delim$subject";
847      }      }
# Line 931  sub print_editform { Line 949  sub print_editform {
949          }          }
950          $mymsg = &escape($form{mymsg});          $mymsg = &escape($form{mymsg});
951      } else {      } else {
952          $mymsg = &escape($mymsg);          $mymsg = &escape($mymsg || $database{NewPageTemplate});
953      }      }
954    
955      my $edit = $mode{admin} ? 'adminedit' : 'edit';      my $edit = $mode{admin} ? 'adminedit' : 'edit';
# Line 943  sub print_editform { Line 961  sub print_editform {
961      @{[ $mode{admin} ? qq($resource{frozenpassword} <input type="password" name="mypassword" value="$escapedmypassword" size="10"><br>) : "" ]}      @{[ $mode{admin} ? qq($resource{frozenpassword} <input type="password" name="mypassword" value="$escapedmypassword" size="10"><br>) : "" ]}
962      <input type="hidden" name="myLastModified" value="$lastmodified">      <input type="hidden" name="myLastModified" value="$lastmodified">
963      <input type="hidden" name="mypage" value="$escapedmypage">      <input type="hidden" name="mypage" value="$escapedmypage">
964      <textarea cols="$cols" rows="$rows" name="mymsg" wrap="off" tabindex="1">$mymsg</textarea><br>      <textarea cols="$cols" rows="$rows" name="mymsg" tabindex="1">$mymsg</textarea><br>
965  @{[  @{[
966      $mode{admin} ?      $mode{admin} ?
967      qq(      qq(
# Line 1005  sub is_editable { Line 1023  sub is_editable {
1023  #   not_wiki_name -> [[not_wiki_name]]  #   not_wiki_name -> [[not_wiki_name]]
1024  sub armor_name {  sub armor_name {
1025      my ($name) = @_;      my ($name) = @_;
1026      if ($name =~ /^$wiki_name$/) {      #if ($name =~ /^$wiki_name$/) {
1027          return $name;      #    return $name;
1028      } else {      #} else {
1029          return "[[$name]]";          return "[[$name]]";
1030      }      #}
1031  }  }
1032    
1033  # unarmor_name:  # unarmor_name:
# Line 1182  sub is_frozen { Line 1200  sub is_frozen {
1200  sub do_comment {  sub do_comment {
1201      my ($content) = $database{$form{mypage}};      my ($content) = $database{$form{mypage}};
1202      my $datestr = &get_now;      my $datestr = &get_now;
1203      my $namestr = $form{myname} ? " ''[[$form{myname}]]'' : " : " ";      my $namestr = " ''[[@{[$form{myname}||$DEFAULT_embed_comment_name]}]]'' : ";
1204      if ($content =~ s/(\Q$embed_comment\E)/- $datestr$namestr$form{mymsg}\n$1/) {      #if ($content =~ s/(\Q$embed_comment\E)/- $datestr$namestr$form{mymsg}\n$1/) {
1205          ;      #  ;
1206      } else {      #} else {
1207          $content =~ s/(\Q$embed_rcomment\E)/$1\n- $datestr$namestr$form{mymsg}/;      #  $content =~ s/(\Q$embed_rcomment\E)/$1\n- $datestr$namestr$form{mymsg}/;
1208        #}
1209        my $i = 0;  my $o = 0;
1210        $content =~ s{(\Q$embed_comment\E|\Q$embed_rcomment\E)}{
1211          my $embed = $1;
1212          if ($i == $form{comment_index}) {
1213            if ($embed eq $embed_comment) {
1214              $embed = "- $datestr$namestr$form{mymsg}\n$embed";  $o = 1;
1215            } else {
1216              $embed .= "\n- $datestr$namestr$form{mymsg}";  $o = 1;
1217            }
1218          }
1219          $i++; $embed;
1220        }ge;
1221        unless ($o) {
1222          $content .= "- $datestr$namestr$form{mymsg}\n";
1223      }      }
1224      if ($form{mymsg}) {      if ($form{mymsg}) {
1225          $form{mymsg} = $content;          $form{mymsg} = $content;
# Line 1198  sub do_comment { Line 1231  sub do_comment {
1231      }      }
1232  }  }
1233    
1234    my $_O_COMMENT_INDEX = 0;
1235  sub embedded_to_html {  sub embedded_to_html {
1236      my ($embedded) = @_;      my ($embedded) = @_;
1237      if ($embedded eq $embed_comment or $embedded eq $embed_rcomment) {      if ($embedded eq $embed_comment or $embedded eq $embed_rcomment) {
# Line 1208  sub embedded_to_html { Line 1242  sub embedded_to_html {
1242      <input type="hidden" name="mypage" value="$form{mypage}">      <input type="hidden" name="mypage" value="$form{mypage}">
1243      <input type="hidden" name="myLastModified" value="$lastmodified">      <input type="hidden" name="myLastModified" value="$lastmodified">
1244      <input type="hidden" name="mytouch" value="on">      <input type="hidden" name="mytouch" value="on">
1245      $resource{yourname}      <input type="hidden" name="comment_index" value="@{[$_O_COMMENT_INDEX++]}">
1246        $embed_comment_Name_Prompt
1247      <input type="text" name="myname" value="" size="10">      <input type="text" name="myname" value="" size="10">
1248      <input type="text" name="mymsg" value="" size="40">      <input type="text" name="mymsg" value="" size="40">
1249      <input type="submit" value="$resource{commentbutton}">      <input type="submit" value="$resource{commentbutton}">

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24