summaryrefslogtreecommitdiffstats
path: root/staticweb/man.pl
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-07-03 21:49:07 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-07-03 21:49:07 +0800
commit599e2d345abf7620f9e3e6510a97b0ac3083a356 (patch)
tree3b8f3a93a567206cf36d8d8beffda97cd64e110f /staticweb/man.pl
parent07b372e069e5fb4f33825837096754517a861e28 (diff)
downloadpttbbs-599e2d345abf7620f9e3e6510a97b0ac3083a356.tar
pttbbs-599e2d345abf7620f9e3e6510a97b0ac3083a356.tar.gz
pttbbs-599e2d345abf7620f9e3e6510a97b0ac3083a356.tar.bz2
pttbbs-599e2d345abf7620f9e3e6510a97b0ac3083a356.tar.lz
pttbbs-599e2d345abf7620f9e3e6510a97b0ac3083a356.tar.xz
pttbbs-599e2d345abf7620f9e3e6510a97b0ac3083a356.tar.zst
pttbbs-599e2d345abf7620f9e3e6510a97b0ac3083a356.zip
search support
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@1010 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'staticweb/man.pl')
-rwxr-xr-xstaticweb/man.pl29
1 files changed, 26 insertions, 3 deletions
diff --git a/staticweb/man.pl b/staticweb/man.pl
index db5b84d5..e9e45a2a 100755
--- a/staticweb/man.pl
+++ b/staticweb/man.pl
@@ -1,5 +1,5 @@
#!/usr/bin/perl
-# $Id: man.pl,v 1.2 2003/07/03 12:39:05 in2 Exp $
+# $Id: man.pl,v 1.3 2003/07/03 13:49:07 in2 Exp $
use CGI qw/:standard/;
use lib qw/./;
use LocalVars;
@@ -15,7 +15,7 @@ use vars qw/%db $brdname $fpath/;
sub main
{
- my($tmpl, $rh);
+ my($tmpl, $rh, $key);
if( !(($brdname, $fpath) = $ENV{PATH_INFO} =~ m|^/([\w\-]+?)(/.*)|) ||
!(tie %db, 'DB_File',
@@ -29,7 +29,12 @@ sub main
charset('');
print header();
- $rh = (($fpath =~ m|/$|) ? dirmode($fpath) : articlemode($fpath));
+ if( ($key = param('key')) ){
+ $rh = search($key);
+ }
+ else{
+ $rh = (($fpath =~ m|/$|) ? dirmode($fpath) : articlemode($fpath));
+ }
$rh->{brdname} = $brdname;
$tmpl = Template->new({INCLUDE_PATH => '.',
ABSOLUTE => 0,
@@ -68,5 +73,23 @@ sub articlemode
return \%th;
}
+sub search($)
+{
+ my($key) = @_;
+ my(%th, $idx, $k);
+ $idx = OurNet::FuzzyIndex->new("$MANDATA/$brdname.idx");
+ my %result = $idx->query($th{key} = $key, MATCH_FUZZY);
+ foreach my $t (sort { $result{$b} <=> $result{$a} } keys(%result)) {
+ $k = $idx->getkey($t);
+ push @{$th{search}}, {title => $db{"title-$k"},
+ fn => $k,
+ score => $result{$t} / 10};
+ }
+
+ $th{key} = $key;
+ $th{tmpl} = 'search.html';
+ return \%th;
+}
+
main();
1;