27 |
} |
} |
28 |
use Message::Util::Error; |
use Message::Util::Error; |
29 |
|
|
30 |
|
use Message::Util::QName::General [q<ExpandedURI>], { |
31 |
|
'log' => q<http://suika.fam.cx/~wakaba/-temp/2004/05/01/reqlog#>, |
32 |
|
'media-type' => q<http://suika.fam.cx/~wakaba/-temp/2004/04/24/mt#>, |
33 |
|
}; |
34 |
|
|
35 |
|
BEGIN { |
36 |
|
if ($main::ENV{REQUEST_URI} =~ /\#/) { |
37 |
|
require SuikaWiki::Output::HTTP; |
38 |
|
my $out = SuikaWiki::Output::HTTP->new; |
39 |
|
$out->{status_code} = 401; |
40 |
|
$out->{status_phrase} = q<Request-URI MUST NOT have Fragment Identifier>; |
41 |
|
$out->{entity}->{media_type} = q<text/html>; |
42 |
|
$out->{entity}->{charset} = q<iso-8859-1>; |
43 |
|
$out->{entity}->{language} = [q<en>]; |
44 |
|
$out->{entity}->{body_is_octet_stream} = 1; |
45 |
|
my $ua = $main::ENV{HTTP_USER_AGENT}; |
46 |
|
for ($ua) { |
47 |
|
s/&/&/g; s/</</g; s/([^\x20-\x7E])/sprintf '&#x%02X;', ord $1/ge; |
48 |
|
}; |
49 |
|
$out->{entity}->{body} = qq< |
50 |
|
<!DOCTYPE html SYSTEM> |
51 |
|
<title>401 Bad Request-URI</title> |
52 |
|
<h1>Bad Request-URI</h1> |
53 |
|
<p>Your Request-URI has fragment identifier but it is not allowed here. |
54 |
|
It might be a bug of your user agent ($ua). Please contact to the UA |
55 |
|
vendor.</p> |
56 |
|
>; |
57 |
|
$out->output (output => 'http-cgi'); |
58 |
|
exit; |
59 |
|
} |
60 |
|
} |
61 |
|
|
62 |
push our @Config, sub ($) { |
push our @Config, sub ($) { |
63 |
my $WIKI = shift; |
my $WIKI = shift; |
64 |
use Cwd qw(abs_path); |
use FindBin q($Bin); |
65 |
|
use File::Spec; |
66 |
|
|
67 |
## -- Filesystem path mapping |
## -- Filesystem path mapping |
68 |
for ( |
for ( |
69 |
[db__cache__dir => q"./wikidata/lock/"], |
[db__cache__dir => q"./wikidata/cache/"], |
70 |
[db__cache_struct__file => q"./wikidata/lock/struct.db"], |
[db__cache_struct__file => q"./wikidata/cache/struct.db"], |
71 |
[db__content__dir => q"./wikidata/page/"], |
[db__content__dir => q"./wikidata/page/"], |
72 |
[db__content__error_log => q"./wikidata/log/db-content.log"], |
[db__content__error_log => q"./wikidata/log/db-content.log"], |
73 |
[db__bdb__home_dir => q"./wikidata/lock/"], |
[db__bdb__home_dir => q"./wikidata/lock/"], |
77 |
[db__lock__dir => q"./wikidata/lock/"], |
[db__lock__dir => q"./wikidata/lock/"], |
78 |
[db__lock__log_file => q"./wikidata/log/lock.log"], |
[db__lock__log_file => q"./wikidata/log/lock.log"], |
79 |
[db__log__dir => q"./wikidata/log/"], |
[db__log__dir => q"./wikidata/log/"], |
80 |
|
[db__request_log__dir => q"./wikidata/rlog/"], |
81 |
[db__temp__dir => q"./wikidata/lock/"], |
[db__temp__dir => q"./wikidata/lock/"], |
82 |
[namazu__index_dir => q"/var/namazu/index/suikawiki"], |
[namazu__index_dir => q"/var/namazu/index/suikawiki"], |
83 |
) { |
) { |
84 |
## On system that does not set current directory as main script |
## On system that does not set current directory as main script |
85 |
## directory, you should specify it instead of using "abs_path". |
## directory, you should specify it instead of using "abs_path". |
86 |
$WIKI->{config}->{path_to}->{$_->[0]} = abs_path $_->[1]; |
$WIKI->{config}->{path_to}->{$_->[0]} = File::Spec->catfile ($Bin, $_->[1]); |
87 |
} |
} |
88 |
|
|
89 |
## -- Namazu URI Mapping (See SuikaWiki:SuikaWiki//Namazu) -- |
## -- Namazu URI Mapping (See SuikaWiki:SuikaWiki//Namazu) -- |
126 |
|
|
127 |
## Main content |
## Main content |
128 |
$wiki->{db}->_set_prop_db (content => {-db_open => sub { |
$wiki->{db}->_set_prop_db (content => {-db_open => sub { |
129 |
require SuikaWiki::DB::FileSystem::YukiWikiDBNS; |
require SuikaWiki::DB::FileSystem::LeafFile; |
130 |
SuikaWiki::DB::FileSystem::YukiWikiDBNS->new |
SuikaWiki::DB::FileSystem::LeafFile->new |
131 |
(directory => $wiki->{config}->{path_to}->{db__content__dir}, |
(base_directory => $wiki->{config}->{path_to}->{db__content__dir}, |
132 |
logfile => $wiki->{config}->{path_to}->{db__content__error_log}, |
directory_suffix => '.ns', |
133 |
suffix => '.txt', |
file_suffix => '.txt', |
134 |
root_key => $wiki->{config}->{page}->{Default}, |
root_key => $wiki->{config}->{page}->{Default}, |
135 |
|
-lock => $wiki->{var}->{db}->{lock_prop}->('content_prop')); |
136 |
|
}, -db_close => sub { |
137 |
|
my %opt = @_; |
138 |
|
$opt{prop_info}->{-db}->close; |
139 |
|
delete $opt{prop_info}->{-db}; |
140 |
|
}}); |
141 |
|
|
142 |
|
## Properties |
143 |
|
$wiki->{db}->_set_prop_db (content_prop => {-db_open => sub { |
144 |
|
require SuikaWiki::DB::FileSystem::LeafProp; |
145 |
|
SuikaWiki::DB::FileSystem::LeafProp->new |
146 |
|
(base_directory => $wiki->{config}->{path_to}->{db__content__dir}, |
147 |
|
directory_suffix => '.ns', |
148 |
|
file_suffix => '.prop', |
149 |
|
root_key => $wiki->{config}->{page}->{Default}, |
150 |
-lock => $wiki->{var}->{db}->{lock_prop}->('content')); |
-lock => $wiki->{var}->{db}->{lock_prop}->('content')); |
151 |
}, -db_close => sub { |
}, -db_close => sub { |
152 |
my %opt = @_; |
my %opt = @_; |
219 |
|
|
220 |
## Referer Database (See Referer plugin module) |
## Referer Database (See Referer plugin module) |
221 |
$wiki->{db}->_set_prop_db (referer => {-db_open => sub { |
$wiki->{db}->_set_prop_db (referer => {-db_open => sub { |
222 |
require SuikaWiki::DB::Hash; |
require SuikaWiki::DB::FileSystem::Count; |
223 |
new SuikaWiki::DB::Hash constructor => sub { |
SuikaWiki::DB::FileSystem::Count->new |
224 |
tie my %db, 'BerkeleyDB::Hash', |
(base_directory => $wiki->{config}->{path_to}->{db__content__dir}, |
225 |
-Filename => 'referer.db', |
directory_suffix => '.ns', |
226 |
-Env => $bdbenv, |
file_suffix => '.ref', |
227 |
-Flags => DB_CREATE, |
root_key => $wiki->{config}->{page}->{Default}, |
228 |
-Mode => 0644; |
auto_mkdir => 0, |
229 |
\%db; |
-lock => $wiki->{var}->{db}->{lock_prop}->('referer')); |
230 |
}; |
}, -db_close => sub { |
231 |
|
my %opt = @_; |
232 |
|
$opt{prop_info}->{-db}->close; |
233 |
|
delete $opt{prop_info}->{-db}; |
234 |
}}); |
}}); |
235 |
|
|
236 |
## HTTP Request Logging Database (See RequestLog plugin module) |
## HTTP Request Logging Database (See RequestLog plugin module) |
237 |
$wiki->{db}->_set_prop_db (log__http_request => {-db_open => sub { |
$wiki->{db}->_set_prop_db (log__http_request => {-db_open => sub { |
238 |
require SuikaWiki::DB::Hash; |
require SuikaWiki::DB::FileSystem::Count; |
239 |
new SuikaWiki::DB::Hash constructor => sub { |
SuikaWiki::DB::FileSystem::Count->new |
240 |
tie my %db, 'BerkeleyDB::Hash', |
(base_directory => $wiki->{config}->{path_to}->{db__request_log__dir}, |
241 |
-Filename => 'http-request-log.db', |
directory_suffix => '.ns', |
242 |
-Env => $bdbenv, |
file_suffix => '.rlog', |
243 |
-Flags => DB_CREATE, |
root_key => $wiki->{config}->{page}->{Default}, |
244 |
-Mode => 0644; |
auto_mkdir => 1); |
245 |
\%db; |
}, -db_close => sub { |
246 |
}; |
my %opt = @_; |
247 |
|
$opt{prop_info}->{-db}->close; |
248 |
|
delete $opt{prop_info}->{-db}; |
249 |
}}); |
}}); |
250 |
|
|
251 |
## Additional WikiDB properties should be defined here |
## Additional WikiDB properties should be defined here |
255 |
push @{$WIKI->{event}->{input_close}}, sub { |
push @{$WIKI->{event}->{input_close}}, sub { |
256 |
my ($wiki, $event) = @_; |
my ($wiki, $event) = @_; |
257 |
try { |
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 { |
|
258 |
SuikaWiki::Plugin->module_package ('RequestLog') |
SuikaWiki::Plugin->module_package ('RequestLog') |
259 |
->http_request_log (wiki => $wiki, |
->http_request_log (wiki => $wiki, |
260 |
prop => 'log__http_request'); |
prop => 'log__http_request'); |
270 |
InterWikiName => $WIKI->name ([qw/Wiki InterWikiName/]), |
InterWikiName => $WIKI->name ([qw/Wiki InterWikiName/]), |
271 |
NewPageTemplate => $WIKI->name ([qw/Wiki NewPageTemplate/]), |
NewPageTemplate => $WIKI->name ([qw/Wiki NewPageTemplate/]), |
272 |
'StyleSheetList(text/html)' => $WIKI->name ([qw<Wiki Style List text/html>]), |
'StyleSheetList(text/html)' => $WIKI->name ([qw<Wiki Style List text/html>]), |
273 |
|
ExpandedURI q<log:root> => $WIKI->name ([]), |
274 |
}; |
}; |
275 |
|
|
276 |
## -- WikiNamespace constants |
## -- WikiNamespace constants |
298 |
## Fragment identifier in URI reference |
## Fragment identifier in URI reference |
299 |
uri_fragment => 'x-punycode', ## Reserved for possible future use |
uri_fragment => 'x-punycode', ## Reserved for possible future use |
300 |
}; |
}; |
301 |
|
|
302 |
|
## -- User option for media types |
303 |
|
$WIKI->{config}->{ExpandedURI q<media-type:accept-media-type>} = { |
304 |
|
q<IMT:text/css##> => 1, |
305 |
|
q<IMT:text/plain##> => 1, |
306 |
|
q<IMT:text/x-suikawiki;version="0.9"##> => 1, |
307 |
|
q<IMT:application/x.suikawiki.config;version="2.0"##> => 1, |
308 |
|
}; |
309 |
|
|
310 |
## -- Expires duration templates |
## -- Expires duration templates |
311 |
$WIKI->{config}->{entity}->{expires} = { |
$WIKI->{config}->{entity}->{expires} = { |