added --hyperestraier switch, which turns on search support

(ok, the way I run estseek.cgi is admittedly pretty nasty, but it works..)
master
joey 2006-03-29 22:21:23 +00:00
parent a4eaf05620
commit 0d9539d577
12 changed files with 144 additions and 4 deletions

View File

@ -475,12 +475,22 @@ sub cgi_editpage ($$) { #{{{
} }
} #}}} } #}}}
sub cgi_hyperestraier () { #{{{
# only works for GET requests
chdir("$config{wikistatedir}/hyperestraier") || error("chdir: $!");
exec("./".basename($config{cgiurl})) || error("estseek.cgi failed");
} #}}}
sub cgi () { #{{{ sub cgi () { #{{{
eval q{use CGI}; eval q{use CGI};
eval q{use CGI::Session}; eval q{use CGI::Session};
my $q=CGI->new; my $q=CGI->new;
if (defined $q->param('phrase')) {
cgi_hyperestraier();
}
my $do=$q->param('do'); my $do=$q->param('do');
if (! defined $do || ! length $do) { if (! defined $do || ! length $do) {
error("\"do\" parameter missing"); error("\"do\" parameter missing");
@ -491,6 +501,9 @@ sub cgi () { #{{{
cgi_recentchanges($q); cgi_recentchanges($q);
return; return;
} }
elsif ($do eq 'hyperestraier') {
cgi_hyperestraier();
}
CGI::Session->name("ikiwiki_session_$config{wikiname}"); CGI::Session->name("ikiwiki_session_$config{wikiname}");

View File

@ -214,6 +214,9 @@ sub genpage ($$$) { #{{{
$u=~s/\[\[file\]\]/$pagesources{$page}/g; $u=~s/\[\[file\]\]/$pagesources{$page}/g;
$template->param(historyurl => $u); $template->param(historyurl => $u);
} }
if ($config{hyperestraier}) {
$template->param(hyperestraierurl => cgiurl());
}
if ($config{rss} && $inlinepages{$page}) { if ($config{rss} && $inlinepages{$page}) {
$template->param(rssurl => rsspage(basename($page))); $template->param(rssurl => rsspage(basename($page)));
@ -381,6 +384,56 @@ sub prune ($) { #{{{
} }
} #}}} } #}}}
sub estcfg () { #{{{
my $estdir="$config{wikistatedir}/hyperestraier";
my $cgi=basename($config{cgiurl});
$cgi=~s/\..*$//;
open(TEMPLATE, ">$estdir/$cgi.tmpl") ||
error("write $estdir/$cgi.tmpl: $!");
print TEMPLATE misctemplate("search",
"<!--ESTFORM-->\n\n<!--ESTRESULT-->\n\n<!--ESTINFO-->\n\n");
close TEMPLATE;
open(TEMPLATE, ">$estdir/$cgi.conf") ||
error("write $estdir/$cgi.conf: $!");
my $template=HTML::Template->new(
filename => "$config{templatedir}/estseek.conf"
);
eval q{use Cwd 'abs_path'};
$template->param(
index => $estdir,
tmplfile => "$estdir/$cgi.tmpl",
destdir => abs_path($config{destdir}),
url => $config{url},
);
print TEMPLATE $template->output;
close TEMPLATE;
symlink("/usr/lib/estraier/estseek.cgi",
"$estdir/".basename($config{cgiurl})) ||
error("symlink: $!");
} # }}}
sub estcmd ($;@) { #{{{
my @params=split(' ', shift);
push @params, "-cl", "$config{wikistatedir}/hyperestraier";
if (@_) {
push @params, "-";
}
my $pid=open(CHILD, "|-");
if ($pid) {
# parent
foreach (@_) {
print CHILD "$_\n";
}
close(CHILD) || error("estcmd @params exited nonzero: $?");
}
else {
# child
open(STDOUT, "/dev/null"); # shut it up (closing won't work)
exec("estcmd", @params) || error("can't run estcmd");
}
} #}}}
sub refresh () { #{{{ sub refresh () { #{{{
# find existing pages # find existing pages
my %exists; my %exists;
@ -505,6 +558,7 @@ FILE: foreach my $file (@files) {
if (globlist_match($page, $inlinepages{$p})) { if (globlist_match($page, $inlinepages{$p})) {
debug("rendering $f, which inlines $page"); debug("rendering $f, which inlines $page");
render($f); render($f);
$rendered{$f}=1;
last; last;
} }
} }
@ -539,9 +593,25 @@ FILE: foreach my $file (@files) {
if (defined $linkfile) { if (defined $linkfile) {
debug("rendering $linkfile, to update its backlinks"); debug("rendering $linkfile, to update its backlinks");
render($linkfile); render($linkfile);
$rendered{$linkfile}=1;
} }
} }
} }
if ($config{hyperestraier} && (%rendered || @del)) {
debug("updating hyperestraier search index");
if (%rendered) {
estcmd("gather -cm -bc -cl -sd",
map { $config{destdir}."/".$renderedfiles{pagename($_)} }
keys %rendered);
}
if (@del) {
estcmd("purge -cl");
}
debug("generating hyperestraier cgi config");
estcfg();
}
} #}}} } #}}}
1 1

