/[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.4 by wakaba, Sat Mar 13 13:16:59 2004 UTC revision 1.16 by wakaba, Sat May 1 03:55:28 2004 UTC
# Line 25  use strict; Line 25  use strict;
25      $Message::Util::Formatter::Base::Token = qr/[\w._+\x80-\xFF-]+/;      $Message::Util::Formatter::Base::Token = qr/[\w._+\x80-\xFF-]+/;
26      require Message::Util::Formatter::Base;      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    };
34    
35    BEGIN {
36      if ($main::ENV{REQUEST_URI} =~ /\#/) {
37        require SuikaWiki::Output::HTTP;
38        my $out = SuikaWiki::Output::HTTP->new;
39        $out->{status_code} = 401;
40        $out->{status_phrase} = q<Request-URI MUST NOT have Fragment Identifier>;
41        $out->{entity}->{media_type} = q<text/html>;
42        $out->{entity}->{charset} = q<iso-8859-1>;
43        $out->{entity}->{language} = [q<en>];
44        $out->{entity}->{body_is_octet_stream} = 1;
45        my $ua = $main::ENV{HTTP_USER_AGENT};
46        for ($ua) {
47          s/&/&amp;/g; s/</&lt;/g; s/([^\x20-\x7E])/sprintf '&#x%02X;', ord $1/ge;
48        };
49        $out->{entity}->{body} = qq<
50          <!DOCTYPE html SYSTEM>
51          <title>401 Bad Request-URI</title>
52          <h1>Bad Request-URI</h1>
53          <p>Your Request-URI has fragment identifier but it is not allowed here.
54          It might be a bug of your user agent ($ua).  Please contact to the UA
55          vendor.</p>
56        >;
57        $out->output (output => 'http-cgi');
58        exit;
59      }
60    }
61    
 use Message::Util::Error;  
