diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2003-07-03 21:49:07 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2003-07-03 21:49:07 +0800 |
commit | 599e2d345abf7620f9e3e6510a97b0ac3083a356 (patch) | |
tree | 3b8f3a93a567206cf36d8d8beffda97cd64e110f /staticweb | |
parent | 07b372e069e5fb4f33825837096754517a861e28 (diff) | |
download | pttbbs-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')
-rwxr-xr-x | staticweb/man.pl | 29 | ||||
-rw-r--r-- | staticweb/search.html | 40 |
2 files changed, 66 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; diff --git a/staticweb/search.html b/staticweb/search.html new file mode 100644 index 00000000..191c412f --- /dev/null +++ b/staticweb/search.html @@ -0,0 +1,40 @@ +[% INCLUDE header.html %] +<table width="75%" align="center"> +<tr> +<td> +<div id="banner"> + <h1><a href="http://blog.ptt.cc/blog.pl/ptt/" + accesskey="1">批踢踢實業坊</a></h1> +</div> +</td></tr> + +<tr><td> +<a href="http://man.ptt.cc">網頁版精華區首頁</a> +<a href="http://man.ptt.cc/man.pl/[% brdname %]/">[% brdname %]精華區首頁</a> +<a href="http://blog.ptt.cc">批踢踢部落格</a> +<br /> +<font size=+1>在看板 [% brdname %] 內搜尋 [% key %]</font> +<hr /> +</td></tr> +<tr><td> + +<ul> +[% FOREACH x=search %] +<li><a href="/man.pl/[% brdname %][% x.fn %]">[% x.title %]</a> (score: [% x.score %])</li> +[% END %] +</ul> + +</td></tr> +<tr><td> +<hr /> +<form method="POST" action="/man.pl/[% brdname %]/"> +在這個精華區內翻弄 (under construction) +<input type="text" name="key"> +<input type="submit" value="撈"> +</form> +<hr /> +<a href="telnet://ptt.cc">批踢踢實業坊</a> (<a href="http://ptt.cc">PttWeb</a>) +</td></tr> +</table> +</body> +</html> |