/[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.23 by wakaba, Sun Aug 18 04:14:35 2002 UTC revision 1.26 by wakaba, Sat Sep 28 10:54:27 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 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 = '([^:]+):i:([^:].*)';  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 = (  my %embed_command = (
129          searched        => '^\[\[#searched:([^\]]+)\]\]$',          searched        => '^\[\[#searched:([^\]]+)\]\]$',
# Line 161  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 201  sub main { Line 205  sub main {
205  }  }
206    
207  sub do_read {  sub do_read {
208      &print_header($form{mypage});    &print_header($form{mypage});
209      &print_content($database{$form{mypage}});    my $content = $database{$form{mypage}};
210      my ($r, $c) = get_search_result ($form{mypage});      my $cf = 'SuikaWiki/0.9';
211        $cf = $1 if $content =~ s#^(?:/\*\s*|\#\?)?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:\s[^\x0D\x0A]+)?)[\x0D\x0A]+##s;
212        if ($cf =~ m#^SuikaWiki/0.9(?:$|\s)#) {
213          &print_content($content, $cf);
214          print &text_to_html (q([[#comment]]));
215        } else {
216          print "<pre>@{[&escape($content)]}</pre>";
217        }
218      my ($r, $c) = get_search_result ($form{mypage});
219      if ($c) {      if ($c) {
220        print q{<h2>See also</h2>};        print q{<h2 id="SEE-ALSO">See also</h2>};
221        print $r;        print $r;
222      }      }
223      &print_footer($form{mypage});    &print_footer($form{mypage});
224    }
225    
226    sub do_output_css {
227      my $content = $database{$form{mypage}};
228      if ($content =~ m#^\s*/\*\s*W3C-CSS#) {
229        print "Content-Type: text/css; charset=$charset\n";
230        print "\n";
231        print $content;
232      } else {
233        print "Status: 406 Unsupported Media Type\n";
234        &print_header('WikiPageIsNotCSS');
235        &print_content($database{WikiPageIsNotCSS});
236        &print_footer('WikiPageIsNotCSS');
237      }
238  }  }
239    
240  sub do_edit {  sub do_edit {
# Line 274  sub do_index { Line 300  sub do_index {
300      print qq(<ul>);      print qq(<ul>);
301      foreach my $page (sort keys %database) {      foreach my $page (sort keys %database) {
302          if (&is_editable($page)) {          if (&is_editable($page)) {
303              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>);
304              # print qq(<li>@{[&get_info($page, $info_IsFrozen)]}</li>);              # print qq(<li>@{[&get_info($page, $info_IsFrozen)]}</li>);
305              # print qq(<li>@{[0 + &is_frozen($page)]}</li>);              # print qq(<li>@{[0 + &is_frozen($page)]}</li>);
306          }          }
# Line 343  sub do_search { Line 369  sub do_search {
369      my $word = $form{mymsg};      my $word = $form{mymsg};
370      &print_header($SearchPage);      &print_header($SearchPage);
371      &print_searchform(&escape($word));      &print_searchform(&escape($word));
372      print get_search_result ($word, -output_not_found => 1);      print scalar get_search_result ($word, -output_not_found => 1);
     print "foo";  
373      &print_footer($SearchPage);      &print_footer($SearchPage);
374  }  }
375    
# Line 359  sub get_search_result ($;%) { Line 384  sub get_search_result ($;%) {
384          || index ($page, $word) > 0          || index ($page, $word) > 0
385          || index ($word, $page) > 0          || index ($word, $page) > 0
386         ) {         ) {
387        $r .= qq(<li><a href ="$url_cgi?@{[&escape(&encode($page))]}">@{[&escape($page)]}</a>@{[&escape(&get_subjectline($page))]}</li>);        $r .= qq(<li><a href ="$url_cgi?@{[&encode($page)]}" class="wiki">@{[&escape($page)]}</a>@{[&escape(&get_subjectline($page))]}</li>);
388        $counter++;        $counter++;
389      }      }
390    }    }
# Line 410  sub print_header { Line 435  sub print_header {
435        print qq{Refresh: 0; url="$option{-goto}"\n};        print qq{Refresh: 0; url="$option{-goto}"\n};
436      }      }
437      my $cookedpage = &encode($page);      my $cookedpage = &encode($page);
438        my $escapedpage = &escape($page);
439      print <<"EOD";      print <<"EOD";
440  Content-type: text/html; charset=$charset  Content-type: text/html; charset=$charset
441  Content-Language: $lang  Content-Language: $lang
# Line 420  Content-Style-Type: text/css Line 446  Content-Style-Type: text/css
446      "http://www.w3.org/TR/html4/loose.dtd">      "http://www.w3.org/TR/html4/loose.dtd">
447  <html lang="$lang">  <html lang="$lang">
448  <head>  <head>
449      <title>@{[&escape($page.' '.&get_subjectline($page))]}</title>      <title>$escapedpage @{[&escape(&get_subjectline($page))]}</title>
450      <link rel="index" href="$url_cgi?$IndexPage">      <link rel="index" href="$url_cgi?$IndexPage">
451      <link rev="made" href="mailto:$modifier_mail">      <link rel="copyright" href="$url_cgi?$NAME_OF_WikiPageLicense">
452      <link rel="stylesheet" type="text/css" href="$url_stylesheet">      <link rev="made" href="mailto:@{[&escape($modifier_mail)]}">
453        <link rel="stylesheet" type="text/css" href="@{[&escape($url_stylesheet)]}">
454  </head>  </head>
455  <body class="$bodyclass">  <body class="$bodyclass">
456  EOD  EOD
# Line 534  sub unescape { Line 561  sub unescape {
561      return $s;      return $s;
562  }  }
563    
564  sub print_content {  sub print_content ($;$) {
565      my ($rawcontent) = @_;      my ($rawcontent, $format) = @_;
566      print &text_to_html($rawcontent, toc=>1);      print &text_to_html($rawcontent, toc=>1);
567  }  }
568    
# Line 549  sub text_to_html { Line 576  sub text_to_html {
576      push(@result, "<p>");      push(@result, "<p>");
577      foreach (@txt) {      foreach (@txt) {
578          chomp;          chomp;
579          # Walrus mod (6) start          if (/^\*\*\*\*\*([^\x0D\x0A]*)/) {
580          #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));  
581              push(@result, splice(@saved), qq(<h6 id="i$tocnum">) . &inline($1) . '</h6>');              push(@result, splice(@saved), qq(<h6 id="i$tocnum">) . &inline($1) . '</h6>');
582              $tocnum++;              $tocnum++;
583          } elsif (/^\*\*\*\*(.*)/) {          } elsif (/^\*\*\*\*([^\x0D\x0A]*)/) {
584              push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));              push(@toc, qq(---- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
585              push(@result, splice(@saved), qq(<h5 id="i$tocnum">) . &inline($1) . '</h5>');              push(@result, splice(@saved), qq(<h5 id="i$tocnum">) . &inline($1) . '</h5>');
586              $tocnum++;              $tocnum++;
587          } elsif (/^\*\*\*(.*)/) {          } elsif (/^\*\*\*([^\x0D\x0A]*)/) {
588              push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));              push(@toc, qq(--- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
589              push(@result, splice(@saved), qq(<h4 id="i$tocnum">) . &inline($1) . '</h4>');              push(@result, splice(@saved), qq(<h4 id="i$tocnum">) . &inline($1) . '</h4>');
590              $tocnum++;              $tocnum++;
591          } elsif (/^\*\*(.*)/) {          } elsif (/^\*\*([^\x0D\x0A]*)/) {
592          # if (/^\*\*(.*)/) {          # if (/^\*\*(.*)/) {
593          # Walrus mod (6) end          # Walrus mod (6) end
594              push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));              push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
595              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>');
596              $tocnum++;              $tocnum++;
597          } elsif (/^\*(.*)/) {          } elsif (/^\*([^\x0D\x0A]*)/) {
598              push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));              push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n));
599              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>');
600              $tocnum++;              $tocnum++;
601          #} elsif (/^----/) {          } elsif (/^(={1,6})(.*)/) {
         #    push(@result, splice(@saved), '<hr>');  
         } elsif (/^(={1,5})(.*)/) {  
602              &back_push('ol', length($1), \@saved, \@result);              &back_push('ol', length($1), \@saved, \@result);
603              push(@result, '<li>' . &inline($2) . '</li>');              push(@result, '<li>' . &inline($2) . '</li>');
604          } elsif (/^(-{1,5})(.*)/) {          } elsif (/^(-{1,6})(.*)/) {
605              &back_push('ul', length($1), \@saved, \@result);              &back_push('ul', length($1), \@saved, \@result);
606              push(@result, '<li>' . &inline($2) . '</li>');              push(@result, '<li>' . &inline($2) . '</li>');
607          } elsif (/^:([^:]+):(.*)/) {          } elsif (/^:([^:]+):(.*)/) {
# Line 600  sub text_to_html { Line 617  sub text_to_html {
617          } elsif (/^(\s+.*)$/) {          } elsif (/^(\s+.*)$/) {
618              &back_push('pre', 1, \@saved, \@result);              &back_push('pre', 1, \@saved, \@result);
619              #push(@result, &escape($1)); # Not &inline, but &escape              #push(@result, &escape($1)); # Not &inline, but &escape
620              push(@result, &inline($1)); # Not &inline, but &escape              push(@result, &inline($1));
621  #       } elsif (/^\,(.*)$/) {             # Walrus del (BF)  #       } elsif (/^\,(.*)$/) {             # Walrus del (BF)
622          } elsif (/^\,(.*?)[\x0D\x0A]*$/) { # Walrus add (BF)          } elsif (/^\,(.*?)[\x0D\x0A]*$/) { # Walrus add (BF)
623              &back_push('table', 1, \@saved, \@result, ' border="1"');              &back_push('table', 1, \@saved, \@result, ' border="1"');
# Line 625  sub text_to_html { Line 642  sub text_to_html {
642              push(@result, join('', '<tr>', @value, '</tr>'));              push(@result, join('', '<tr>', @value, '</tr>'));
643              # XXXXX              # XXXXX
644              #######              #######
645            } elsif (/^\[INS\[/) {
646                push(@result, "<ins>");
647            } elsif (/^\]INS\]/) {
648                push(@result, "</ins>");
649            } elsif (/^\[DEL\[/) {
650                push(@result, "<del>");
651            } elsif (/^\]DEL\]/) {
652                push(@result, "</del>");
653            } elsif (/^\[PRE\[/) {
654                push(@result, "<pre>");
655            } elsif (/^\]PRE\]/) {
656                push(@result, "</pre>");
657          } else {          } else {
658              push(@result, &inline($_));              push(@result, &inline($_));
659          }          }
# Line 636  sub text_to_html { Line 665  sub text_to_html {
665          # This part is taken from Makio Tsukamoto's WalWiki.          # This part is taken from Makio Tsukamoto's WalWiki.
666          my (@tocsaved, @tocresult);          my (@tocsaved, @tocresult);
667          foreach (@toc) {          foreach (@toc) {
668              if (/^(-{1,3})(.*)/) {              if (/^(-{1,6})(.*)$/) {
669                  &back_push('ul', length($1), \@tocsaved, \@tocresult);                  &back_push('ul', length($1), \@tocsaved, \@tocresult);
670                  push(@tocresult, '<li>' . $2 . '</li>');                  push(@tocresult, '<li>' . $2 . '</li>');
671              }              }
# Line 670  sub inline { Line 699  sub inline {
699      $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
700      $line =~ s!      $line =~ s!
701        (        (
702          (?:&lt;(?:mailto|http|https|ftp|urn):[\x21-\x7E]*)&gt;          (?:&lt;(?:mailto|http|https|ftp|urn|news):[\x21-\x7E]*)&gt;
703        |        |
704          ($bracket_name) # [[likethis]], [[#comment]], [[Friend:remotelink]]          ($bracket_name) # [[likethis]], [[#comment]], [[Friend:remotelink]]
705        |        |
# Line 694  sub make_link { Line 723  sub make_link {
723      } elsif ($chunk =~ /^mailto:(.*)$/) {      } elsif ($chunk =~ /^mailto:(.*)$/) {
724          $name = $1;          $name = $1;
725      }      }
726      if ($use_autoimg and $name =~ /^(http|https|ftp|):.+\.(png|gif|jpe?g)/) {      if ($use_autoimg and $name =~ /^(http|https|ftp):.+\.(png|gif|jpe?g)/) {
727          $name = qq(<img src="$name">) ;          $name = qq(<img src="$name">) ;
728      }      }
729      $name = &unarmor_name($name);      $name = &unarmor_name($name);
730      # Walrus add (3) end      # Walrus add (3) end
731      if ($chunk =~ /^(http|https|ftp):/) {      if ($chunk =~ /^(http|https|ftp|news):/) {
732          # Walrus mod (3) start          # Walrus mod (3) start
733  #       if ($use_autoimg and $chunk =~ /\.(gif|png|jpeg|jpg)$/) {  #       if ($use_autoimg and $chunk =~ /\.(gif|png|jpeg|jpg)$/) {
734  #           return qq(<a href="$chunk"><img src="$chunk"></a>);  #           return qq(<a href="$chunk"><img src="$chunk"></a>);
# Line 729  sub make_link { Line 758  sub make_link {
758  #               $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)
759                  $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)
760  #               return qq(<a href="$remoteurl">$chunk</a>); # Walrus del (3)  #               return qq(<a href="$remoteurl">$chunk</a>); # Walrus del (3)
761                  return qq(<a href="$remoteurl">$name</a>);  # Walrus add (3)                  return qq(<a href="$remoteurl">@{[&escape($name)]}</a>);  # Walrus add (3)
762              } else {              } else {
763  #               return $chunk;                              # Walrus del (3)  #               return $chunk;                              # Walrus del (3)
764                  return $name;                               # Walrus add (3)                  return &escape($name);                               # Walrus add (3)
765              }              }
766          } elsif ($database{$chunk}) {          } elsif ($database{$chunk}) {
767              my $subject = &escape(&get_subjectline($chunk, delimiter => ''));              my $subject = &escape(&get_subjectline($chunk, delimiter => ''));
768  #           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)
769              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)
770          } elsif ($page_command{$chunk}) {          } elsif ($page_command{$chunk}) {
771  #           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)
772              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)
773          } else {          } else {
774              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>);
775          }          }
776      }      }
777  }  }
778    
 # 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  
   
