summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-07-04 10:50:36 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-07-04 10:50:36 +0800
commit07ba1ee3d555817b56dcfc35618d170ff2359277 (patch)
tree5cfe23d609316f02d8eee2536ad07af9414c0e5a
parent3b9ca23f6101423bfe6dc3eadfde925484aeea77 (diff)
downloadpttbbs-07ba1ee3d555817b56dcfc35618d170ff2359277.tar
pttbbs-07ba1ee3d555817b56dcfc35618d170ff2359277.tar.gz
pttbbs-07ba1ee3d555817b56dcfc35618d170ff2359277.tar.bz2
pttbbs-07ba1ee3d555817b56dcfc35618d170ff2359277.tar.lz
pttbbs-07ba1ee3d555817b56dcfc35618d170ff2359277.tar.xz
pttbbs-07ba1ee3d555817b56dcfc35618d170ff2359277.tar.zst
pttbbs-07ba1ee3d555817b56dcfc35618d170ff2359277.zip
build .idx from .db
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@1015 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rwxr-xr-xstaticweb/manbuilder.pl29
1 files 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{$_});
}
}