=head1 NAME suikawiki-config.ph - SuikaWiki: Configuration for SuikaWiki HTTP CGI Driver =head1 DESCRIPTION This is a configuration file for SuikaWiki Driver for HTTP CGI Script (SWHCS). Basic options such as WikiDB directory mapping and special purpose WikiPage names can be customized with this file. More complex customizing, e.g. modifying navigation bar or adding new mode, is also possible by config.ph (generated from config.wp2) and WikiPlugin modules. For more information, see . This file is part of SuikaWiki. =cut package wiki::driver::http; use strict; ## These lines should be removed after utf8 support BEGIN { $Message::Util::Formatter::Base::Token = qr/[\w._+\x80-\xFF-]+/; require Message::Util::Formatter::Base; } use Message::Util::Error; push our @Config, sub ($) { my $WIKI = shift; use Cwd qw(abs_path); ## -- Filesystem path mapping for ( [db__cache__dir => q"./wikidata/lock/"], [db__cache_struct__file => q"./wikidata/lock/struct.db"], [db__content__dir => q"./wikidata/page/"], [db__content__error_log => q"./wikidata/log/db-content.log"], [db__bdb__home_dir => q"./wikidata/lock/"], [db__bdb__log_dir => q"./wikidata/log/bdb/"], [db__bdb__log_file => q"./wikidata/log/bdb.log"], [db__bdb__temp_dir => q"./wikidata/lock/"], [db__lock__dir => q"./wikidata/lock/"], [db__lock__log_file => q"./wikidata/log/lock.log"], [db__log__dir => q"./wikidata/log/"], [db__temp__dir => q"./wikidata/lock/"], ) { ## On system that does not set current directory as main script ## directory, you should specify it instead of using "abs_path". $WIKI->{config}->{path_to}->{$_->[0]} = abs_path $_->[1]; } ## -- WikiPlugin push @{$WIKI->{event}->{plugin_manager_loaded}}, sub { my $wiki = shift; ## Installed plugin modules $wiki->{plugin}->load_directory (qw( lib/SuikaWiki/Plugin/ misc/plugins/ misc/plugins/form/ misc/plugins/format/ misc/plugins/link/ misc/plugins/view/ )); ## Configuration file as pseudo-plugin module require 'wikidata/config.ph'; }; ## -- WikiDatabase: Mapping logical to physical push @{$WIKI->{event}->{database_loaded}}, sub { my $wiki = shift; ## Main content $wiki->{db}->_set_prop_db (content => {-db_open => sub { require SuikaWiki::DB::FileSystem::YukiWikiDBNS; SuikaWiki::DB::FileSystem::YukiWikiDBNS->new (directory => $wiki->{config}->{path_to}->{db__content__dir}, logfile => $wiki->{config}->{path_to}->{db__content__error_log}, suffix => '.txt', -lock => $wiki->{var}->{db}->{lock_prop}->('content')); }, -db_close => sub { my %opt = @_; $opt{prop_info}->{-db}->close; delete $opt{prop_info}->{-db}; }}); ## Last modified $wiki->{db}->_set_prop_db (lastmodified => {-db_open => sub { require SuikaWiki::DB::FileSystem::SuikaWikiMetaInfo09; SuikaWiki::DB::FileSystem::SuikaWikiMetaInfo09->new (directory => $wiki->{config}->{path_to}->{db__content__dir}, -lock => $wiki->{var}->{db}->{lock_prop}->('lastmodified')); }, -prop => 'last_modified', -db_close => sub { my %opt = @_; $opt{prop_info}->{-db}->close; delete $opt{prop_info}->{-db}; }}); ## Cache DBs require SuikaWiki::DB::FileSystem::SuikaWikiCache09; my $cachedb = SuikaWiki::DB::FileSystem::SuikaWikiCache09->new (directory => $wiki->{config}->{path_to}->{db__cache__dir}); $wiki->{db}->_set_prop_db (m__search_result => {-db => $cachedb, -prop => 'search_result', -db_close => sub { my %opt = @_; $opt{prop_info}->{-db}->close; delete $opt{prop_info}->{-db}; }}); $wiki->{db}->_set_prop_db (wpp__headsummary => {-db => $cachedb, -prop => 'headsummary', -db_close => sub { my %opt = @_; $opt{prop_info}->{-db}->close; delete $opt{prop_info}->{-db}; }}); $wiki->{db}->_set_prop_db (ref__item_template => {-db => $cachedb, -prop => 'refereritem', -db_close => sub { my %opt = @_; $opt{prop_info}->{-db}->close; delete $opt{prop_info}->{-db}; }}); ## Berkely DB Environment Preparation use BerkeleyDB; my $bdbenv = new BerkeleyDB::Env -Home => $wiki->{config}->{path_to}->{db__bdb__home_dir}, -Config => { DB_DATA_DIR => $wiki->{config}->{path_to}->{db__content__dir}, DB_LOG_DIR => $wiki->{config}->{path_to}->{db__bdb__log_dir}, DB_TMP_DIR => $wiki->{config}->{path_to}->{db__bdb__temp_dir}, }, -ErrFile => $wiki->{config}->{path_to}->{db__bdb__log_file}, -Flags => DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL, -Verbose => $wiki->{config}->{debug}->{db}; $wiki->{db}->_set_prop_db (content__structured => {-db_open => sub { require SuikaWiki::DB::Hash; new SuikaWiki::DB::Hash constructor => sub { use MLDBM qw(BerkeleyDB::Hash);# Storable); tie my %mldb, 'MLDBM', -Filename => $wiki->{config}->{path_to} ->{db__cache_struct__file}, -Env => $bdbenv, -Flags => DB_CREATE, -Mode => 0644; \%mldb; }; }}); ## Referer Database (See Referer plugin module) $wiki->{db}->_set_prop_db (referer => {-db_open => sub { require SuikaWiki::DB::Hash; new SuikaWiki::DB::Hash constructor => sub { tie my %db, 'BerkeleyDB::Hash', -Filename => 'referer.db', -Env => $bdbenv, -Flags => DB_CREATE, -Mode => 0644; \%db; }; }}); ## HTTP Request Logging Database (See RequestLog plugin module) $wiki->{db}->_set_prop_db (log__http_request => {-db_open => sub { require SuikaWiki::DB::Hash; new SuikaWiki::DB::Hash constructor => sub { tie my %db, 'BerkeleyDB::Hash', -Filename => 'http-request-log.db', -Env => $bdbenv, -Flags => DB_CREATE, -Mode => 0644; \%db; }; }}); ## Additional WikiDB properties should be defined here # ... }; push @{$WIKI->{event}->{input_close}}, sub { my ($wiki, $event) = @_; 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 { SuikaWiki::Plugin->module_package ('RequestLog') ->http_request_log (wiki => $wiki, prop => 'log__http_request'); } catch SuikaWiki::Plugin::error with { my $err = shift; $err->raise unless $err->{-type} eq 'PLUGIN_NOT_FOUND'; }; }; ## -- WikiName of special purpose WikiPages $WIKI->{config}->{page} = { Default => $WIKI->name ([qw/HomePage/]), InterWikiName => $WIKI->name ([qw/Wiki InterWikiName/]), NewPageTemplate => $WIKI->name ([qw/Wiki NewPageTemplate/]), 'StyleSheetList(text/html)' => $WIKI->name ([qw]), }; ## -- WikiNamespace constants $WIKI->{config}->{name}->{space} = { separator => '//', separator_reg => qr#\s*//\s*#, self => '.', parent => '..', }; ## -- Default character codes $WIKI->{config}->{charset} = { ## Internal code - MUST be ASCII + 8bit coding scheme internal => 'euc-jp', ## Default output code output => 'iso-2022-jp', ## "query" part in URI reference uri_query => '', # auto-detected uri_query_encode => 'euc-jp', ## For compatibility w/ SuikaWiki 2 uri_param => '', # auto-detected uri_param_encode => 'euc-jp', ## For compatibility w/ SuikaWiki 2 ## PATH_INFO part in URI reference uri_path_info => 'x-utf-8-10646', ## Reserved for future use ## Fragment identifier in URI reference uri_fragment => 'x-punycode', ## Reserved for possible future use }; ## -- Expires duration templates $WIKI->{config}->{entity}->{expires} = { edit => {delta => 60}, view => {delta => 2*3600}, lm_flaged => {delta => 30*24*3600}, stylesheet => {delta => 30*24*3600}, error => {delta => 60}, }; ## -- Debug mode $WIKI->{config}->{debug} = { general => 0, db => 0, format => 0, view => 0, }; }; =head1 SEE ALSO C, C, , =head1 LICENSE Copyright 2003-2004 Wakaba . All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; # $Date: 2004/03/13 13:16:59 $