62  push our @Config, sub ($) {  push our @Config, sub ($) {
63    my $WIKI = shift;    my $WIKI = shift;
64    use Cwd qw(abs_path);    use FindBin q($Bin);
65      use File::Spec;
66        
67    ## -- Filesystem path mapping    ## -- Filesystem path mapping
68    for (    for (
69       [db__cache__dir          => q"./wikidata/lock/"],       [db__cache__dir          => q"./wikidata/cache/"],
70       [db__cache_struct__file  => q"./wikidata/lock/struct.db"],       [db__cache_struct__file  => q"./wikidata/cache/struct.db"],
71       [db__content__dir        => q"./wikidata/page/"],       [db__content__dir        => q"./wikidata/page/"],
72       [db__content__error_log  => q"./wikidata/log/db-content.log"],       [db__content__error_log  => q"./wikidata/log/db-content.log"],
73       [db__bdb__home_dir       => q"./wikidata/lock/"],       [db__bdb__home_dir       => q"./wikidata/lock/"],
# Line 44  push our @Config, sub ($) { Line 77  push our @Config, sub ($) {
77       [db__lock__dir           => q"./wikidata/lock/"],       [db__lock__dir           => q"./wikidata/lock/"],
78       [db__lock__log_file      => q"./wikidata/log/lock.log"],       [db__lock__log_file      => q"./wikidata/log/lock.log"],
79       [db__log__dir            => q"./wikidata/log/"],       [db__log__dir            => q"./wikidata/log/"],
80         [db__request_log__dir    => q"./wikidata/rlog/"],
81       [db__temp__dir           => q"./wikidata/lock/"],       [db__temp__dir           => q"./wikidata/lock/"],
82         [namazu__index_dir       => q"/var/namazu/index/suikawiki"],
83    ) {    ) {
84      ## On system that does not set current directory as main script      ## On system that does not set current directory as main script
85      ## directory, you should specify it instead of using "abs_path".      ## directory, you should specify it instead of using "abs_path".
86      $WIKI->{config}->{path_to}->{$_->[0]} = abs_path $_->[1];      $WIKI->{config}->{path_to}->{$_->[0]} = File::Spec->catfile ($Bin, $_->[1]);
87    }    }
88      
89      ## -- Namazu URI Mapping (See SuikaWiki:SuikaWiki//Namazu) --
90      $WIKI->{config}->{nmz__uri_to_uri} = sub {
91        my ($nmzuri, %opt) = @_;
92        if ($nmzuri =~ s!^\Q$opt{o}->{wiki}->{config}->{path_to}->{db__content__dir}\E/*!!o) {
93          $nmzuri =~ s/\.txt$//;
94          return $opt{o}->{wiki}->uri_reference
95                          (page => $opt{o}->{wiki}->name ([
96            map {s/([0-9A-F][0-9A-F])/pack 'C', hex $1/ge; $_}
97            split m!\.ns/!, $nmzuri
98          ]), base => 1);
99        } else {
100          $nmzuri =~ s<^/home/wakaba/public_html/([^.]+)><http://suika.fam.cx/~wakaba/$1>;
101          return ($nmzuri, $nmzuri);
102        }
103      };
104    
105    ## -- WikiPlugin    ## -- WikiPlugin
106    push @{$WIKI->{event}->{plugin_manager_loaded}}, sub {    push @{$WIKI->{event}->{plugin_manager_loaded}}, sub {
# Line 75  push our @Config, sub ($) { Line 126  push our @Config, sub ($) {
126                
127        ## Main content        ## Main content
128        $wiki->{db}->_set_prop_db (content => {-db_open => sub {        $wiki->{db}->_set_prop_db (content => {-db_open => sub {
129          require SuikaWiki::DB::FileSystem::YukiWikiDBNS;          require SuikaWiki::DB::FileSystem::LeafFile;
130          SuikaWiki::DB::FileSystem::YukiWikiDBNS->new          SuikaWiki::DB::FileSystem::LeafFile->new
131            (directory => $wiki->{config}->{path_to}->{db__content__dir},            (base_directory => $wiki->{config}->{path_to}->{db__content__dir},
132             logfile   => $wiki->{config}->{path_to}->{db__content__error_log},             directory_suffix => '.ns',
133             suffix    => '.txt',             file_suffix    => '.txt',
134               root_key => $wiki->{config}->{page}->{Default},
135               -lock => $wiki->{var}->{db}->{lock_prop}->('content_prop'));
136          }, -db_close => sub {
137            my %opt = @_;
138            $opt{prop_info}->{-db}->close;
139            delete $opt{prop_info}->{-db};
140          }});
141    
142          ## Properties
143          $wiki->{db}->_set_prop_db (content_prop => {-db_open => sub {
144            require SuikaWiki::DB::FileSystem::LeafProp;
145            SuikaWiki::DB::FileSystem::LeafProp->new
146              (base_directory => $wiki->{config}->{path_to}->{db__content__dir},
147               directory_suffix => '.ns',
148               file_suffix    => '.prop',
149               root_key => $wiki->{config}->{page}->{Default},
150             -lock => $wiki->{var}->{db}->{lock_prop}->('content'));             -lock => $wiki->{var}->{db}->{lock_prop}->('content'));
151        }, -db_close => sub {        }, -db_close => sub {
152          my %opt = @_;          my %opt = @_;
# Line 102  push our @Config, sub ($) { Line 169  push our @Config, sub ($) {
169        ## Cache DBs        ## Cache DBs
170        require SuikaWiki::DB::FileSystem::SuikaWikiCache09;        require SuikaWiki::DB::FileSystem::SuikaWikiCache09;
171        my $cachedb = SuikaWiki::DB::FileSystem::SuikaWikiCache09->new        my $cachedb = SuikaWiki::DB::FileSystem::SuikaWikiCache09->new
172              (directory => $wiki->{config}->{path_to}->{db__cache__dir});              (directory => $wiki->{config}->{path_to}->{db__cache__dir},
173                 expires => 86400 * 3, removes => 86400 * 3); # 3 days
174        $wiki->{db}->_set_prop_db (m__search_result =>        $wiki->{db}->_set_prop_db (m__search_result =>
175          {-db => $cachedb, -prop => 'search_result', -db_close => sub {          {-db => $cachedb, -prop => 'search_result', -db_close => sub {
176            my %opt = @_;            my %opt = @_;
# Line 151  push our @Config, sub ($) { Line 219  push our @Config, sub ($) {
219                
220        ## Referer Database (See Referer plugin module)        ## Referer Database (See Referer plugin module)
221        $wiki->{db}->_set_prop_db (referer => {-db_open => sub {        $wiki->{db}->_set_prop_db (referer => {-db_open => sub {
222          require SuikaWiki::DB::Hash;          require SuikaWiki::DB::FileSystem::Count;
223          new SuikaWiki::DB::Hash constructor => sub {          SuikaWiki::DB::FileSystem::Count->new
224            tie my %db, 'BerkeleyDB::Hash',            (base_directory => $wiki->{config}->{path_to}->{db__content__dir},
225                          -Filename => 'referer.db',             directory_suffix => '.ns',
226                          -Env => $bdbenv,             file_suffix    => '.ref',
227                          -Flags => DB_CREATE,             root_key => $wiki->{config}->{page}->{Default},
228                          -Mode => 0644;             auto_mkdir => 0,
229            \%db;             -lock => $wiki->{var}->{db}->{lock_prop}->('referer'));
230         };        }, -db_close => sub {
231            my %opt = @_;
232            $opt{prop_info}->{-db}->close;
233            delete $opt{prop_info}->{-db};
234        }});        }});
235    
236        ## HTTP Request Logging Database (See RequestLog plugin module)        ## HTTP Request Logging Database (See RequestLog plugin module)
237        $wiki->{db}->_set_prop_db (log__http_request => {-db_open => sub {        $wiki->{db}->_set_prop_db (log__http_request => {-db_open => sub {
238          require SuikaWiki::DB::Hash;          require SuikaWiki::DB::FileSystem::Count;
239          new SuikaWiki::DB::Hash constructor => sub {          SuikaWiki::DB::FileSystem::Count->new
240            tie my %db, 'BerkeleyDB::Hash',            (base_directory => $wiki->{config}->{path_to}->{db__request_log__dir},
241                          -Filename => 'http-request-log.db',             directory_suffix => '.ns',
242                          -Env => $bdbenv,             file_suffix    => '.rlog',
243                          -Flags => DB_CREATE,             root_key => $wiki->{config}->{page}->{Default},
244                          -Mode => 0644;             auto_mkdir => 1);
245            \%db;        }, -db_close => sub {
246         };          my %opt = @_;
247            $opt{prop_info}->{-db}->close;
248            delete $opt{prop_info}->{-db};
249        }});        }});
250                
251        ## Additional WikiDB properties should be defined here        ## Additional WikiDB properties should be defined here
# Line 182  push our @Config, sub ($) { Line 255  push our @Config, sub ($) {
255    push @{$WIKI->{event}->{input_close}}, sub {    push @{$WIKI->{event}->{input_close}}, sub {
256      my ($wiki, $event) = @_;      my ($wiki, $event) = @_;
257      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 {  
258        SuikaWiki::Plugin->module_package ('RequestLog')        SuikaWiki::Plugin->module_package ('RequestLog')
259                       ->http_request_log (wiki => $wiki,                       ->http_request_log (wiki => $wiki,
260                                           prop => 'log__http_request');                                           prop => 'log__http_request');
# Line 206  push our @Config, sub ($) { Line 270  push our @Config, sub ($) {
270      InterWikiName   => $WIKI->name ([qw/Wiki InterWikiName/]),      InterWikiName   => $WIKI->name ([qw/Wiki InterWikiName/]),
271      NewPageTemplate => $WIKI->name ([qw/Wiki NewPageTemplate/]),      NewPageTemplate => $WIKI->name ([qw/Wiki NewPageTemplate/]),
272      'StyleSheetList(text/html)' => $WIKI->name ([qw<Wiki Style List text/html>]),      'StyleSheetList(text/html)' => $WIKI->name ([qw<Wiki Style List text/html>]),
273        ExpandedURI q<log:root> => $WIKI->name ([]),
274    };    };
275        
276    ## -- WikiNamespace constants    ## -- WikiNamespace constants
# Line 214  push our @Config, sub ($) { Line 279  push our @Config, sub ($) {
279      separator_reg => qr#\s*//\s*#,      separator_reg => qr#\s*//\s*#,
280      self => '.',      self => '.',
281      parent => '..',      parent => '..',
282        root => '//',
283    };    };
284        
285    ## -- Default character codes    ## -- Default character codes
# Line 232  push our @Config, sub ($) { Line 298  push our @Config, sub ($) {
298      ## Fragment identifier in URI reference      ## Fragment identifier in URI reference
299        uri_fragment => 'x-punycode',     ## Reserved for possible future use        uri_fragment => 'x-punycode',     ## Reserved for possible future use
300    };    };
301    
302      ## -- User option for media types
303      $WIKI->{config}->{ExpandedURI q<media-type:accept-media-type>} = {
304        q<IMT:text/css##> => 1,
305        q<IMT:text/plain##> => 1,
306        q<IMT:text/x-suikawiki;version="0.9"##> => 1,
307        q<IMT:application/x.suikawiki.config;version="2.0"##> => 1,
308      };
309        
310    ## -- Expires duration templates    ## -- Expires duration templates
311    $WIKI->{config}->{entity}->{expires} = {    $WIKI->{config}->{entity}->{expires} = {
312      edit      => {delta => 60},      edit      => {delta => 60},
313      view      => {delta => 2*3600},      view      => {delta => 2*3600},
314        list      => {delta => 60},
315      lm_flaged => {delta => 30*24*3600},      lm_flaged => {delta => 30*24*3600},
316      stylesheet => {delta => 30*24*3600},      stylesheet => {delta => 30*24*3600},
317      error     => {delta => 60},      error     => {delta => 60},

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24