#!/bin/perl5 # this is a customizable output filter for swish output. # also reads "hidden" config info from the form # use CGI::Carp; #$debug = 1; $_ = 1; #unbuffered out print STDERR "Content-type: text/html\n\n"; # Grab the cgi routines require "/usr/local/lib/perl/cgi/cgilib.pl"; # Get the template library too #use Text::Template; # Read form input into %in and @in &ReadParse; # Required Vars ($in{'index'}) || die 'No swish index passed. Set hidden var "index"'; ($in{'words'}) || die 'Please enter some search words'; ($in{'template'}) || die 'No template passed. Set hidden var "template"'; (-f $in{'index'}) || die "swish index $in{'index'} not found."; (-f $in{'template'}) || die "template $in{'template'} not found."; # Optional vars ($in{'max'}) && ($max = '-m ' . $in{'max'}); ($in{'tags'}) && ($tags = '-t ' . $in{'tags'}); $words = $in{'words'}; # Get the results! ($debug) && print("
/usr/local/bin/swish -f $in{'index'} $max $tags -w $in{'words'}|");
open(TPL,"$in{'template'}");
while() {
if (/\{FORMAT(.*)\}/) {
my $xformat = $1;
&format($xformat);
next;
}
if (/\$/) {
eval "print \"$_\"" ;
next;
}
print;
}
close(TPL);
($debug) && (print "