/[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.34 by wakaba, Wed Dec 4 12:00:42 2002 UTC revision 1.35 by wakaba, Thu Dec 5 04:32:27 2002 UTC
# Line 50  my $modifier_rss_description = 'This is Line 50  my $modifier_rss_description = 'This is
50  #  #
51  # You MAY modify following variables.  # You MAY modify following variables.
52  #  #
53    $SuikaWiki::Plugin::plugin_directory = q(./SuikaWiki/Plugin/);
54  my $file_touch = "$modifier_dir_data/touched.txt";  my $file_touch = "$modifier_dir_data/touched.txt";
55  my $file_resource = "$modifier_dir_data/resource.txt";  my $file_resource = "$modifier_dir_data/resource.txt";
56  my $file_FrontPage = "$modifier_dir_data/frontpage.txt";  my $file_FrontPage = "$modifier_dir_data/frontpage.txt";
# Line 118  my %fixedpage = ( Line 119  my %fixedpage = (
119      $CompletedSuccessfully => 1,      $CompletedSuccessfully => 1,
120      #$FrontPage => 1,      #$FrontPage => 1,
121      WikiUserAgentList => 1,      WikiUserAgentList => 1,
122        WikiPluginInfo    => 1,
123  );  );
124  my %form;  my %form;
125  my %database;  my %database;
# Line 133  my %page_command = ( Line 135  my %page_command = (
135      $RssPage => 'rss',      $RssPage => 'rss',
136      $AdminChangePassword => 'adminchangepasswordform',      $AdminChangePassword => 'adminchangepasswordform',
137      #$FrontPage => 'FrontPage',      #$FrontPage => 'FrontPage',
138        WikiPluginInfo       => 'x_WikiPluginInfo',
139  );  );
140  my %command_do = (  my %command_do = (
141      read => \&do_read,      read => \&do_read,
# Line 154  my %command_do = ( Line 157  my %command_do = (
157      diff => \&do_diff,      diff => \&do_diff,
158      interwikibox => \&do_interwiki_box, # Walrus add (5)      interwikibox => \&do_interwiki_box, # Walrus add (5)
159      wikiform => \&do_wikiform,      wikiform => \&do_wikiform,
160        x_WikiPluginInfo  => \&do_wikiplugininfo,
161  );  );
162  ##############################  ##############################
163  my $walversion = '2.0.beta1.wal.1';          # Walrus add (1)  my $walversion = '2.0.beta1.wal.1';          # Walrus add (1)
164  ##############################  ##############################
165  # &test_convert;  # &test_convert;
166  my $UA = '';  ## User agent name  my $UA = '';  ## User agent name
 &main;  
 exit(0);  
