/[pub]/suikawiki/script/default/suikawiki-config.ph
Suika

Diff of /suikawiki/script/default/suikawiki-config.ph

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

revision 1.12 by wakaba, Wed Feb 18 07:23:48 2004 UTC revision 1.16 by wakaba, Sat Mar 20 04:25:49 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  sub config ($) {  push our @Config, sub ($) {
24      eval q{ use Message::Util::Error };
25    my $WIKI = shift;    my $WIKI = shift;
26    use Cwd qw(abs_path);    use Cwd qw(abs_path);
27        
28    ## -- Filesystem path mapping    ## -- Filesystem path mapping
29    for (    for (
30       [db__cache__dir          => q"./wikidata/lock/"],       [db__cache__dir          => q"./wikidata/lock/"],
31         [db__cache_struct__file  => q"./wikidata/lock/struct.db"],
32       [db__content__dir        => q"./wikidata/page/"],       [db__content__dir        => q"./wikidata/page/"],
33       [db__content__error_log  => q"./wikidata/log/db-content.log"],       [db__content__error_log  => q"./wikidata/log/db-content.log"],
34       [db__bdb__home_dir       => q"./wikidata/lock/"],       [db__bdb__home_dir       => q"./wikidata/lock/"],
# Line 37  sub config ($) { Line 39  sub config ($) {
39       [db__lock__log_file      => q"./wikidata/log/lock.log"],       [db__lock__log_file      => q"./wikidata/log/lock.log"],
40       [db__log__dir            => q"./wikidata/log/"],       [db__log__dir            => q"./wikidata/log/"],
41       [db__temp__dir           => q"./wikidata/lock/"],       [db__temp__dir           => q"./wikidata/lock/"],
42    #     [namazu__index_dir       => q"/var/namazu/index/wiki"],
43    ) {    ) {
44      ## On system that does not set current directory as main script      ## On system that does not set current directory as main script
45      ## directory, you should specify it instead of using "abs_path".      ## directory, you should specify it instead of using "abs_path".
46      $WIKI->{config}->{path_to}->{$_->[0]} = abs_path $_->[1];      $WIKI->{config}->{path_to}->{$_->[0]} = abs_path $_->[1];
47    }    }
48    
49    =begin comment
50    
51      ## -- Namazu URI Mapping (See SuikaWiki:SuikaWiki//Namazu) --
52      $WIKI->{config}->{nmz__uri_to_uri} = sub {
53        my ($nmzuri, %opt) = @_;
54        if ($nmzuri =~ s!^\Q$opt{o}->{wiki}->{config}->{path_to}->{db__content__dir}\E/*!!o) {
55          $nmzuri =~ s/\.txt$//;
56          return $opt{o}->{wiki}->uri_reference
57                          (page => $opt{o}->{wiki}->name ([
58            map {s/([0-9A-F][0-9A-F])/pack 'C', hex $1/ge; $_}
59            split m!\.ns/!, $nmzuri
60          ]), base => 1);
61        } else {
62          return ($nmzuri, $nmzuri);
63        }
64      };
65    
66    =end comment
67    
68    ## -- WikiPlugin    ## -- WikiPlugin
69    push @{$WIKI->{event}->{plugin_manager_loaded}}, sub {    push @{$WIKI->{event}->{plugin_manager_loaded}}, sub {
70      my $wiki = shift;      my $wiki = shift;
# Line 94  sub config ($) { Line 116  sub config ($) {
116        ## Cache DBs        ## Cache DBs
117        require SuikaWiki::DB::FileSystem::SuikaWikiCache09;        require SuikaWiki::DB::FileSystem::SuikaWikiCache09;
118        my $cachedb = SuikaWiki::DB::FileSystem::SuikaWikiCache09->new        my $cachedb = SuikaWiki::DB::FileSystem::SuikaWikiCache09->new
119              (directory => $wiki->{config}->{path_to}->{db__cache__dir});              (directory => $wiki->{config}->{path_to}->{db__cache__dir},
120                 expires => 86400 * 3, removes => 86400 * 3); # 3 days
121        $wiki->{db}->_set_prop_db (m__search_result =>        $wiki->{db}->_set_prop_db (m__search_result =>
122          {-db => $cachedb, -prop => 'search_result', -db_close => sub {          {-db => $cachedb, -prop => 'search_result', -db_close => sub {
123            my %opt = @_;            my %opt = @_;
# Line 107  sub config ($) { Line 130  sub config ($) {
130            $opt{prop_info}->{-db}->close;            $opt{prop_info}->{-db}->close;
131            delete $opt{prop_info}->{-db};            delete $opt{prop_info}->{-db};
132          }});          }});
133          $wiki->{db}->_set_prop_db (ref__item_template =>
134            {-db => $cachedb, -prop => 'refereritem', -db_close => sub {
135              my %opt = @_;
136              $opt{prop_info}->{-db}->close;
137              delete $opt{prop_info}->{-db};
138            }});
139                
140        ## Berkely DB Environment Preparation        ## Berkely DB Environment Preparation
141        use BerkeleyDB;        use BerkeleyDB;
# Line 120  sub config ($) { Line 149  sub config ($) {
149           -ErrFile => $wiki->{config}->{path_to}->{db__bdb__log_file},           -ErrFile => $wiki->{config}->{path_to}->{db__bdb__log_file},
150           -Flags => DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL,           -Flags => DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL,
151           -Verbose => $wiki->{config}->{debug}->{db};           -Verbose => $wiki->{config}->{debug}->{db};
152    
153          $wiki->{db}->_set_prop_db (content__structured => {-db_open => sub {
154            require SuikaWiki::DB::Hash;
155            new SuikaWiki::DB::Hash constructor => sub {
156              use MLDBM qw(BerkeleyDB::Hash);# Storable);
157              tie my %mldb, 'MLDBM',
158                            -Filename => $wiki->{config}->{path_to}
159                                              ->{db__cache_struct__file},
160                            -Env => $bdbenv,
161                            -Flags => DB_CREATE,
162                            -Mode => 0644;
163              \%mldb;
164           };
165          }});
166                
167        ## Referer Database (See Referer plugin module)        ## Referer Database (See Referer plugin module)
168        $wiki->{db}->_set_prop_db (referer => {-db_open => sub {        $wiki->{db}->_set_prop_db (referer => {-db_open => sub {
# Line 153  sub config ($) { Line 196  sub config ($) {
196    
197    push @{$WIKI->{event}->{input_close}}, sub {    push @{$WIKI->{event}->{input_close}}, sub {
198      my ($wiki, $event) = @_;      my ($wiki, $event) = @_;
199      SuikaWiki::Plugin->module_package ('Referer')      try {
200          SuikaWiki::Plugin->module_package ('Referer')
201                       ->add_referer (wiki => $wiki,                       ->add_referer (wiki => $wiki,
202                                      uri => $wiki->{input}->meta_variable                                      uri => $wiki->{input}->meta_variable
203                                               ('HTTP_REFERER'));                                               ('HTTP_REFERER'));
204      SuikaWiki::Plugin->module_package ('RequestLog')      } catch SuikaWiki::Plugin::error with {
205          my $err = shift;
206          $err->raise unless $err->{-type} eq 'PLUGIN_NOT_FOUND';
207        };
208        try {
209          SuikaWiki::Plugin->module_package ('RequestLog')
210                       ->http_request_log (wiki => $wiki,                       ->http_request_log (wiki => $wiki,
211                                           prop => 'log__http_request');                                           prop => 'log__http_request');
212        } catch SuikaWiki::Plugin::error with {
213          my $err = shift;
214          $err->raise unless $err->{-type} eq 'PLUGIN_NOT_FOUND';
215        };
216    };    };
217    
218    ## -- WikiName of special purpose WikiPages    ## -- WikiName of special purpose WikiPages
# Line 206  sub config ($) { Line 259  sub config ($) {
259    
260    ## -- Debug mode    ## -- Debug mode
261    $WIKI->{config}->{debug} = {    $WIKI->{config}->{debug} = {
262      general => 1,      general => 0,
263      db => 0,      db => 0,
264      format => 0,      format => 0,
265      view => 1,      view => 0,
266    };    };
267    
268  }  };
269    
270  =head1 SEE ALSO  =head1 SEE ALSO
271    

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24