Add sort by knob for freebsd mailinglists search. Values are author, date,

subject and score. Score is the default sort option.
This commit is contained in:
Wolfram Schneider 1997-11-08 18:22:27 +00:00
parent 98aa89eea4
commit 243e91422b
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/www/; revision=2148
4 changed files with 142 additions and 10 deletions

View file

@ -106,6 +106,7 @@ sub do_wais {
&open2(WAISOUT, WAISIN, $waisq, "-g");
print WAISIN $w_question;
local(@mylist) = ();
local($hits, $score, $headline, $lines, $bytes, $type, $date, $file);
while (<WAISOUT>) {
/:score\s+(\d+)/ && ($score = $1);
@ -113,9 +114,64 @@ sub do_wais {
/:number-of-lines\s+(\d+)/ && ($lines = $1);
/:number-of-bytes\s+(\d+)/ && ($bytes = $1);
/:type "(.*)"/ && ($type = $1);
/:headline "(.*)"/ && ($headline = $1); # XXX
/:date "(\d+)"/ && ($date = $1, $hits++, &docdone);
/:headline "(.*)"/ && ($headline = $1,
$headline =~ s/Re:\sRe:\s/Re: /); # XXX
/:date "(\d+)"/ && ($date = $1, $hits++,
push(@mylist, join("\t", $date, $headline, $type,
$bytes, $lines, $file, $score, $hits)));
}
if ($in{'sort'} eq "date") {
foreach (reverse sort {$a <=> $b} @mylist) {
($date, $headline, $type, $bytes, $lines,
$file, $score, $hits) = split("\t");
&docdone;
}
} elsif ($in{'sort'} eq "subject") {
local(@a, @c, $b, $d);
foreach (@mylist) {
@a = split("\t");
$b = $a[0];
# swap date and subject
if ($a[1] =~ /(^[^:]+)(Re:.*)/) {
$a[0] = "$2\t$1";
} else {
$a[0] = "$a[1]\t.";
}
$a[1] = $b;
push(@c, join("\t", @a));
}
local($subject, $author);
foreach (sort {$a cmp $b} @c) {
($subject, $author, $date, $type, $bytes,
$lines, $file, $score, $hits) = split("\t");
$headline = $author . $subject;
&docdone;
}
} elsif ($in{'sort'} eq "author") {
local(@a, @c, $b);
foreach (@mylist) {
@a = split("\t");
# swap date and subject
$b = $a[0]; $a[0] = $a[1]; $a[1] = $b;
push(@c, join("\t", @a));
}
foreach (sort {$a cmp $b} @c) {
($headline, $date, $type, $bytes,
$lines, $file, $score, $hits) = split("\t");
&docdone;
}
} else {
foreach (@mylist) {
($date, $headline, $type, $bytes,
$lines, $file, $score, $hits) = split("\t");
&docdone;
}
}
#print qq[in: $in{'sort'}\n];
print "</OL>\n";
print "<p>Didn't get what you expected? ";

View file

@ -1,9 +1,9 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN" [
<!ENTITY date "$Date: 1997-10-22 21:44:26 $">
<!ENTITY date "$Date: 1997-11-08 18:22:06 $">
<!ENTITY title "Search">
<!ENTITY % includes SYSTEM "includes.sgml"> %includes;
]>
<!-- $Id: search.sgml,v 1.19 1997-10-22 21:44:26 jfieber Exp $ -->
<!-- $Id: search.sgml,v 1.20 1997-11-08 18:22:06 wosch Exp $ -->
<html>
&header;
@ -62,7 +62,17 @@ for more information.</a></p>
<p><input type="text" name="words" size="50"><br>
Limit the number of results to <input type="text" name="max"
value="25" size="5"> <input type="submit"> <input type="reset"></p>
value="25" size="5">
sort by
<SELECT NAME="sort">
<OPTION VALUE="score">score</OPTION>
<OPTION VALUE="date">date</OPTION>
<OPTION VALUE="subject">subject</OPTION>
<OPTION VALUE="author">author</OPTION>
</SELECT>
<input type="submit"> <input type="reset"></p>
<h3>In archive(s):</h3>