View File

@ -1,11 +1,11 @@
#header h1 { #header h1 {
margin: 0; margin: 0;
padding: 2px 0; padding: 0 0;
} }
#actions ul { #actions ul {
margin: 0; margin: 0;
padding: 2px; padding: 6px;
list-style-type: none; list-style-type: none;
border-bottom: 1px solid #000; border-bottom: 1px solid #000;
} }
@ -15,6 +15,11 @@
padding: .2em .4em; padding: .2em .4em;
} }
#searchform {
display: inline;
float: right;
}
#content { #content {
border-bottom: 1px solid #000; border-bottom: 1px solid #000;
} }
@ -23,8 +28,8 @@
#blogform { #blogform {
padding: 10px 10px; padding: 10px 10px;
border: 1px solid #aaa; border: 1px solid #aaa;
color: black !important;;
background: #eee; background: #eee;
color: black !important;
} }
#backlinks { #backlinks {

2
debian/control vendored
View File

@ -8,7 +8,7 @@ Standards-Version: 3.6.2
Package: ikiwiki Package: ikiwiki
Architecture: all Architecture: all
Depends: ${perl:Depends}, markdown, libhtml-template-perl, libcgi-formbuilder-perl, libtime-duration-perl, libcgi-session-perl, libmail-sendmail-perl, gcc | c-compiler Depends: ${perl:Depends}, markdown, libhtml-template-perl, libcgi-formbuilder-perl, libtime-duration-perl, libcgi-session-perl, libmail-sendmail-perl, gcc | c-compiler
Recommends: subversion Recommends: subversion, hyperestraier
Suggests: viewcvs Suggests: viewcvs
Description: a wiki compiler Description: a wiki compiler
ikiwiki converts a directory full of wiki pages into html pages suitable ikiwiki converts a directory full of wiki pages into html pages suitable

View File

@ -102,6 +102,11 @@ Currently implemented:
Wiki admins can lock pages so that only other admins can edit them. Wiki admins can lock pages so that only other admins can edit them.
* Full text search
ikiwiki can use the [[HyperEstraier]] search engine to add powerful
full text search capabilities to your wiki.
---- ----
It also has some [[TODO]] items and [[Bugs]]. It also has some [[TODO]] items and [[Bugs]].

View File

@ -46,4 +46,6 @@ use IkiWiki::Setup::Standard {
#anonok => 1, #anonok => 1,
# Generate rss feeds for pages? # Generate rss feeds for pages?
rss => 1, rss => 1,
# Use the Hyper Estraier search engine?
#hyperestraier => 1,
} }

View File

