/[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.8 by wakaba, Fri Dec 26 07:05:09 2003 UTC revision 1.13 by wakaba, Thu Mar 11 10:09:41 2004 UTC
# Line 1  Line 1 
1  package main;  =head1 NAME
2  use strict;  
3    suikawiki-config.ph - SuikaWiki: Configuration for SuikaWiki HTTP CGI Driver
4    
5    =head1 DESCRIPTION
6    
7    This is a configuration file for SuikaWiki Driver for HTTP CGI Script
8    (SWHCS).  Basic options such as WikiDB directory mapping and
9    special purpose WikiPage names can be customized with this file.
10    
11  ## [OBSOLETE] URI (or part of URI) of Wiki CGI script itself and its external addons  More complex customizing, e.g. modifying navigation bar or
12          ## Note: If your Wiki CGI script URI is <http://foo.example/path/to/wiki.cgi>,  adding new mode, is also possible by config.ph (generated from
13          ##              cookie-path: /path/to/  config.wp2) and WikiPlugin modules.  For more information,
14          ##              script-short-name: wiki.cgi  see <http://suika.fam.cx/~wakaba/-temp/wiki/wiki?SuikaWiki>.
15          ##       URI parts MUST NOT contains "&" and/or non-URI characters.  
16    our %uri = (  This file is part of SuikaWiki.
17      cookie_path         => '/~wakaba/-temp/expwiki/',  
18      external_script     => '../wiki/script/',  =cut
19      script_short_name   => 'wiki',  
20      ## If you use CVS repository of WikiDatabase,  package wiki::driver::http;
21      #cvs_repository     => 'http://path-to-viewcvs/path-to-repository/',  use strict;
   );  
   $uri{wiki_abs} = "http://".($main::ENV{HTTP_HOST} || $main::ENV{SERVER_NAME}.($main::ENV{SERVER_PORT}==80?'':":$main::ENV{SERVER_PORT}"))."$uri{cookie_path}$uri{script_short_name}";  
   $main::url_cgi = $uri{wiki_abs};  
   $uri{wiki} = qq($uri{cookie_path}$uri{script_short_name});      
   
 ## Path to modules and databases  
   push @main::INC, qw'lib ../wiki/lib lib';  
   
 ## Constructing a new instance of the WikiEngine  
   require SuikaWiki::Implementation;  
   our $WIKI = SuikaWiki::Implementation->new;  
   
   ## Obsolete interface  
   our %PathTo = (       ## Path to your data, relative to the main CGI script (NOT to this config script)  
     CachePrefix         => q(./wikidata/.cache.),  # WikiPlugin  
     TempPrefix  => q(./wikidata/.tmp.),            # WikiPlugin, Image  
     convert     => q(/usr/X11R6/bin/convert),      # Image  
   );  
22    
23  ## Filesystem path mapping  sub config ($) {
24      my $WIKI = shift;
25      use Cwd qw(abs_path);
26      
27      ## -- Filesystem path mapping
28    for (    for (
29       [db__content__dir        => q"./wikidata/page"],       [db__cache__dir          => q"./wikidata/lock/"],
30         [db__content__dir        => q"./wikidata/page/"],
31       [db__content__error_log  => q"./wikidata/log/db-content.log"],       [db__content__error_log  => q"./wikidata/log/db-content.log"],
32         [db__bdb__home_dir       => q"./wikidata/lock/"],
33         [db__bdb__log_dir        => q"./wikidata/log/bdb/"],
34         [db__bdb__log_file       => q"./wikidata/log/bdb.log"],
35         [db__bdb__temp_dir       => q"./wikidata/lock/"],
36       [db__lock__dir           => q"./wikidata/lock/"],       [db__lock__dir           => q"./wikidata/lock/"],
37         [db__lock__log_file      => q"./wikidata/log/lock.log"],
38         [db__log__dir            => q"./wikidata/log/"],
39         [db__temp__dir           => q"./wikidata/lock/"],
40    ) {    ) {
41      $WIKI->{config}->{path_to}->{$_->[0]} = $_->[1];      ## On system that does not set current directory as main script
42        ## directory, you should specify it instead of using "abs_path".
43        $WIKI->{config}->{path_to}->{$_->[0]} = abs_path $_->[1];
44    }    }
45    
46  ## Debug mode    ## -- WikiPlugin
   $WIKI->{config}->{debug} = {  
     general => 1,  
     db => 0,  
   };  
   
 ## WikiPlugin  
47    push @{$WIKI->{event}->{plugin_manager_loaded}}, sub {    push @{$WIKI->{event}->{plugin_manager_loaded}}, sub {
48      my $wiki = shift;      my $wiki = shift;
49        
50        ## Installed plugin modules
51      $wiki->{plugin}->load_directory (qw(      $wiki->{plugin}->load_directory (qw(
52        lib/SuikaWiki/Plugin/        lib/SuikaWiki/Plugin/
53        misc/plugins/        misc/plugins/
54          misc/plugins/form/
55          misc/plugins/format/
56          misc/plugins/link/
57        misc/plugins/view/        misc/plugins/view/
58      ));      ));
59        
60        ## Configuration file as pseudo-plugin module
61      require 'wikidata/config.ph';      require 'wikidata/config.ph';
62    };    };
63    
64  ## WikiDatabase : Mapping logical to physical    ## -- WikiDatabase: Mapping logical to physical
65    push @{$WIKI->{event}->{database_loaded}}, sub {    push @{$WIKI->{event}->{database_loaded}}, sub {
66          my $wiki = shift;
67          
68        ## Main content        ## Main content
69        $WIKI->{db}->_set_prop_db (content => {-db_open => sub {        $wiki->{db}->_set_prop_db (content => {-db_open => sub {
70          require SuikaWiki::DB::FileSystem::YukiWikiDBNS;          require SuikaWiki::DB::FileSystem::YukiWikiDBNS;
71          SuikaWiki::DB::FileSystem::YukiWikiDBNS->new          SuikaWiki::DB::FileSystem::YukiWikiDBNS->new
72            (directory => $WIKI->{config}->{path_to}->{db__content__dir},            (directory => $wiki->{config}->{path_to}->{db__content__dir},
73             logfile   => $WIKI->{config}->{path_to}->{db__content__error_log},             logfile   => $wiki->{config}->{path_to}->{db__content__error_log},
74             suffix    => '.txt',             suffix    => '.txt',
75             -lock => &{$WIKI->{var}->{db}->{lock_prop}} ('content'));             -lock => $wiki->{var}->{db}->{lock_prop}->('content'));
76        }, -db_close => sub {        }, -db_close => sub {
77          my %opt = @_;          my %opt = @_;
78          $opt{prop_info}->{-db}->close;          $opt{prop_info}->{-db}->close;
# Line 74  use strict; Line 80  use strict;
80        }});        }});
81                
82        ## Last modified        ## Last modified
83        $WIKI->{db}->_set_prop_db (lastmodified => {-db_open => sub {        $wiki->{db}->_set_prop_db (lastmodified => {-db_open => sub {
84          require SuikaWiki::DB::FileSystem::SuikaWikiMetaInfo09;          require SuikaWiki::DB::FileSystem::SuikaWikiMetaInfo09;
85          SuikaWiki::DB::FileSystem::SuikaWikiMetaInfo09->new          SuikaWiki::DB::FileSystem::SuikaWikiMetaInfo09->new
86            (directory => $WIKI->{config}->{path_to}->{db__content__dir},            (directory => $wiki->{config}->{path_to}->{db__content__dir},
87             -lock => &{$WIKI->{var}->{db}->{lock_prop}} ('lastmodified'));             -lock => $wiki->{var}->{db}->{lock_prop}->('lastmodified'));
88        }, -prop => 'last_modified', -db_close => sub {        }, -prop => 'last_modified', -db_close => sub {
89          my %opt = @_;          my %opt = @_;
90          $opt{prop_info}->{-db}->close;          $opt{prop_info}->{-db}->close;
91          delete $opt{prop_info}->{-db};          delete $opt{prop_info}->{-db};
92        }});        }});
93            
94    ## OBSOLETE interface for transition        ## Cache DBs
95    ## Don't remove until WikiResource is reimplemented        require SuikaWiki::DB::FileSystem::SuikaWikiCache09;
96      $WIKI->{db}->get (content => ['dummy']);        my $cachedb = SuikaWiki::DB::FileSystem::SuikaWikiCache09->new
97      *main::database = $WIKI->{db}->{prop}->{content}->{-db}->{db_hash};              (directory => $wiki->{config}->{path_to}->{db__cache__dir});
98      $SuikaWiki::Plugin::DB = $WIKI->{db};        $wiki->{db}->_set_prop_db (m__search_result =>
99      for (@{$SuikaWiki::Plugin::On{WikiDatabaseLoaded}||[]}) { &{$_} }          {-db => $cachedb, -prop => 'search_result', -db_close => sub {
100                  my %opt = @_;
101      package wiki::dummy;            $opt{prop_info}->{-db}->close;
102      sub meta {undef};            delete $opt{prop_info}->{-db};
103      sub list_items {};          }});
104      sub STORE {};        $wiki->{db}->_set_prop_db (wpp__headsummary =>
105            {-db => $cachedb, -prop => 'headsummary', -db_close => sub {
106              my %opt = @_;
107              $opt{prop_info}->{-db}->close;
108              delete $opt{prop_info}->{-db};
109            }});
110          
111          ## Berkely DB Environment Preparation
112          use BerkeleyDB;
113          my $bdbenv = new BerkeleyDB::Env
114             -Home => $wiki->{config}->{path_to}->{db__bdb__home_dir},
115             -Config => {
116               DB_DATA_DIR => $wiki->{config}->{path_to}->{db__content__dir},
117               DB_LOG_DIR => $wiki->{config}->{path_to}->{db__bdb__log_dir},
118               DB_TMP_DIR => $wiki->{config}->{path_to}->{db__bdb__temp_dir},
119             },
120             -ErrFile => $wiki->{config}->{path_to}->{db__bdb__log_file},
121             -Flags => DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL,
122             -Verbose => $wiki->{config}->{debug}->{db};
123          
124          ## Referer Database (See Referer plugin module)
125          $wiki->{db}->_set_prop_db (referer => {-db_open => sub {
126            require SuikaWiki::DB::Hash;
127            new SuikaWiki::DB::Hash constructor => sub {
128              tie my %db, 'BerkeleyDB::Hash',
129                            -Filename => 'referer.db',
130                            -Env => $bdbenv,
131                            -Flags => DB_CREATE,
132                            -Mode => 0644;
133              \%db;
134           };
135          }});
136    
137          ## HTTP Request Logging Database (See RequestLog plugin module)
138          $wiki->{db}->_set_prop_db (log__http_request => {-db_open => sub {
139            require SuikaWiki::DB::Hash;
140            new SuikaWiki::DB::Hash constructor => sub {
141              tie my %db, 'BerkeleyDB::Hash',
142                            -Filename => 'http-request-log.db',
143                            -Env => $bdbenv,
144                            -Flags => DB_CREATE,
145                            -Mode => 0644;
146              \%db;
147           };
148          }});
149          
150          ## Additional WikiDB properties should be defined here
151          # ...    
152      };
153    
154      push @{$WIKI->{event}->{input_close}}, sub {
155        my ($wiki, $event) = @_;
156        try {
157          SuikaWiki::Plugin->module_package ('Referer')
158                         ->add_referer (wiki => $wiki,
159                                        uri => $wiki->{input}->meta_variable
160                                                 ('HTTP_REFERER'));
161        } catch SuikaWiki::Plugin::error with {
162          my $err = shift;
163          $err->raise unless $err->{-type} eq 'PLUGIN_NOT_FOUND';
164        };
165        try {
166          SuikaWiki::Plugin->module_package ('RequestLog')
167                         ->http_request_log (wiki => $wiki,
168                                             prop => 'log__http_request');
169        } catch SuikaWiki::Plugin::error with {
170          my $err = shift;
171          $err->raise unless $err->{-type} eq 'PLUGIN_NOT_FOUND';
172        };
173    };    };
174    
175    ## WikiName of special purpose WikiPages    ## -- WikiName of special purpose WikiPages
176    $WIKI->{config}->{page} = {    $WIKI->{config}->{page} = {
177      Default         => [qw/HomePage/],      Default         => $WIKI->name ([qw/HomePage/]),
178      NewPageTemplate => [qw/Wiki NewPageTemplate/],      InterWikiName   => $WIKI->name ([qw/Wiki InterWikiName/]),
179        NewPageTemplate => $WIKI->name ([qw/Wiki NewPageTemplate/]),
180        'StyleSheetList(text/html)' => $WIKI->name ([qw<Wiki Style List text/html>]),
181    };    };
182        
183    ## [OBSOLETE] Name of Special WikiPage (linked as parts of navigations)    ## -- WikiNamespace constants
184    our %PageName = (    $WIKI->{config}->{name}->{space} = {
185      FrontPage   => 'HomePage',      separator => '//',
186      InterWikiName       => 'Wiki//InterWikiName',      separator_reg => qr#\s*//\s*#,
187      MenuBar     => 'Wiki//MenuBar',      self => '.',
188      RefererDontRecord   => 'Wiki//Referer//IgnoreSite',      parent => '..',
189      RefererSiteName     => 'Wiki//Referer//SiteName',    };
     ResourceNS  => 'Wiki//Resource//',  
     StyleList   => 'Wiki//Style//List//',  
   );  
     
   ## WikiNamespace constants  
   $WIKI->{config}->{name}->{space}->{separator} = '//';  
   $WIKI->{config}->{name}->{space}->{separator_reg} = qr#//#;  
190        
191    ## Default character code    ## -- Default character codes
192    $WIKI->{config}->{charset}->{internal} = 'euc-jp';    $WIKI->{config}->{charset} = {
193    $WIKI->{config}->{charset}->{output} = 'iso-2022-jp';      ## Internal code - MUST be ASCII + 8bit coding scheme
194    $WIKI->{config}->{charset}->{uri_param} = ''; # auto detect        internal => 'euc-jp',
195    $WIKI->{config}->{charset}->{uri_param_encode} = 'euc-jp';      ## Default output code
196    $WIKI->{config}->{charset}->{uri_query} = ''; # auto detect        output => 'iso-2022-jp',
197    $WIKI->{config}->{charset}->{uri_query_encode} = 'euc-jp';      ## "query" part in URI reference
198    $WIKI->{config}->{charset}->{uri_path_info} = 'utf-8';        uri_query => '', # auto-detected
199          uri_query_encode => 'euc-jp',     ## For compatibility w/ SuikaWiki 2
200          uri_param => '', # auto-detected
201          uri_param_encode => 'euc-jp',     ## For compatibility w/ SuikaWiki 2
202        ## PATH_INFO part in URI reference
203          uri_path_info => 'x-utf-8-10646', ## Reserved for future use
204        ## Fragment identifier in URI reference
205          uri_fragment => 'x-punycode',     ## Reserved for possible future use
206      };
207        
208    ## Expires duration templates    ## -- Expires duration templates
209    $WIKI->{config}->{entity}->{expires} = {    $WIKI->{config}->{entity}->{expires} = {
210      edit      => {delta => 60},      edit      => {delta => 60},
211      view      => {delta => 2*3600},      view      => {delta => 2*3600},
212      lm_flaged => {delta => 30*24*3600},      lm_flaged => {delta => 30*24*3600},
213        stylesheet => {delta => 30*24*3600},
214        error     => {delta => 60},
215    };    };
216    
217      ## -- Debug mode
218      $WIKI->{config}->{debug} = {
219        general => 0,
220        db => 0,
221        format => 0,
222        view => 0,
223      };
224    
225  =head1 NAME  }
226    
227    =head1 SEE ALSO
228    
229  suikawiki-config.ph --- SuikaWiki: Configuration of the wiki  C<lib/suikawiki.pl>, C<wiki.cgi>,
230    <http://suika.fam.cx/~wakaba/-temp/wiki/wiki?SuikaWiki>,
231    <http://suika.fam.cx/~wakaba/-temp/wiki/wiki?SWHCS>
232    
233  =head1 LICENSE  =head1 LICENSE
234    
235  Copyright 2003 Wakaba <w@suika.fam.cx>  Copyright 2003-2004 Wakaba <w@suika.fam.cx>.  All rights reserved.
236    
237  This program is free software; you can redistribute it and/or  This program is free software; you can redistribute it and/or
238  modify it under the same terms as Perl itself.  modify it under the same terms as Perl itself.

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.13

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24