From 07ba1ee3d555817b56dcfc35618d170ff2359277 Mon Sep 17 00:00:00 2001 From: in2 Date: Fri, 4 Jul 2003 02:50:36 +0000 Subject: build .idx from .db git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@1015 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- staticweb/manbuilder.pl | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/staticweb/manbuilder.pl b/staticweb/manbuilder.pl index a6020357..dda94a8a 100755 --- a/staticweb/manbuilder.pl +++ b/staticweb/manbuilder.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $Id: manbuilder.pl,v 1.7 2003/07/03 14:01:36 in2 Exp $ +# $Id: manbuilder.pl,v 1.8 2003/07/04 02:50:36 in2 Exp $ use lib '/home/bbs/bin/'; use strict; use OurNet::FuzzyIndex; @@ -20,11 +20,28 @@ sub main ); foreach( @ARGV ){ - tie %db, 'DB_File', "$_.db", O_CREAT | O_RDWR, 0666, $DB_HASH; - $idx = OurNet::FuzzyIndex->new("$_.idx") - if( !$Getopt::Std::opt_n ); - build("/home/bbs/man/boards/".substr($_, 0, 1)."/$_", ''); - untie %db; + if( /\.db$/ ){ + next if( $Getopt::Std::opt_n ); + + tie %db, 'DB_File', $_, O_RDONLY, 0666, $DB_HASH; + $idx = OurNet::FuzzyIndex->new(substr($_, 0, -3). '.idx'); + buildidx(); + } + else{ + tie %db, 'DB_File', "$_.db", O_CREAT | O_RDWR, 0666, $DB_HASH; + $idx = OurNet::FuzzyIndex->new("$_.idx") + if( !$Getopt::Std::opt_n ); + build("/home/bbs/man/boards/".substr($_, 0, 1)."/$_", ''); + untie %db; + } + } +} + +sub buildidx +{ + foreach( keys %db ){ + next if( /^title/ || /\/$/ ); # 是 title 或目錄的都跳過 + $idx->insert($_, $db{"title-$_"}. "\n". $db{$_}); } } -- cgit v1.2.3