@ -143,6 +143,11 @@ These options configure the wiki.
Currently allows locking of any page, other powers may be added later. Currently allows locking of any page, other powers may be added later.
May be specified multiple times for multiple admins. May be specified multiple times for multiple admins.
* --hyperestraier
Enables use of the [[HyperEstraier]] search engine for full test page
searches.
* --verbose * --verbose
Be vebose about what it's doing. Be vebose about what it's doing.

View File

@ -36,6 +36,7 @@ sub getconfig () { #{{{
rebuild => 0, rebuild => 0,
refresh => 0, refresh => 0,
getctime => 0, getctime => 0,
hyperestraier => 0,
wrapper => undef, wrapper => undef,
wrappermode => undef, wrappermode => undef,
srcdir => undef, srcdir => undef,
@ -57,6 +58,7 @@ sub getconfig () { #{{{
"wrappermode=i" => \$config{wrappermode}, "wrappermode=i" => \$config{wrappermode},
"svn!" => \$config{svn}, "svn!" => \$config{svn},
"anonok!" => \$config{anonok}, "anonok!" => \$config{anonok},
"hyperestraier" => \$config{hyperestraier},
"rss!" => \$config{rss}, "rss!" => \$config{rss},
"cgi!" => \$config{cgi}, "cgi!" => \$config{cgi},
"url=s" => \$config{url}, "url=s" => \$config{url},
@ -102,6 +104,9 @@ sub checkconfig () { #{{{
if ($config{rss} && ! length $config{url}) { if ($config{rss} && ! length $config{url}) {
error("Must specify url to wiki with --url when using --rss\n"); error("Must specify url to wiki with --url when using --rss\n");
} }
if ($config{hyperestraier} && ! length $config{url}) {
error("Must specify --url when using --hyperestraier\n");
}
$config{wikistatedir}="$config{srcdir}/.ikiwiki" $config{wikistatedir}="$config{srcdir}/.ikiwiki"
unless exists $config{wikistatedir}; unless exists $config{wikistatedir};

View File

@ -0,0 +1,21 @@
indexname: <TMPL_VAR INDEX>
tmplfile: <TMPL_VAR TMPLFILE>
topfile: /dev/null
logfile:
replace: ^file://<TMPL_VAR DESTDIR>{{!}}<TMPL_VAR URL>
showreal: false
perpage: 10,20,30,40,50,100
attrselect: false
showscore: false
extattr: date|Date
snipwwidth: 480
sniphwidth: 96
snipawidth: 96
condgstep: 2
dotfidf: true
scancheck: false
smplphrase: true
candetail: true
smlrvnum: 0
clipview: 2
spcache:

View File

@ -8,13 +8,19 @@
</head> </head>
<body> <body>
<div id="header">
<h1> <h1>
<TMPL_VAR INDEXLINK>/ <TMPL_VAR TITLE> <TMPL_VAR INDEXLINK>/ <TMPL_VAR TITLE>
</h1> </h1>
</div>
<div id="content">
<TMPL_VAR PAGEBODY> <TMPL_VAR PAGEBODY>
</div>
<div id="footer">
<!-- from <TMPL_VAR NAME=WIKINAME> --> <!-- from <TMPL_VAR NAME=WIKINAME> -->
</div>
</body> </body>
</html> </html>

View File

@ -15,6 +15,13 @@
</TMPL_LOOP> </TMPL_LOOP>
<TMPL_VAR TITLE> <TMPL_VAR TITLE>
</h1> </h1>
<TMPL_IF NAME="HYPERESTRAIERURL">
<form method="get" action="<TMPL_VAR HYPERESTRAIERURL>" id="searchform">
<input type="text" name="phrase" value="" size="32" />
<input type="submit" value="Search" />
<input type="hidden" name="enc" value="UTF-8" />
<input type="hidden" name="do" value="hyperestraier" />
</TMPL_IF>
</div> </div>
<div id="actions"> <div id="actions">
@ -36,6 +43,7 @@
</TMPL_IF> </TMPL_IF>
<li><TMPL_VAR DISCUSSIONLINK><br /></li> <li><TMPL_VAR DISCUSSIONLINK><br /></li>
</ul> </ul>
</div> </div>