=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; use Message::Util::QName::General [q], { 'log' => q, 'media-type' => q, 'pe' => q, 'relrev' => q, 'ss' => q, 'sw' => q, 'sw09' => q, }; BEGIN { if ($main::ENV{REQUEST_URI} =~ /\#/) { require SuikaWiki::Output::HTTP; my $out = SuikaWiki::Output::HTTP->new; $out->{status_code} = 401; $out->{status_phrase} = q; $out->{entity}->{media_type} = q; $out->{entity}->{charset} = q; $out->{entity}->{language} = [q]; $out->{entity}->{body_is_octet_stream} = 1; my $ua = $main::ENV{HTTP_USER_AGENT}; for ($ua) { s/&/&/g; s/{entity}->{body} = qq< 401 Bad Request-URI

Bad Request-URI

Your Request-URI has fragment identifier but it is not allowed here. It might be a bug of your user agent ($ua). Please contact to the UA vendor.

>; $out->output (output => 'http-cgi'); exit; } } push our @Config, sub ($) { my $WIKI = shift; use FindBin q($Bin); use File::Spec; ## -- Filesystem path mapping for ( [db__cache__dir => q"./wikidata/cache/"], [db__cache_struct__file => q"./wikidata/cache/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__request_log__dir => q"./wikidata/rlog/"], [db__static__dir => q"./wikidata/static/"], [db__temp__dir => q"./wikidata/lock/"], [namazu__index_dir => q"/var/namazu/index/suikawiki"], ) { ## 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]} = File::Spec->rel2abs ($_->[1], $Bin); } ## -- Namazu URI Mapping (See SuikaWiki:SuikaWiki//Namazu) -- $WIKI->{config}->{nmz__uri_to_uri} = sub { my ($nmzuri, %opt) = @_; if ($nmzuri =~ s!^\Q$opt{o}->{wiki}->{config}->{path_to}->{db__content__dir}\E/*!!o) { $nmzuri =~ s/\.txt$//; return $opt{o}->{wiki}->uri_reference (page => $opt{o}->{wiki}->name ([ map {s/([0-9A-F][0-9A-F])/pack 'C', hex $1/ge; $_} split m!\.ns/!, $nmzuri ]), base => 1); } else { $nmzuri =~ s<^/home/wakaba/public_html/([^.]+)>; return ($nmzuri, $nmzuri); } }; ## -- 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::LeafFile; SuikaWiki::DB::FileSystem::LeafFile->new (base_directory => $wiki->{config}->{path_to}->{db__content__dir}, directory_suffix => '.ns', file_suffix => '.txt', root_key => $wiki->{config}->{page}->{Default}, -lock => $wiki->{var}->{db}->{lock_prop}->('content')); }, -db_close => sub { my %opt = @_; $opt{prop_info}->{-db}->close; delete $opt{prop_info}->{-db}; }}); ## Properties $wiki->{db}->_set_prop_db (content_prop => {-db_open => sub { require SuikaWiki::DB::FileSystem::LeafProp; SuikaWiki::DB::FileSystem::LeafProp->new (base_directory => $wiki->{config}->{path_to}->{db__content__dir}, directory_suffix => '.ns', file_suffix => '.prop', root_key => $wiki->{config}->{page}->{Default}, -lock => $wiki->{var}->{db}->{lock_prop}->('content_prop')); }, -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}; }}); ## Static version $wiki->{db}->_set_prop_db (static__css => {-db_open => sub { require SuikaWiki::DB::FileSystem::LeafFileP; SuikaWiki::DB::FileSystem::LeafFileP->new (base_directory => $wiki->{config}->{path_to}->{db__static__dir}, directory_suffix => '.ns', file_suffix => '.css', root_key => $wiki->{config}->{page}->{Default}); }, -db_close => sub { my %opt = @_; $opt{prop_info}->{-db}->close; delete $opt{prop_info}->{-db}; }}); $wiki->{config}->{ExpandedURI q} = 1; ## URI maker for LeafFileP generated files $wiki->{config}->{ExpandedURI q} = sub { my (undef, %opt) = @_; my $page = join '.ns/', map {s/([^0-9A-Za-z_-])/sprintf '+%02X', ord $1/ge;$_} @{$opt{wikiname}}; return URI->new ('wikidata/static/' . $page . '.css'); }; ## Reverse mapping of generate-uri $wiki->{config}->{ExpandedURI q} = sub { my (undef, %opt) = @_; $opt{uri} =~ s!^.+/wikidata/static/!!g; $opt{uri} =~ s/\?[^?]*$//g; $opt{uri} =~ s/\.css$//g; return $opt{wiki}->name ([map {s/\+([0-9A-Fa-f_-][0-9A-Fa-f_-])/pack 'CC', hex $1/ge;$_} split m!.ns/!, $opt{uri}]); }; ## Cache DBs require SuikaWiki::DB::FileSystem::SuikaWikiCache09; my $cachedb = SuikaWiki::DB::FileSystem::SuikaWikiCache09->new (directory => $wiki->{config}->{path_to}->{db__cache__dir}, expires => 86400 * 3, removes => 86400 * 3); # 3 days $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::FileSystem::Count; SuikaWiki::DB::FileSystem::Count->new (base_directory => $wiki->{config}->{path_to}->{db__content__dir}, directory_suffix => '.ns', file_suffix => '.ref', root_key => $wiki->{config}->{page}->{Default}, auto_mkdir => 0, -lock => $wiki->{var}->{db}->{lock_prop}->('referer')); }, -db_close => sub { my %opt = @_; $opt{prop_info}->{-db}->close; delete $opt{prop_info}->{-db}; }}); ## HTTP Request Logging Database (See RequestLog plugin module) $wiki->{db}->_set_prop_db (log__http_request => {-db_open => sub { require SuikaWiki::DB::FileSystem::Count; SuikaWiki::DB::FileSystem::Count->new (base_directory => $wiki->{config}->{path_to}->{db__request_log__dir}, directory_suffix => '.ns', file_suffix => '.rlog', root_key => $wiki->{config}->{page}->{Default}, auto_mkdir => 1); }, -db_close => sub { my %opt = @_; $opt{prop_info}->{-db}->close; delete $opt{prop_info}->{-db}; }}); ## Additional WikiDB properties should be defined here # ... }; push @{$WIKI->{event}->{input_close}}, sub { my ($wiki, $event) = @_; 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'; }; }; $WIKI->{config}->{engine_max_access} = 15; ## -- 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]), ExpandedURI q => $WIKI->name ([]), }; ## -- WikiNamespace constants $WIKI->{config}->{name}->{space} = { separator => '//', separator_reg => qr#\s*//\s*#, self => '.', parent => '..', root => '//', }; ## -- 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 }; ## -- User option for media types $WIKI->{config}->{ExpandedURI q} = { q => 1, q => 1, q => 1, q => 1, }; ## -- Expires duration templates $WIKI->{config}->{entity}->{expires} = { edit => {delta => 60}, view => {delta => 2*3600}, list => {delta => 60}, lm_flaged => {delta => 30*24*3600}, stylesheet => {delta => 30*24*3600}, error => {delta => 60}, }; ## -- User-editable content properties $WIKI->{config}->{ExpandedURI q} = { 'abstract' => {uri => ExpandedURI q}, 'abstract--type' => {uri => ExpandedURI q, type => ExpandedURI q, depend => [qw/abstract/]}, 'category' => {uri => ExpandedURI q, is_list => 1}, 'keyword' => {uri => ExpandedURI q, is_list => 1}, 'obsoleted' => {uri => ExpandedURI q}, 'rel-contents' => {uri => ExpandedURI q, is_list => 1}, 'rel-index' => {uri => ExpandedURI q, is_list => 1}, 'rel-next' => {uri => ExpandedURI q, is_list => 1}, 'rel-prev' => {uri => ExpandedURI q, is_list => 1}, 'rel-up' => {uri => ExpandedURI q, is_list => 1}, }; ## -- 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/08/06 03:39:02 $