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::Error; |
use Message::Util::QName::General [q<ExpandedURI>], { |
31 |
|
'media-type' => q<http://suika.fam.cx/~wakaba/-temp/2004/04/24/mt#>, |
32 |
|
}; |
33 |
|
|
34 |
push our @Config, sub ($) { |
push our @Config, sub ($) { |
35 |
my $WIKI = shift; |
my $WIKI = shift; |
36 |
use Cwd qw(abs_path); |
use FindBin q($Bin); |
37 |
|
use File::Spec; |
38 |
|
|
39 |
## -- Filesystem path mapping |
## -- Filesystem path mapping |
40 |
for ( |
for ( |
41 |
[db__cache__dir => q"./wikidata/lock/"], |
[db__cache__dir => q"./wikidata/cache/"], |
42 |
[db__cache_struct__file => q"./wikidata/lock/struct.db"], |
[db__cache_struct__file => q"./wikidata/cache/struct.db"], |
43 |
[db__content__dir => q"./wikidata/page/"], |
[db__content__dir => q"./wikidata/page/"], |
44 |
[db__content__error_log => q"./wikidata/log/db-content.log"], |
[db__content__error_log => q"./wikidata/log/db-content.log"], |
45 |
[db__bdb__home_dir => q"./wikidata/lock/"], |
[db__bdb__home_dir => q"./wikidata/lock/"], |
50 |
[db__lock__log_file => q"./wikidata/log/lock.log"], |
[db__lock__log_file => q"./wikidata/log/lock.log"], |
51 |
[db__log__dir => q"./wikidata/log/"], |
[db__log__dir => q"./wikidata/log/"], |
52 |
[db__temp__dir => q"./wikidata/lock/"], |
[db__temp__dir => q"./wikidata/lock/"], |
53 |
|
# [namazu__index_dir => q"/var/namazu/index/wiki"], |
54 |
) { |
) { |
55 |
## On system that does not set current directory as main script |
## On system that does not set current directory as main script |
56 |
## directory, you should specify it instead of using "abs_path". |
## directory, you should specify it instead of using "abs_path". |
57 |
$WIKI->{config}->{path_to}->{$_->[0]} = abs_path $_->[1]; |
$WIKI->{config}->{path_to}->{$_->[0]} = File::Spec->rel2abs ($_->[1], $Bin); |
58 |
} |
} |
59 |
|
|
60 |
|
=begin comment |
61 |
|
|
62 |
|
## -- Namazu URI Mapping (See SuikaWiki:SuikaWiki//Namazu) -- |
63 |
|
$WIKI->{config}->{nmz__uri_to_uri} = sub { |
64 |
|
my ($nmzuri, %opt) = @_; |
65 |
|
if ($nmzuri =~ s!^\Q$opt{o}->{wiki}->{config}->{path_to}->{db__content__dir}\E/*!!o) { |
66 |
|
$nmzuri =~ s/\.txt$//; |
67 |
|
return $opt{o}->{wiki}->uri_reference |
68 |
|
(page => $opt{o}->{wiki}->name ([ |
69 |
|
map {s/([0-9A-F][0-9A-F])/pack 'C', hex $1/ge; $_} |
70 |
|
split m!\.ns/!, $nmzuri |
71 |
|
]), base => 1); |
72 |
|
} else { |
73 |
|
return ($nmzuri, $nmzuri); |
74 |
|
} |
75 |
|
}; |
76 |
|
|
77 |
|
=end comment |
78 |
|
|
79 |
|
=cut |
80 |
|
|
81 |
## -- WikiPlugin |
## -- WikiPlugin |
82 |
push @{$WIKI->{event}->{plugin_manager_loaded}}, sub { |
push @{$WIKI->{event}->{plugin_manager_loaded}}, sub { |
83 |
my $wiki = shift; |
my $wiki = shift; |
102 |
|
|
103 |
## Main content |
## Main content |
104 |
$wiki->{db}->_set_prop_db (content => {-db_open => sub { |
$wiki->{db}->_set_prop_db (content => {-db_open => sub { |
105 |
require SuikaWiki::DB::FileSystem::YukiWikiDBNS; |
require SuikaWiki::DB::FileSystem::LeafFile; |
106 |
SuikaWiki::DB::FileSystem::YukiWikiDBNS->new |
SuikaWiki::DB::FileSystem::LeafFile->new |
107 |
(directory => $wiki->{config}->{path_to}->{db__content__dir}, |
(base_directory => $wiki->{config}->{path_to}->{db__content__dir}, |
108 |
logfile => $wiki->{config}->{path_to}->{db__content__error_log}, |
directory_suffix => '.ns', |
109 |
suffix => '.txt', |
file_suffix => '.txt', |
110 |
|
root_key => $wiki->{config}->{page}->{Default}, |
111 |
-lock => $wiki->{var}->{db}->{lock_prop}->('content')); |
-lock => $wiki->{var}->{db}->{lock_prop}->('content')); |
112 |
}, -db_close => sub { |
}, -db_close => sub { |
113 |
my %opt = @_; |
my %opt = @_; |
115 |
delete $opt{prop_info}->{-db}; |
delete $opt{prop_info}->{-db}; |
116 |
}}); |
}}); |
117 |
|
|
118 |
|
## Properties |
119 |
|
$wiki->{db}->_set_prop_db (content_prop => {-db_open => sub { |
120 |
|
require SuikaWiki::DB::FileSystem::LeafProp; |
121 |
|
SuikaWiki::DB::FileSystem::LeafProp->new |
122 |
|
(base_directory => $wiki->{config}->{path_to}->{db__content__dir}, |
123 |
|
directory_suffix => '.ns', |
124 |
|
file_suffix => '.prop', |
125 |
|
root_key => $wiki->{config}->{page}->{Default}, |
126 |
|
-lock => $wiki->{var}->{db}->{lock_prop}->('content_prop')); |
127 |
|
}, -db_close => sub { |
128 |
|
my %opt = @_; |
129 |
|
$opt{prop_info}->{-db}->close; |
130 |
|
delete $opt{prop_info}->{-db}; |
131 |
|
}}); |
132 |
|
|
133 |
## Last modified |
## Last modified |
134 |
$wiki->{db}->_set_prop_db (lastmodified => {-db_open => sub { |
$wiki->{db}->_set_prop_db (lastmodified => {-db_open => sub { |
135 |
require SuikaWiki::DB::FileSystem::SuikaWikiMetaInfo09; |
require SuikaWiki::DB::FileSystem::SuikaWikiMetaInfo09; |
145 |
## Cache DBs |
## Cache DBs |
146 |
require SuikaWiki::DB::FileSystem::SuikaWikiCache09; |
require SuikaWiki::DB::FileSystem::SuikaWikiCache09; |
147 |
my $cachedb = SuikaWiki::DB::FileSystem::SuikaWikiCache09->new |
my $cachedb = SuikaWiki::DB::FileSystem::SuikaWikiCache09->new |
148 |
(directory => $wiki->{config}->{path_to}->{db__cache__dir}); |
(directory => $wiki->{config}->{path_to}->{db__cache__dir}, |
149 |
|
expires => 86400 * 3, removes => 86400 * 3); # 3 days |
150 |
$wiki->{db}->_set_prop_db (m__search_result => |
$wiki->{db}->_set_prop_db (m__search_result => |
151 |
{-db => $cachedb, -prop => 'search_result', -db_close => sub { |
{-db => $cachedb, -prop => 'search_result', -db_close => sub { |
152 |
my %opt = @_; |
my %opt = @_; |
166 |
delete $opt{prop_info}->{-db}; |
delete $opt{prop_info}->{-db}; |
167 |
}}); |
}}); |
168 |
|
|
|
## 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; |
|
|
}; |
|
|
}}); |
|
|
|
|
169 |
## Referer Database (See Referer plugin module) |
## Referer Database (See Referer plugin module) |
170 |
$wiki->{db}->_set_prop_db (referer => {-db_open => sub { |
$wiki->{db}->_set_prop_db (referer => {-db_open => sub { |
171 |
require SuikaWiki::DB::Hash; |
require SuikaWiki::DB::FileSystem::Count; |
172 |
new SuikaWiki::DB::Hash constructor => sub { |
SuikaWiki::DB::FileSystem::Count->new |
173 |
tie my %db, 'BerkeleyDB::Hash', |
(base_directory => $wiki->{config}->{path_to}->{db__content__dir}, |
174 |
-Filename => 'referer.db', |
directory_suffix => '.ns', |
175 |
-Env => $bdbenv, |
file_suffix => '.ref', |
176 |
-Flags => DB_CREATE, |
root_key => $wiki->{config}->{page}->{Default}, |
177 |
-Mode => 0644; |
auto_mkdir => 0, |
178 |
\%db; |
-lock => $wiki->{var}->{db}->{lock_prop}->('referer')); |
179 |
}; |
}, -db_close => sub { |
180 |
|
my %opt = @_; |
181 |
|
$opt{prop_info}->{-db}->close; |
182 |
|
delete $opt{prop_info}->{-db}; |
183 |
}}); |
}}); |
184 |
|
|
|
## 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; |
|
|
}; |
|
|
}}); |
|
|
|
|
185 |
## Additional WikiDB properties should be defined here |
## Additional WikiDB properties should be defined here |
186 |
# ... |
# ... |
187 |
}; |
}; |
188 |
|
|
|
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'; |
|
|
}; |
|
|
}; |
|
|
|
|
189 |
## -- WikiName of special purpose WikiPages |
## -- WikiName of special purpose WikiPages |
190 |
$WIKI->{config}->{page} = { |
$WIKI->{config}->{page} = { |
191 |
Default => $WIKI->name ([qw/HomePage/]), |
Default => $WIKI->name ([qw/HomePage/]), |
200 |
separator_reg => qr#\s*//\s*#, |
separator_reg => qr#\s*//\s*#, |
201 |
self => '.', |
self => '.', |
202 |
parent => '..', |
parent => '..', |
203 |
|
root => '//', |
204 |
}; |
}; |
205 |
|
|
206 |
## -- Default character codes |
## -- Default character codes |
220 |
uri_fragment => 'x-punycode', ## Reserved for possible future use |
uri_fragment => 'x-punycode', ## Reserved for possible future use |
221 |
}; |
}; |
222 |
|
|
223 |
|
## -- User option for media types |
224 |
|
$WIKI->{config}->{ExpandedURI q<media-type:accept-media-type>} = { |
225 |
|
q<IMT:text/css##> => 1, |
226 |
|
q<IMT:text/plain##> => 1, |
227 |
|
q<IMT:text/x-suikawiki;version="0.9"##> => 1, |
228 |
|
q<IMT:application/x.suikawiki.config;version="2.0"##> => 1, |
229 |
|
}; |
230 |
|
|
231 |
## -- Expires duration templates |
## -- Expires duration templates |
232 |
$WIKI->{config}->{entity}->{expires} = { |
$WIKI->{config}->{entity}->{expires} = { |
233 |
edit => {delta => 60}, |
edit => {delta => 60}, |
234 |
view => {delta => 2*3600}, |
view => {delta => 2*3600}, |
235 |
|
list => {delta => 60}, |
236 |
lm_flaged => {delta => 30*24*3600}, |
lm_flaged => {delta => 30*24*3600}, |
237 |
stylesheet => {delta => 30*24*3600}, |
stylesheet => {delta => 30*24*3600}, |
238 |
error => {delta => 60}, |
error => {delta => 60}, |