/[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.16 by wakaba, Sun Jun 2 05:03:38 2002 UTC revision 1.24 by wakaba, Fri Aug 30 04:31:11 2002 UTC
# Line 56  require 'jcode.pl'; Line 56  require 'jcode.pl';
56  # use Jcode;  # use Jcode;
57  use Fcntl;  use Fcntl;
58  my $version = '2.0.beta1.2002-05-29';  my $version = '2.0.beta1.2002-05-29';
59    my $walversion;
60  ##############################  ##############################
61  #  #
62  # You MUST modify following '$modifier_...' variables.  # You MUST modify following '$modifier_...' variables.
# Line 68  my $modifier_name = 'ΟΒ';      # Your name, l Line 69  my $modifier_name = 'ΟΒ';      # Your name, l
69  my $modifier_dbtype = 'YukiWikiDB';     # Slow, available on all environment.  my $modifier_dbtype = 'YukiWikiDB';     # Slow, available on all environment.
70  # my $modifier_sendmail = '/usr/sbin/sendmail -t -n'; # Your sendmail.  # my $modifier_sendmail = '/usr/sbin/sendmail -t -n'; # Your sendmail.
71  my $modifier_sendmail = ''; # If you don't need mail notification.  my $modifier_sendmail = ''; # If you don't need mail notification.
72  my $modifier_dir_data = '../wiki'; # Your data directory.  my $modifier_dir_data = './wikidata'; # Your data directory.
73  my $modifier_rss_title = "WalWiki $walversion";  my $modifier_rss_title = "WalWiki $walversion";
74  my $modifier_rss_link = 'http://suika.fam.cx/~wakaba/-temp/wiki2/wiki'; # Blank is not allowed.  my $modifier_rss_link = 'http://suika.fam.cx/~wakaba/-temp/wiki2/wiki'; # Blank is not allowed.
75  my $modifier_rss_description = 'This is WalWiki, yet another Wiki clone based on YukiWiki';  my $modifier_rss_description = 'This is WalWiki, yet another Wiki clone based on YukiWiki';
# Line 82  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 = './WalWiki/Theme/wiki.css';  my $url_stylesheet = 'wiki-style.css';
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 103  my $InterWikiName = 'InterWikiName'; Line 104  my $InterWikiName = 'InterWikiName';
104  my $RecentChanges = 'RecentChanges';  my $RecentChanges = 'RecentChanges';
105  my $AdminChangePassword = 'AdminChangePassword';  my $AdminChangePassword = 'AdminChangePassword';
106  my $CompletedSuccessfully = 'CompletedSuccessfully';  my $CompletedSuccessfully = 'CompletedSuccessfully';
107  my $FrontPage = 'FrontPage';  my $FrontPage = 'HomePage';
108  my $IndexPage = 'IndexPage';  my $IndexPage = 'IndexPage';
109  my $SearchPage = 'SearchPage';  my $SearchPage = 'SearchPage';
110  my $CreatePage = 'CreatePage';  my $CreatePage = 'CreatePage';
# Line 116  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 138  my %fixedpage = ( Line 142  my %fixedpage = (
142      $SearchPage => 1,      $SearchPage => 1,
143      $AdminChangePassword => 1,      $AdminChangePassword => 1,
144      $CompletedSuccessfully => 1,      $CompletedSuccessfully => 1,
145      $FrontPage => 1,      #$FrontPage => 1,
146  );  );
147  my %form;  my %form;
148  my %database;  my %database;
# Line 153  my %page_command = ( Line 157  my %page_command = (
157      $CreatePage => 'create',      $CreatePage => 'create',
158      $RssPage => 'rss',      $RssPage => 'rss',
159      $AdminChangePassword => 'adminchangepasswordform',      $AdminChangePassword => 'adminchangepasswordform',
160      $FrontPage => 'FrontPage',      #$FrontPage => 'FrontPage',
161  );  );
162  my %command_do = (  my %command_do = (
163      read => \&do_read,      read => \&do_read,
# Line 199  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 265  sub do_index { Line 274  sub do_index {
274      print qq(<ul>);      print qq(<ul>);
275      foreach my $page (sort keys %database) {      foreach my $page (sort keys %database) {
276          if (&is_editable($page)) {          if (&is_editable($page)) {
277              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>);
278              # print qq(<li>@{[&get_info($page, $info_IsFrozen)]}</li>);              # print qq(<li>@{[&get_info($page, $info_IsFrozen)]}</li>);
279              # print qq(<li>@{[0 + &is_frozen($page)]}</li>);              # print qq(<li>@{[0 + &is_frozen($page)]}</li>);
280          }          }
# Line 307  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 331  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 scalar 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)]}">@{[&escape($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 385  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        my $escapedpage = &escape($page);
413      print <<"EOD";      print <<"EOD";
414  Content-type: text/html; charset=$charset  Content-type: text/html; charset=$charset
415    Content-Language: $lang
416    Content-Style-Type: text/css
417    
418  <!DOCTYPE html  <!DOCTYPE html
419      PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"      PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
420      "http://www.w3.org/TR/html4/loose.dtd">      "http://www.w3.org/TR/html4/loose.dtd">
421  <html lang="$lang">  <html lang="$lang">
422  <head>  <head>
423      <meta http-equiv="Content-Language" content="$lang">      <title>$escapedpage @{[&escape(&get_subjectline($page))]}</title>
     <meta http-equiv="Content-Type" content="text/html; charset=$charset">  
     <title>$page @{[&escape(&get_subjectline($page))]}</title>  
424      <link rel="index" href="$url_cgi?$IndexPage">      <link rel="index" href="$url_cgi?$IndexPage">
425      <link rev="made" href="mailto:$modifier_mail">      <link rev="made" href="mailto:@{[&escape($modifier_mail)]}">
426      <link rel="stylesheet" type="text/css" href="$url_stylesheet">      <link rel="stylesheet" type="text/css" href="@{[&escape($url_stylesheet)]}">
427  </head>  </head>
428  <body class="$bodyclass">  <body class="$bodyclass">
429    EOD
430      &print_navigate_links ($page);
431      print <<EOD;
432    <h1 class="header"><a
433        title="$resource{searchthispage}"
434        href="$url_cgi?mycmd=search;mymsg=$cookedpage">@{[&escape($page)]}</a>@{[&escape(&get_subjectline($page))]}</h1>
435    EOD
436    }
437    
438    sub print_navigate_links (@) {
439      my ($page) = @_;
440        my $editable = 0;
441        my $admineditable = 0;
442        if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) {
443            $editable = 0;
444            $admineditable = 1;
445        } elsif (&is_editable($page) and $form{mycmd} =~ /^(read|write)$/) {
446            $admineditable = 1;
447            $editable = 1;
448        } else {
449            $editable = 0;
450        }
451        my $cookedpage = &encode($page);
452      print <<EOH;
453  <div class="tools">  <div class="tools">
454      @{[ $admineditable      @{[ $admineditable
455          ? 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> | )
456          : qq()          : qq()
457      ]}      ]}
458      @{[ $editable      @{[ $editable
459          ? 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> | )
460          : qq()          : qq()
461      ]}      ]}
462      @{[ $admineditable      @{[ $admineditable
# Line 436  Content-type: text/html; charset=$charse Line 470  Content-type: text/html; charset=$charse
470      <a href="$url_cgi?$SearchPage">$resource{searchbutton}</a> |      <a href="$url_cgi?$SearchPage">$resource{searchbutton}</a> |
471      <a href="$url_cgi?$RecentChanges">$resource{recentchangesbutton}</a>      <a href="$url_cgi?$RecentChanges">$resource{recentchangesbutton}</a>
472  </div>  </div>
473  <h1 class="header"><a  EOH
     title="$resource{searchthispage}"  
     href="$url_cgi?mycmd=search;mymsg=$cookedpage">$page</a>@{[&escape(&get_subjectline($page))]}</h1>  
 EOD  
474  }  }
475    
476  sub print_footer {  sub print_footer {
477      my ($page) = @_;      my ($page) = @_;
478      $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)
479      # Walrus mod (1) start      # Walrus mod (1) start
480      my $mod_info = $modifier_name ? qq(Modified by <a href="$modifier_url">$modifier_name</a>.) : '';    my $cvslog = '$Revision$ $Date$';
481      print <<"EOD";    print_navigate_links ($page);
482      print <<"EOD";
483  <div class="footer">  <div class="footer">
 <hr />  
484  <p>  <p>
485  <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 />
486  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 />
487  $mod_info  <a href="/gate/cvs/wakaba/wiki/" title="CVS Repository">
488    $cvslog
489    </a>
490  </p>  </p>
491    <div class="navigation">
492    [<a href="/" title="€³€Ξ₯΅‘Ό₯Π‘Ό€ΞΌσΚΗ">/</a>
493    <a href="/map" title="€³€Ξ₯΅‘Ό₯Π‘Ό€Ξ°ΖΖβ">ΓΟΏή</a>
494    <a href="/search/" title="€³€Ξ₯΅‘Ό₯Π‘Ό€ΞΈ‘Ίχ">Έ‘Ίχ</a>]
495    </div>
496  </div>  </div>
497  $walrus_log <!-- Walrus add (debug) -->  $walrus_log
498  </body>  </body>
499  </html>  </html>
500  EOD  EOD
# Line 479  EOD Line 517  EOD
517  sub escape {  sub escape {
518      my $s = shift;      my $s = shift;
519      $s =~ s|\r\n|\n|g;      $s =~ s|\r\n|\n|g;
520      $s =~ s|\&|&amp;|g;      $s =~ s|&|&amp;|g;
521      $s =~ s|<|&lt;|g;      $s =~ s|<|&lt;|g;
522      $s =~ s|>|&gt;|g;      $s =~ s|>|&gt;|g;
523      $s =~ s|"|&quot;|g;      $s =~ s|"|&quot;|g;
# Line 489  sub escape { Line 527  sub escape {
527  sub unescape {  sub unescape {
528      my $s = shift;      my $s = shift;
529      # $s =~ s|\n|\r\n|g;      # $s =~ s|\n|\r\n|g;
530      $s =~ s|\&amp;|\&|g;      $s =~ s|&lt;|<|g;
531      $s =~ s|\&lt;|\<|g;      $s =~ s|&gt;|>|g;
532      $s =~ s|\&gt;|\>|g;      $s =~ s|&quot;|"|g;
533      $s =~ s|\&quot;|\"|g;      $s =~ s|&amp;|&|g;
534      return $s;      return $s;
535  }  }
536    
# Line 511  sub text_to_html { Line 549  sub text_to_html {
549      push(@result, "<p>");      push(@result, "<p>");
550      foreach (@txt) {      foreach (@txt) {
551          chomp;          chomp;
552          # Walrus mod (6) start          if (/^\*\*\*\*\*(.*)/) {
553          if ($saved[0] eq '</html>') {              push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));
554              if (/<\/html>/i) { splice(@saved); }              push(@result, splice(@saved), qq(<h6 id="i$tocnum">) . &inline($1) . '</h6>');
555              else { push (@result, &html_to_ignored_html($_)); }              $tocnum++;
556          } elsif (/^<html>/i and &is_ignore_html($form{mypage})) {          } elsif (/^\*\*\*\*(.*)/) {
557              push(@result, splice(@saved));              push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));
558              push(@saved, '</html>');              push(@result, splice(@saved), qq(<h5 id="i$tocnum">) . &inline($1) . '</h5>');
559                $tocnum++;
560            } elsif (/^\*\*\*(.*)/) {
561                push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));
562                push(@result, splice(@saved), qq(<h4 id="i$tocnum">) . &inline($1) . '</h4>');
563                $tocnum++;
564          } elsif (/^\*\*(.*)/) {          } elsif (/^\*\*(.*)/) {
565          # if (/^\*\*(.*)/) {          # if (/^\*\*(.*)/) {
566          # Walrus mod (6) end          # Walrus mod (6) end
# Line 528  sub text_to_html { Line 571  sub text_to_html {
571              push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));              push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)]}</a>\n));
572              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>');
573              $tocnum++;              $tocnum++;
574          } elsif (/^----/) {          #} elsif (/^----/) {
575              push(@result, splice(@saved), '<hr>');          #    push(@result, splice(@saved), '<hr>');
576          } elsif (/^(-{1,3})(.*)/) {          } elsif (/^(={1,5})(.*)/) {
577                &back_push('ol', length($1), \@saved, \@result);
578                push(@result, '<li>' . &inline($2) . '</li>');
579            } elsif (/^(-{1,5})(.*)/) {
580              &back_push('ul', length($1), \@saved, \@result);              &back_push('ul', length($1), \@saved, \@result);
581              push(@result, '<li>' . &inline($2) . '</li>');              push(@result, '<li>' . &inline($2) . '</li>');
582          } elsif (/^:([^:]+):(.*)/) {          } elsif (/^:([^:]+):(.*)/) {
583              &back_push('dl', 1, \@saved, \@result);              &back_push('dl', 1, \@saved, \@result);
584              push(@result, '<dt>' . &inline($1) . '</dt>', '<dd>' . &inline($2) . '</dd>');              push(@result, '<dt>' . &inline($1) . '</dt>', '<dd>' . &inline($2) . '</dd>');
585          } elsif (/^(>{1,3})(.*)/) {          } elsif (/^(>{1,5})(.*)/) {
586              &back_push('blockquote', length($1), \@saved, \@result);              &back_push('blockquote', length($1), \@saved, \@result);
587              push(@result, &inline($2));              push(@result, &inline($2));
588          } elsif (/^\s*$/) {          } elsif (/^\s*$/) {
# Line 545  sub text_to_html { Line 591  sub text_to_html {
591              push(@result, "<p>");              push(@result, "<p>");
592          } elsif (/^(\s+.*)$/) {          } elsif (/^(\s+.*)$/) {
593              &back_push('pre', 1, \@saved, \@result);              &back_push('pre', 1, \@saved, \@result);
594              push(@result, &escape($1)); # Not &inline, but &escape              #push(@result, &escape($1)); # Not &inline, but &escape
595                push(@result, &inline($1)); # Not &inline, but &escape
596  #       } elsif (/^\,(.*)$/) {             # Walrus del (BF)  #       } elsif (/^\,(.*)$/) {             # Walrus del (BF)
597          } elsif (/^\,(.*?)[\x0D\x0A]*$/) { # Walrus add (BF)          } elsif (/^\,(.*?)[\x0D\x0A]*$/) { # Walrus add (BF)
598              &back_push('table', 1, \@saved, \@result, ' border="1"');              &back_push('table', 1, \@saved, \@result, ' border="1"');
# Line 610  sub back_push { Line 657  sub back_push {
657  sub inline {  sub inline {
658      my ($line) = @_;      my ($line) = @_;
659      $line = &escape($line);      $line = &escape($line);
660      $line =~ s|'''([^']+?)'''|<i>$1</i>|g;  # Italic      $line =~ s|'''([^']+?)'''|<strong>$1</strong>|g;
661      $line =~ s|''([^']+?)''|<b>$1</b>|g;    # Bold      $line =~ s|''([^']+?)''|<em>$1</em>|g;
662      $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
663      $line =~ s!      $line =~ s!
664                  (        (
665                      ((mailto|http|https|ftp):([^\x00-\x20()<>\x7F-\xFF])*)  # Direct http://...          (?:&lt;(?:mailto|http|https|ftp|urn):[\x21-\x7E]*)&gt;
666                          |        |
667                      ($bracket_name)             # [[likethis]], [[#comment]], [[Friend:remotelink]]          ($bracket_name) # [[likethis]], [[#comment]], [[Friend:remotelink]]
668                          |        |
669                      ($interwiki_definition)     # [[Friend http://somewhere/?q=sjis($1)]]          ($interwiki_definition) # [[Friend http://somewhere/?q=sjis($1)]]
670                          |        #|
671                      ($wiki_name)                # LocalLinkLikeThis        #  ($wiki_name)
672                  )        )
673              !              !
674                  &make_link($1)                  &make_link($1)
675              !gex;              !gex;
# Line 632  sub inline { Line 679  sub inline {
679  sub make_link {  sub make_link {
680      my $chunk = shift;      my $chunk = shift;
681      # Walrus add (3) start      # Walrus add (3) start
682        $chunk =~ s/^&lt;(.*)&gt;$/$1/;
683      my $name  = $chunk;      my $name  = $chunk;
684      if ($chunk =~ /^\[\[([^ ]+?) ([^ ]+?)\]\]$/ and $form{mypage} ne $InterWikiName) {      if ($chunk =~ /^\[\[([^ ]+?) ([^ ]+?)\]\]$/ and $form{mypage} ne $InterWikiName) {
685          ($name, $chunk) = ($1, $2);          ($name, $chunk) = ($1, $2);
# Line 650  sub make_link { Line 698  sub make_link {
698  #       } else {  #       } else {
699  #           return qq(<a href="$chunk">$chunk</a>);  #           return qq(<a href="$chunk">$chunk</a>);
700  #       }  #       }
701          return qq(<a href="$chunk">$name</a>);          return qq(&lt;<a href="$chunk">$name</a>&gt;);
702          # Walrus mod (3) end          # Walrus mod (3) end
703      } elsif ($chunk =~ /^(mailto):(.*)/) {      } elsif ($chunk =~ m#^urn:[0-9A-Za-z_:;/.-]+#) {
704            return qq|&lt;<a href="/uri-res/N2L?${name}">$name</a>&gt;|;
705        } elsif ($chunk =~ /^mailto:(.*)/) {
706  #       return qq(<a href="$chunk">$2</a>);                 # Walrus del (3)  #       return qq(<a href="$chunk">$2</a>);                 # Walrus del (3)
707          return qq(<a href="$chunk">$name</a>);              # Walrus add (3)          return qq(&lt;<a href="$chunk">$name</a>&gt;);              # Walrus add (3)
708      } elsif ($chunk =~ /^$interwiki_definition$/) {      } elsif ($chunk =~ /^$interwiki_definition$/) {
709  #       return qq(<span class="InterWiki">$chunk</span>);   # Walrus del (3)  #       return qq(<span class="InterWiki">$chunk</span>);   # Walrus del (3)
710          return qq(<span class="InterWiki">$name</span>);    # Walrus add (3)          return qq(<span class="InterWiki">$name</span>);    # Walrus add (3)
# Line 671  sub make_link { Line 721  sub make_link {
721  #               $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)
722                  $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)
723  #               return qq(<a href="$remoteurl">$chunk</a>); # Walrus del (3)  #               return qq(<a href="$remoteurl">$chunk</a>); # Walrus del (3)
724                  return qq(<a href="$remoteurl">$name</a>);  # Walrus add (3)                  return qq(<a href="$remoteurl">@{[&escape($name)]}</a>);  # Walrus add (3)
725              } else {              } else {
726  #               return $chunk;                              # Walrus del (3)  #               return $chunk;                              # Walrus del (3)
727                  return $name;                               # Walrus add (3)                  return &escape($name);                               # Walrus add (3)
728              }              }
729          } elsif ($database{$chunk}) {          } elsif ($database{$chunk}) {
730              my $subject = &escape(&get_subjectline($chunk, delimiter => ''));              my $subject = &escape(&get_subjectline($chunk, delimiter => ''));
731  #           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)
732              return qq(<a title="$subject" href="$url_cgi?$cookedchunk">$name</a>);   # Walrus add (3)              return qq(<a title="$subject" href="$url_cgi?$cookedchunk">@{[&escape($name)]}</a>);   # Walrus add (3)
733          } elsif ($page_command{$chunk}) {          } elsif ($page_command{$chunk}) {
734  #           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)
735              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">@{[&escape($name)]}</a>);     # Walrus add (3)
736          } else {          } else {
737  #           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">@{[&escape($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)  
738          }          }
739      }      }
740  }  }
741    
 # 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  
   
