19 |
|
|
20 |
package wiki::driver::http; |
package wiki::driver::http; |
21 |
use strict; |
use strict; |
22 |
use Message::Util::Error; |
|
23 |
|
## These lines should be removed after utf8 support |
24 |
|
BEGIN { |
25 |
|
$Message::Util::Formatter::Base::Token = qr/[\w._+\x80-\xFF-]+/; |
26 |
|
require Message::Util::Formatter::Base; |
27 |
|
} |
28 |
|
use Message::Util::Error; |
29 |
|
|
30 |
push our @Config, sub ($) { |
push our @Config, sub ($) { |
31 |
my $WIKI = shift; |
my $WIKI = shift; |
45 |
[db__lock__log_file => q"./wikidata/log/lock.log"], |
[db__lock__log_file => q"./wikidata/log/lock.log"], |
46 |
[db__log__dir => q"./wikidata/log/"], |
[db__log__dir => q"./wikidata/log/"], |
47 |
[db__temp__dir => q"./wikidata/lock/"], |
[db__temp__dir => q"./wikidata/lock/"], |
48 |
|
[namazu__index_dir => q"/var/namazu/index/suikawiki"], |
49 |
) { |
) { |
50 |
## On system that does not set current directory as main script |
## On system that does not set current directory as main script |
51 |
## directory, you should specify it instead of using "abs_path". |
## directory, you should specify it instead of using "abs_path". |
52 |
$WIKI->{config}->{path_to}->{$_->[0]} = abs_path $_->[1]; |
$WIKI->{config}->{path_to}->{$_->[0]} = abs_path $_->[1]; |
53 |
} |
} |
54 |
|
|
55 |
|
## -- Namazu URI Mapping (See SuikaWiki:SuikaWiki//Namazu) -- |
56 |
|
$WIKI->{config}->{nmz__uri_to_uri} = sub { |
57 |
|
my ($nmzuri, %opt) = @_; |
58 |
|
if ($nmzuri =~ s!^\Q$opt{o}->{wiki}->{config}->{path_to}->{db__content__dir}\E/*!!o) { |
59 |
|
$nmzuri =~ s/\.txt$//; |
60 |
|
return $opt{o}->{wiki}->uri_reference |
61 |
|
(page => $opt{o}->{wiki}->name ([ |
62 |
|
map {s/([0-9A-F][0-9A-F])/pack 'C', hex $1/ge; $_} |
63 |
|
split m!\.ns/!, $nmzuri |
64 |
|
]), base => 1); |
65 |
|
} else { |
66 |
|
$nmzuri =~ s<^/home/wakaba/public_html/([^.]+)><http://suika.fam.cx/~wakaba/$1>; |
67 |
|
return ($nmzuri, $nmzuri); |
68 |
|
} |
69 |
|
}; |
70 |
|
|
71 |
## -- WikiPlugin |
## -- WikiPlugin |
72 |
push @{$WIKI->{event}->{plugin_manager_loaded}}, sub { |
push @{$WIKI->{event}->{plugin_manager_loaded}}, sub { |
81 |
misc/plugins/link/ |
misc/plugins/link/ |
82 |
misc/plugins/view/ |
misc/plugins/view/ |
83 |
)); |
)); |
84 |
|
|
85 |
## Configuration file as pseudo-plugin module |
## Configuration file as pseudo-plugin module |
86 |
require 'wikidata/config.ph'; |
require 'wikidata/config.ph'; |
87 |
}; |
}; |
119 |
## Cache DBs |
## Cache DBs |
120 |
require SuikaWiki::DB::FileSystem::SuikaWikiCache09; |
require SuikaWiki::DB::FileSystem::SuikaWikiCache09; |
121 |
my $cachedb = SuikaWiki::DB::FileSystem::SuikaWikiCache09->new |
my $cachedb = SuikaWiki::DB::FileSystem::SuikaWikiCache09->new |
122 |
(directory => $wiki->{config}->{path_to}->{db__cache__dir}); |
(directory => $wiki->{config}->{path_to}->{db__cache__dir}, |
123 |
|
expires => 86400 * 3, removes => 86400 * 3); # 3 days |
124 |
$wiki->{db}->_set_prop_db (m__search_result => |
$wiki->{db}->_set_prop_db (m__search_result => |
125 |
{-db => $cachedb, -prop => 'search_result', -db_close => sub { |
{-db => $cachedb, -prop => 'search_result', -db_close => sub { |
126 |
my %opt = @_; |
my %opt = @_; |
139 |
$opt{prop_info}->{-db}->close; |
$opt{prop_info}->{-db}->close; |
140 |
delete $opt{prop_info}->{-db}; |
delete $opt{prop_info}->{-db}; |
141 |
}}); |
}}); |
142 |
|
|
143 |
## Berkely DB Environment Preparation |
## Berkely DB Environment Preparation |
144 |
use BerkeleyDB; |
use BerkeleyDB; |
145 |
my $bdbenv = new BerkeleyDB::Env |
my $bdbenv = new BerkeleyDB::Env |