use IkiWiki;
sub import { #{{{
+ hook(type => "getopt", id => "hyperestraier",
+ call => \&getopt);
hook(type => "checkconfig", id => "hyperestraier",
call => \&checkconfig);
hook(type => "pagetemplate", id => "hyperestraier",
call => \&cgi);
} # }}}
+sub getopt () { #{{{
+ eval q{use Getopt::Long};
+ Getopt::Long::Configure('pass_through');
+ GetOptions("estseek=s" => \$config{estseek});
+} #}}}
+
sub checkconfig () { #{{{
foreach my $required (qw(url cgiurl)) {
if (! length $config{$required}) {
debug("updating hyperestraier search index");
estcmd("gather -cm -bc -cl -sd",
map {
- Encode::encode_utf8($config{destdir}."/".$renderedfiles{pagename($_)})
+ Encode::encode_utf8($config{destdir}."/".$_)
+ foreach @{$renderedfiles{pagename($_)}};
} @_
);
estcfg();
my $estdir="$config{wikistatedir}/hyperestraier";
my $cgi=IkiWiki::basename($config{cgiurl});
$cgi=~s/\..*$//;
- open(TEMPLATE, ">$estdir/$cgi.tmpl") ||
+ open(TEMPLATE, ">:utf8", "$estdir/$cgi.tmpl") ||
error("write $estdir/$cgi.tmpl: $!");
print TEMPLATE IkiWiki::misctemplate("search",
"<!--ESTFORM-->\n\n<!--ESTRESULT-->\n\n<!--ESTINFO-->\n\n",
close TEMPLATE;
$cgi="$estdir/".IkiWiki::basename($config{cgiurl});
unlink($cgi);
- symlink("/usr/lib/estraier/estseek.cgi", $cgi) ||
- error("symlink $cgi: $!");
+ my $estseek = defined $config{estseek} ? $config{estseek} : '/usr/lib/estraier/estseek.cgi';
+ symlink($estseek, $cgi) ||
+ error("symlink $estseek $cgi: $!");
} # }}}
sub estcmd ($;@) { #{{{