742  sub print_message {  sub print_message {
743      my ($msg) = @_;      my ($msg) = @_;
744      print qq(<p><strong>$msg</strong></p>);      print qq(<p><strong>$msg</strong></p>);
745  }  }
746    
747    sub get_message {
748        my ($msg) = @_;
749        qq(<p><strong>$msg</strong></p>);
750    }
751    
752  sub init_form {  sub init_form {
753      if (param()) {      if (param()) {
754          foreach my $var (param()) {          foreach my $var (param()) {
# Line 914  sub print_editform { Line 935  sub print_editform {
935      }      }
936    
937      my $edit = $mode{admin} ? 'adminedit' : 'edit';      my $edit = $mode{admin} ? 'adminedit' : 'edit';
938        my $escapedmypage = &escape($form{mypage});
939        my $escapedmypassword = &escape($form{mypassword});
940    
941      print <<"EOD";      print <<"EOD";
942  <form action="$url_cgi" method="post">  <form action="$url_cgi" method="post">
943      @{[ $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>) : "" ]}
944      <input type="hidden" name="myLastModified" value="$lastmodified">      <input type="hidden" name="myLastModified" value="$lastmodified">
945      <input type="hidden" name="mypage" value="$form{mypage}">      <input type="hidden" name="mypage" value="$escapedmypage">
946      <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>
947  @{[  @{[
948      $mode{admin} ?      $mode{admin} ?
949      qq(      qq(
# Line 933  sub print_editform { Line 956  sub print_editform {
956      qq(      qq(
957          <input type="checkbox" name="mytouch" value="on" checked="checked">$resource{touch}<br>          <input type="checkbox" name="mytouch" value="on" checked="checked">$resource{touch}<br>
958          <input type="submit" name="mypreview_$edit" value="$resource{previewbutton}">          <input type="submit" name="mypreview_$edit" value="$resource{previewbutton}">
959          <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>
960      )      )
961  ]}  ]}
962  </form>  </form>
# Line 1191  sub embedded_to_html { Line 1214  sub embedded_to_html {
1214      <input type="submit" value="$resource{commentbutton}">      <input type="submit" value="$resource{commentbutton}">
1215  </form>  </form>
1216  EOD  EOD
1217      } elsif ($embedded =~ /$embed_command{searched}/) {
1218        return get_search_result ($1);
1219      # Walrus add (5) start      # Walrus add (5) start
1220      } elsif ($embedded =~ /$embed_interwiki/ and my $remoteurl = $interwiki{$2}) {      } elsif ($embedded =~ /$embed_interwiki/ and my $remoteurl = $interwiki{$2}) {
1221          $_ = &make_interwiki_box($1, $2);          $_ = &make_interwiki_box($1, $2);

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24