167  ##############################  ##############################
168    
169  sub main {  sub main {
# Line 848  sub make_urilink ($;%) { Line 850  sub make_urilink ($;%) {
850  }  }
851    
852  my $FormIndex = 0;  my $FormIndex = 0;
853  sub make_custom_form ($$$) {  sub make_custom_form ($$$$) {
854      my ($wfname, $definition, $template, $option) = @_;      my ($wfname, $definition, $template, $option) = @_;
855      ## $template and $option is currently not used in this procedure.      ## $template and $option is currently not used in this procedure.
856      unless ($main::_EMBEDED) {      unless ($main::_EMBEDED) {
# Line 856  sub make_custom_form ($$$) { Line 858  sub make_custom_form ($$$) {
858          if (length $definition) {          if (length $definition) {
859              my $param = bless {}, 'SuikaWiki::Plugin';              my $param = bless {}, 'SuikaWiki::Plugin';
860              my $lastmodified = &get_info($form{mypage}, $info_LastModified);              my $lastmodified = &get_info($form{mypage}, $info_LastModified);
861                &load_formatter (qw/form_input form_option/);
862                $definition = &unescape ($definition);
863              $definition =~ s/\\(.)/$1/g;              $definition =~ s/\\(.)/$1/g;
864              $definition .= ' %submit;' if $definition !~ /%submit/;              $definition .= ' %submit;' if $definition !~ /%submit/;
             unless ($fmt{form_option}) {  
                 $fmt{form_option} = Message::Util::Formatter->new;  
                 for (@{$SuikaWiki::Plugin::List{wikiform_option}||[]}) {  
                     $_->load_formatter ($fmt{form_option}, type => 'wikiform_option');  
                 }  
             }  
865              $option = &unescape ($option);              $option = &unescape ($option);
866              $option =~ s/\\(.)/$1/g;              $option =~ s/\\(.)/$1/g;
867              $fmt{form_option}->replace ($option, $param);              $fmt{form_option}->replace ($option, $param);
868                my $target_page = $param->{output}->{page} || $form{mypage};
869                $param->{form_disabled} = 1 if $fixedpage{$target_page};
870              my $target_form = $param->{output}->{id};              my $target_form = $param->{output}->{id};
871              my $r = <<EOH;              my $r = <<EOH;
872  <form method="post" action="$url_cgi" id="wikiform-$FormIndex" class="wikiform">  <form method="post" action="$url_cgi" id="wikiform-$FormIndex" class="wikiform">
873    <input type="hidden" name="mycmd" value="wikiform">    <input type="hidden" name="mycmd" value="@{[$param->{form_disabled}?'read':'wikiform']}">
874    <input type="hidden" name="mypage" value="@{[&escape($form{mypage})]}">    <input type="hidden" name="mypage" value="@{[&escape($target_page)]}">
875    <input type="hidden" name="myLastModified" value="$lastmodified">    <input type="hidden" name="myLastModified" value="$lastmodified">
876    <input type="hidden" name="mytouch" value="on">    <input type="hidden" name="mytouch" value="on">
877    <input type="hidden" name="@{[$target_form? qq(wikiform_targetform" value="@{[&escape($target_form)]}) : qq(wikiform_index" value="$FormIndex)]}">    <input type="hidden" name="@{[$target_form? qq(wikiform_targetform" value="@{[&escape($target_form)]}) : qq(wikiform_index" value="$FormIndex)]}">
878  EOH  EOH
879              $r .= qq(<a name="wikiform-$FormIndex"></a>) if $UA =~ m#Mozilla/[12]\.#;              $r .= qq(<a name="wikiform-$FormIndex"></a>) if $UA =~ m#Mozilla/[12]\.#;
880              $r .= $fmt{form_input}->replace (&unescape ($definition), $param);              $r .= $fmt{form_input}->replace ($definition, $param);
881              $r .= <<EOH;              $r .= <<EOH;
882  </form>  </form>
883  EOH  EOH
# Line 1285  sub init_InterWikiName { Line 1285  sub init_InterWikiName {
1285      $s = qq([[$s]]) if $s !~ /^[A-Z][a-z]+(?:[A-Z][a-z]+)+$/;      $s = qq([[$s]]) if $s !~ /^[A-Z][a-z]+(?:[A-Z][a-z]+)+$/;
1286      &encode (&code_convert (\$p->{name}, $o->{charset} || 'shift_jis'));      &encode (&code_convert (\$p->{name}, $o->{charset} || 'shift_jis'));
1287    };    };
   
   $fmt{form_input} = Message::Util::Formatter->new;  
   for (@{$SuikaWiki::Plugin::List{wikiform_input}||[]}) {  
     $_->load_formatter ($fmt{form_input}, type => 'wikiform_input');  
   }  
1288  }  }
1289    
1290    
# Line 1455  EOD Line 1450  EOD
1450    }    }
1451  }  }
1452    
1453  sub do_wikiform {  sub load_formatter (@) {
1454      my $content = $database{$form{mypage}};      for my $t (@_) {
     my $anchor = &get_new_anchor_index ($content);  
     for my $t (qw/form_template form_option/) {  
1455          unless ($fmt{$t}) {          unless ($fmt{$t}) {
1456              $fmt{$t} = Message::Util::Formatter->new;              $fmt{$t} = Message::Util::Formatter->new;
1457              for (@{$SuikaWiki::Plugin::List{'wiki'.$t}||[]}) {              for (@{$SuikaWiki::Plugin::List{'wiki'.$t}||[]}) {
# Line 1466  sub do_wikiform { Line 1459  sub do_wikiform {
1459              }              }
1460          }          }
1461      }      }
1462    }
1463    
1464    sub do_wikiform {
1465        my $content = $database{$form{mypage}};
1466        my $anchor = &get_new_anchor_index ($content);
1467        &load_formatter (qw/form_template form_option/);
1468      my $write = 0;      my $write = 0;
1469      my $i = 1;      my $i = 1;
1470      $content =~ s{$embed_command{form}}{      $content =~ s{$embed_command{form}}{
# Line 1705  sub is_exist_page { Line 1704  sub is_exist_page {
1704  sub __get_database ($) { $database{ $_[0] } }  sub __get_database ($) { $database{ $_[0] } }
1705  sub __set_database ($$) { $database{ $_[0] } = $_[1] }  sub __set_database ($$) { $database{ $_[0] } = $_[1] }
1706    
1707    sub do_wikiplugininfo {
1708        &print_header (q(WikiPluginInfo));
1709        print text_to_html (&SuikaWiki::Plugin::make_info_page);
1710        &print_footer (q(WikiPluginInfo));
1711    }
1712    
1713  package wiki::referer;  package wiki::referer;
1714  sub add ($$) {  sub add ($$) {
1715    my $page = shift;    my $page = shift;
# Line 1808  sub add ($) { Line 1813  sub add ($) {
1813  }  }
1814    
1815  package SuikaWiki::Plugin;  package SuikaWiki::Plugin;
1816      our $plugin_directory;  # defined in top of this file.
1817    our %List;    our %List;
1818    
1819  sub escape ($$) { main::escape ($_[1]) }  sub escape ($$) { main::escape ($_[1]) }
# Line 1823  sub regist ($@) { Line 1829  sub regist ($@) {
1829      }      }
1830  }  }
1831    
1832  use SuikaWiki::Plugin::WikiFormBasic;  sub import_plugins () {
1833        opendir PDIR, $plugin_directory;
1834        my @plugin = grep {s/\.pm$//} readdir (PDIR);
1835        closedir PDIR;
1836        for (@plugin) {
1837            eval qq{ use SuikaWiki::Plugin::$_ } unless /[^A-Za-z0-9_]/;
1838            push @{$List{_all}}, qq(SuikaWiki::Plugin::$_);
1839        }
1840    }
1841    
1842    sub make_info_page () {
1843        my $r = <<EOH;
1844    EOH
1845        unless ($List{_all}) {
1846            $r .= qq('''No plugin is installed!'''\n);
1847        } else {
1848            my $index = 0;
1849            for my $package (sort @{$List{_all}}) {
1850                $index++;
1851                my $prop = $package->property ();
1852                $r .= <<EOH;
1853    *$package
1854    
1855    [$index] '''$prop->{name}''' (Version $prop->{version})
1856    <$prop->{uri}>
1857    
1858    Provide:
1859    @{[do{my $t = ''; for my $f (@{$prop->{provide}||[]}) {
1860        $t .= qq(-''$f''\n);
1861        for (sort grep m#^\Q$f\E/#, keys %{$prop->{partinfo}}) {
1862             $t .= qq(--''$_'' -- $prop->{partinfo}->{$_}\n);
1863        }
1864    }$t}]}
1865    
1866    EOH
1867            }
1868        }
1869        $r;
1870    }
1871    
1872    &import_plugins ();
1873    
1874    package main;
1875    &main;
1876    exit 0;
1877    
1878  1;  1;
1879  __END__  __END__

Legend:
Removed from v.1.34  
changed lines
  Added in v.1.35

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24