779  sub print_message {  sub print_message {
780      my ($msg) = @_;      my ($msg) = @_;
781      print qq(<p><strong>$msg</strong></p>);      print qq(<p><strong>$msg</strong></p>);
# Line 865  sub get_subjectline { Line 861  sub get_subjectline {
861    
862          # Get the subject of the page.          # Get the subject of the page.
863          my $subject = $database{$page};          my $subject = $database{$page};
864            $subject =~ s#^SuikaWiki/0.9[^\x0D\x0A]*[\x0D\x0A]+##s;
865          $subject =~ s/\r?\n.*//s;          $subject =~ s/\r?\n.*//s;
866          return "$delim$subject";          return "$delim$subject";
867      }      }
# Line 972  sub print_editform { Line 969  sub print_editform {
969          }          }
970          $mymsg = &escape($form{mymsg});          $mymsg = &escape($form{mymsg});
971      } else {      } else {
972          $mymsg = &escape($mymsg);          $mymsg = &escape($mymsg || $database{NewPageTemplate});
973      }      }
974    
975      my $edit = $mode{admin} ? 'adminedit' : 'edit';      my $edit = $mode{admin} ? 'adminedit' : 'edit';
976        my $escapedmypage = &escape($form{mypage});
977        my $escapedmypassword = &escape($form{mypassword});
978    
979      print <<"EOD";      print <<"EOD";
980  <form action="$url_cgi" method="post">  <form action="$url_cgi" method="post">
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="$escapedmypassword" 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="@{[&escape($form{mypage})]}">      <input type="hidden" name="mypage" value="$escapedmypage">
984      <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>
985  @{[  @{[
986      $mode{admin} ?      $mode{admin} ?
987      qq(      qq(
# Line 1044  sub is_editable { Line 1043  sub is_editable {
1043  #   not_wiki_name -> [[not_wiki_name]]  #   not_wiki_name -> [[not_wiki_name]]
1044  sub armor_name {  sub armor_name {
1045      my ($name) = @_;      my ($name) = @_;
1046      if ($name =~ /^$wiki_name$/) {      #if ($name =~ /^$wiki_name$/) {
1047          return $name;      #    return $name;
1048      } else {      #} else {
1049          return "[[$name]]";          return "[[$name]]";
1050      }      #}
1051  }  }
1052    
1053  # unarmor_name:  # unarmor_name:
# Line 1221  sub is_frozen { Line 1220  sub is_frozen {
1220  sub do_comment {  sub do_comment {
1221      my ($content) = $database{$form{mypage}};      my ($content) = $database{$form{mypage}};
1222      my $datestr = &get_now;      my $datestr = &get_now;
1223      my $namestr = $form{myname} ? " ''[[$form{myname}]]'' : " : " ";      my $namestr = " ''[[@{[$form{myname}||$DEFAULT_embed_comment_name]}]]'' : ";
1224      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/) {
1225          ;      #  ;
1226      } else {      #} else {
1227          $content =~ s/(\Q$embed_rcomment\E)/$1\n- $datestr$namestr$form{mymsg}/;      #  $content =~ s/(\Q$embed_rcomment\E)/$1\n- $datestr$namestr$form{mymsg}/;
1228        #}
1229        my $i = 0;  my $o = 0;
1230        $content =~ s{(\Q$embed_comment\E|\Q$embed_rcomment\E)}{
1231          my $embed = $1;
1232          if ($i == $form{comment_index}) {
1233            if ($embed eq $embed_comment) {
1234              $embed = "- $datestr$namestr$form{mymsg}\n$embed";  $o = 1;
1235            } else {
1236              $embed .= "\n- $datestr$namestr$form{mymsg}";  $o = 1;
1237            }
1238          }
1239          $i++; $embed;
1240        }ge;
1241        unless ($o) {
1242          $content .= "- $datestr$namestr$form{mymsg}\n";
1243      }      }
1244      if ($form{mymsg}) {      if ($form{mymsg}) {
1245          $form{mymsg} = $content;          $form{mymsg} = $content;
# Line 1237  sub do_comment { Line 1251  sub do_comment {
1251      }      }
1252  }  }
1253    
1254    my $_O_COMMENT_INDEX = 0;
1255  sub embedded_to_html {  sub embedded_to_html {
1256      my ($embedded) = @_;      my ($embedded) = @_;
1257      if ($embedded eq $embed_comment or $embedded eq $embed_rcomment) {      if ($embedded eq $embed_comment or $embedded eq $embed_rcomment) {
# Line 1247  sub embedded_to_html { Line 1262  sub embedded_to_html {
1262      <input type="hidden" name="mypage" value="$form{mypage}">      <input type="hidden" name="mypage" value="$form{mypage}">
1263      <input type="hidden" name="myLastModified" value="$lastmodified">      <input type="hidden" name="myLastModified" value="$lastmodified">
1264      <input type="hidden" name="mytouch" value="on">      <input type="hidden" name="mytouch" value="on">
1265      $resource{yourname}      <input type="hidden" name="comment_index" value="@{[$_O_COMMENT_INDEX++]}">
1266        $embed_comment_Name_Prompt
1267      <input type="text" name="myname" value="" size="10">      <input type="text" name="myname" value="" size="10">
1268      <input type="text" name="mymsg" value="" size="40">      <input type="text" name="mymsg" value="" size="60">
1269      <input type="submit" value="$resource{commentbutton}">      <input type="submit" value="$resource{commentbutton}">
1270  </form>  </form>
1271  EOD  EOD

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.26

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24