/[pub]/suikawiki/wikidata/suikawiki-config.ph
Suika

Diff of /suikawiki/wikidata/suikawiki-config.ph

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.12.4.5 by wakaba, Sat Mar 20 04:09:14 2004 UTC revision 1.18 by wakaba, Thu Jun 3 06:40:02 2004 UTC
# Line 20  This file is part of SuikaWiki. Line 20  This file is part of SuikaWiki.
20  package wiki::driver::http;  package wiki::driver::http;
21  use strict;  use strict;
22    
23      ## These lines should be removed after utf8 support
24      BEGIN {
25        $Message::Util::Formatter::Base::Token = qr/[\w._+\x80-\xFF-]+/;
26        require Message::Util::Formatter::Base;
27      }
28      use Message::Util::Error;
29    
30    use Message::Util::QName::General [q<ExpandedURI>], {
31      'log' => q<http://suika.fam.cx/~wakaba/-temp/2004/05/01/reqlog#>,
32      'media-type' => q<http://suika.fam.cx/~wakaba/-temp/2004/04/24/mt#>,
33      'ss' => q<http://suika.fam.cx/~wakaba/archive/2004/05/sw-stylesheet#>,
34    };
35    
36    BEGIN {
37      if ($main::ENV{REQUEST_URI} =~ /\#/) {
38        require SuikaWiki::Output::HTTP;
39        my $out = SuikaWiki::Output::HTTP->new;
40        $out->{status_code} = 401;
41        $out->{status_phrase} = q<Request-URI MUST NOT have Fragment Identifier>;
42        $out->{entity}->{media_type} = q<text/html>;
43        $out->{entity}->{charset} = q<iso-8859-1>;
44        $out->{entity}->{language} = [q<en>];
45        $out->{entity}->{body_is_octet_stream} = 1;
46        my $ua = $main::ENV{HTTP_USER_AGENT};
47        for ($ua) {
48          s/&/&amp;/g; s/</&lt;/g; s/([^\x20-\x7E])/sprintf '&#x%02X;', ord $1/ge;
49        };
50        $out->{entity}->{body} = qq<
51          <!DOCTYPE html SYSTEM>
52          <title>401 Bad Request-URI</title>
53          <h1>Bad Request-URI</h1>
54          <p>Your Request-URI has fragment identifier but it is not allowed here.
55          It might be a bug of your user agent ($ua).  Please contact to the UA
56          vendor.</p>
57        >;
58        $out->output (output => 'http-cgi');
59        exit;
60      }
61    }
62    
63  push our @Config, sub ($) {  push our @Config, sub ($) {
   eval { use Message::Util::Error };  
64    my $WIKI = shift;    my $WIKI = shift;
65    use Cwd qw(abs_path);    use FindBin q($Bin);
66      use File::Spec;
67        
68    ## -- Filesystem path mapping    ## -- Filesystem path mapping
69    for (    for (
70       [db__cache__dir          => q"./wikidata/lock/"],       [db__cache__dir          => q"./wikidata/cache/"],
71       [db__cache_struct__file  => q"./wikidata/lock/struct.db"],       [db__cache_struct__file  => q"./wikidata/cache/struct.db"],
72       [db__content__dir        => q"./wikidata/page/"],       [db__content__dir        => q"./wikidata/page/"],
73       [db__content__error_log  => q"./wikidata/log/db-content.log"],       [db__content__error_log  => q"./wikidata/log/db-content.log"],
74       [db__bdb__home_dir       => q"./wikidata/lock/"],       [db__bdb__home_dir       => q"./wikidata/lock/"],
# Line 38  push our @Config, sub ($) { Line 78  push our @Config, sub ($) {
78       [db__lock__dir           => q"./wikidata/lock/"],       [db__lock__dir           => q"./wikidata/lock/"],
79       [db__lock__log_file      => q"./wikidata/log/lock.log"],       [db__lock__log_file      => q"./wikidata/log/lock.log"],
80       [db__log__dir            => q"./wikidata/log/"],       [db__log__dir            => q"./wikidata/log/"],
81         [db__request_log__dir    => q"./wikidata/rlog/"],
82         [db__static__dir         => q"./wikidata/static/"],
83       [db__temp__dir           => q"./wikidata/lock/"],       [db__temp__dir           => q"./wikidata/lock/"],
84       [namazu__index_dir       => q"/var/namazu/index/wakaba"],       [namazu__index_dir       => q"/var/namazu/index/suikawiki"],
85    ) {    ) {
86      ## On system that does not set current directory as main script      ## On system that does not set current directory as main script
87      ## directory, you should specify it instead of using "abs_path".      ## directory, you should specify it instead of using "abs_path".
88      $WIKI->{config}->{path_to}->{$_->[0]} = abs_path $_->[1];      $WIKI->{config}->{path_to}->{$_->[0]} = File::Spec->rel2abs ($_->[1], $Bin);
89    }    }
90        
91    ## -- Namazu URI Mapping (See SuikaWiki:SuikaWiki//Namazu) --    ## -- Namazu URI Mapping (See SuikaWiki:SuikaWiki//Namazu) --
# Line 86  push our @Config, sub ($) { Line 128  push our @Config, sub ($) {
128                
129        ## Main content        ## Main content
130        $wiki->{db}->_set_prop_db (content => {-db_open => sub {        $wiki->{db}->_set_prop_db (content => {-db_open => sub {
131          require SuikaWiki::DB::FileSystem::YukiWikiDBNS;          require SuikaWiki::DB::FileSystem::LeafFile;
132          SuikaWiki::DB::FileSystem::YukiWikiDBNS->new          SuikaWiki::DB::FileSystem::LeafFile->new
133            (directory => $wiki->{config}->{path_to}->{db__content__dir},            (base_directory => $wiki->{config}->{path_to}->{db__content__dir},
134             logfile   => $wiki->{config}->{path_to}->{db__content__error_log},             directory_suffix => '.ns',
135             suffix    => '.txt',             file_suffix    => '.txt',
136               root_key => $wiki->{config}->{page}->{Default},
137               -lock => $wiki->{var}->{db}->{lock_prop}->('content_prop'));
138          }, -db_close => sub {
139            my %opt = @_;
140            $opt{prop_info}->{-db}->close;
141            delete $opt{prop_info}->{-db};
142          }});
143    
144          ## Properties
145          $wiki->{db}->_set_prop_db (content_prop => {-db_open => sub {
146            require SuikaWiki::DB::FileSystem::LeafProp;
147            SuikaWiki::DB::FileSystem::LeafProp->new
148              (base_directory => $wiki->{config}->{path_to}->{db__content__dir},
149               directory_suffix => '.ns',
150               file_suffix    => '.prop',
151               root_key => $wiki->{config}->{page}->{Default},
152             -lock => $wiki->{var}->{db}->{lock_prop}->('content'));             -lock => $wiki->{var}->{db}->{lock_prop}->('content'));
153        }, -db_close => sub {        }, -db_close => sub {
154          my %opt = @_;          my %opt = @_;
# Line 110  push our @Config, sub ($) { Line 168  push our @Config, sub ($) {
168          delete $opt{prop_info}->{-db};          delete $opt{prop_info}->{-db};
169        }});        }});
170                
171          ## Static version
172          $wiki->{db}->_set_prop_db (static__css => {-db_open => sub {
173            require SuikaWiki::DB::FileSystem::LeafFileP;
174            SuikaWiki::DB::FileSystem::LeafFileP->new
175              (base_directory => $wiki->{config}->{path_to}->{db__static__dir},
176               directory_suffix => '.ns',
177               file_suffix    => '.css',
178               root_key => $wiki->{config}->{page}->{Default});
179          }, -db_close => sub {
180            my %opt = @_;
181            $opt{prop_info}->{-db}->close;
182            delete $opt{prop_info}->{-db};
183          }});
184          $wiki->{config}->{ExpandedURI q<ss:use-static>} = 1;
185          ## URI maker for LeafFileP generated files
186          $wiki->{config}->{ExpandedURI q<ss:wikiname-to-uri>} = sub {
187            my (undef, %opt) = @_;
188            my $page = join '.ns/',
189                       map {s/([^0-9A-Za-z_-])/sprintf '+%02X', ord $1/ge;$_}
190                       @{$opt{wikiname}};
191            return URI->new ('wikidata/static/' . $page . '.css');
192          };
193          ## Reverse mapping of generate-uri
194          $wiki->{config}->{ExpandedURI q<ss:uri-to-wikiname>} = sub {
195            my (undef, %opt) = @_;
196            $opt{uri} =~ s!^.+/wikidata/static/!!g;
197            $opt{uri} =~ s/\?[^?]*$//g;
198            $opt{uri} =~ s/\.css$//g;
199            return $opt{wiki}->name
200              ([map {s/\+([0-9A-Fa-f_-][0-9A-Fa-f_-])/pack 'CC', hex $1/ge;$_}
201                split m!.ns/!, $opt{uri}]);
202          };
203    
204    
205        ## Cache DBs        ## Cache DBs
206        require SuikaWiki::DB::FileSystem::SuikaWikiCache09;        require SuikaWiki::DB::FileSystem::SuikaWikiCache09;
207        my $cachedb = SuikaWiki::DB::FileSystem::SuikaWikiCache09->new        my $cachedb = SuikaWiki::DB::FileSystem::SuikaWikiCache09->new
208              (directory => $wiki->{config}->{path_to}->{db__cache__dir},              (directory => $wiki->{config}->{path_to}->{db__cache__dir},
209               expires => 86400 * 3, removes => 86400 * 3); # 3 days               expires => 86400 * 3, removes => 86400 * 3); # 3 days
210        $wiki->{db}->_set_prop_db (m__search_result =>        $wiki->{db}->_set_prop_db (m__search_result =>
211          {-db => $cachedb, -prop => 'search_result', -db_close => sub {          {-db => $cachedb, -prop => 'search_result', -db_close => sub {
# Line 163  push our @Config, sub ($) { Line 255  push our @Config, sub ($) {
255                
256        ## Referer Database (See Referer plugin module)        ## Referer Database (See Referer plugin module)
257        $wiki->{db}->_set_prop_db (referer => {-db_open => sub {        $wiki->{db}->_set_prop_db (referer => {-db_open => sub {
258          require SuikaWiki::DB::Hash;          require SuikaWiki::DB::FileSystem::Count;
259          new SuikaWiki::DB::Hash constructor => sub {          SuikaWiki::DB::FileSystem::Count->new
260            tie my %db, 'BerkeleyDB::Hash',            (base_directory => $wiki->{config}->{path_to}->{db__content__dir},
261                          -Filename => 'referer.db',             directory_suffix => '.ns',
262                          -Env => $bdbenv,             file_suffix    => '.ref',
263                          -Flags => DB_CREATE,             root_key => $wiki->{config}->{page}->{Default},
264                          -Mode => 0644;             auto_mkdir => 0,
265            \%db;             -lock => $wiki->{var}->{db}->{lock_prop}->('referer'));
266         };        }, -db_close => sub {
267            my %opt = @_;
268            $opt{prop_info}->{-db}->close;
269            delete $opt{prop_info}->{-db};
270        }});        }});
271    
272        ## HTTP Request Logging Database (See RequestLog plugin module)        ## HTTP Request Logging Database (See RequestLog plugin module)
273        $wiki->{db}->_set_prop_db (log__http_request => {-db_open => sub {        $wiki->{db}->_set_prop_db (log__http_request => {-db_open => sub {
274          require SuikaWiki::DB::Hash;          require SuikaWiki::DB::FileSystem::Count;
275          new SuikaWiki::DB::Hash constructor => sub {          SuikaWiki::DB::FileSystem::Count->new
276            tie my %db, 'BerkeleyDB::Hash',            (base_directory => $wiki->{config}->{path_to}->{db__request_log__dir},
277                          -Filename => 'http-request-log.db',             directory_suffix => '.ns',
278                          -Env => $bdbenv,             file_suffix    => '.rlog',
279                          -Flags => DB_CREATE,             root_key => $wiki->{config}->{page}->{Default},
280                          -Mode => 0644;             auto_mkdir => 1);
281            \%db;        }, -db_close => sub {
282         };          my %opt = @_;
283            $opt{prop_info}->{-db}->close;
284            delete $opt{prop_info}->{-db};
285        }});        }});
286                
287        ## Additional WikiDB properties should be defined here        ## Additional WikiDB properties should be defined here
# Line 194  push our @Config, sub ($) { Line 291  push our @Config, sub ($) {
291    push @{$WIKI->{event}->{input_close}}, sub {    push @{$WIKI->{event}->{input_close}}, sub {
292      my ($wiki, $event) = @_;      my ($wiki, $event) = @_;
293      try {      try {
       SuikaWiki::Plugin->module_package ('Referer')  
                      ->add_referer (wiki => $wiki,  
                                     uri => $wiki->{input}->meta_variable  
                                              ('HTTP_REFERER'));  
     } catch SuikaWiki::Plugin::error with {  
       my $err = shift;  
       $err->raise unless $err->{-type} eq 'PLUGIN_NOT_FOUND';  
     };  
     try {  
294        SuikaWiki::Plugin->module_package ('RequestLog')        SuikaWiki::Plugin->module_package ('RequestLog')
295                       ->http_request_log (wiki => $wiki,                       ->http_request_log (wiki => $wiki,
296                                           prop => 'log__http_request');                                           prop => 'log__http_request');
# Line 212  push our @Config, sub ($) { Line 300  push our @Config, sub ($) {
300      };      };
301    };    };
302    
303      $WIKI->{config}->{engine_max_access} = 15;
304    
305    ## -- WikiName of special purpose WikiPages    ## -- WikiName of special purpose WikiPages
306    $WIKI->{config}->{page} = {    $WIKI->{config}->{page} = {
307      Default         => $WIKI->name ([qw/HomePage/]),      Default         => $WIKI->name ([qw/HomePage/]),
308      InterWikiName   => $WIKI->name ([qw/Wiki InterWikiName/]),      InterWikiName   => $WIKI->name ([qw/Wiki InterWikiName/]),
309      NewPageTemplate => $WIKI->name ([qw/Wiki NewPageTemplate/]),      NewPageTemplate => $WIKI->name ([qw/Wiki NewPageTemplate/]),
310      'StyleSheetList(text/html)' => $WIKI->name ([qw<Wiki Style List text/html>]),      'StyleSheetList(text/html)' => $WIKI->name ([qw<Wiki Style List text/html>]),
311        ExpandedURI q<log:root> => $WIKI->name ([]),
312    };    };
313        
314    ## -- WikiNamespace constants    ## -- WikiNamespace constants
# Line 226  push our @Config, sub ($) { Line 317  push our @Config, sub ($) {
317      separator_reg => qr#\s*//\s*#,      separator_reg => qr#\s*//\s*#,
318      self => '.',      self => '.',
319      parent => '..',      parent => '..',
320        root => '//',
321    };    };
322        
323    ## -- Default character codes    ## -- Default character codes
# Line 244  push our @Config, sub ($) { Line 336  push our @Config, sub ($) {
336      ## Fragment identifier in URI reference      ## Fragment identifier in URI reference
337        uri_fragment => 'x-punycode',     ## Reserved for possible future use        uri_fragment => 'x-punycode',     ## Reserved for possible future use
338    };    };
339    
340      ## -- User option for media types
341      $WIKI->{config}->{ExpandedURI q<media-type:accept-media-type>} = {
342        q<IMT:text/css##> => 1,
343        q<IMT:text/plain##> => 1,
344        q<IMT:text/x-suikawiki;version="0.9"##> => 1,
345        q<IMT:application/x.suikawiki.config;version="2.0"##> => 1,
346      };
347        
348    ## -- Expires duration templates    ## -- Expires duration templates
349    $WIKI->{config}->{entity}->{expires} = {    $WIKI->{config}->{entity}->{expires} = {
350      edit      => {delta => 60},      edit      => {delta => 60},
351      view      => {delta => 2*3600},      view      => {delta => 2*3600},
352        list      => {delta => 60},
353      lm_flaged => {delta => 30*24*3600},      lm_flaged => {delta => 30*24*3600},
354      stylesheet => {delta => 30*24*3600},      stylesheet => {delta => 30*24*3600},
355      error     => {delta => 60},      error     => {delta => 60},

Legend:
Removed from v.1.12.4.5  
changed lines
  Added in v.1.18

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24