This is the historical archive of the now-inactive 'grubstreet' list.
Discussion on OpenGuides development
has now moved to OpenGuides-Dev.
Discussion on The Open Guide to
London now takes place on OpenGuides-London.
RE: [grubstreet] Ivor's search script
[prev] [thread] [next] [lurker] [Date index for 2002/10/30]
From: Ivor Williams
Subject: RE: [grubstreet] Ivor's search script
Date: 16:44 on 30 Oct 2002
Subject: RE: [grubstreet] Ivor's search script
Date: 16:44 on 30 Oct 2002
On Tuesday, October 29, 2002 5:30 PM, Earle Martin [SMTP:grubstreet@xxxxxxxx.xxx] wrote: > On Tue, Oct 29, 2002 at 12:05:39AM -0000, Ivor Williams wrote: > > Is it worthwhile building in the functionality to present matches x at a > > time? > > I will look at how to do this, but this may be overkill for Grubstreet. > > I think it would be good to be able to do that, because as the site gets > larger, search results will get longer as well (obviously). For example, > try searching for 'the'. > I have written some code to implement this. 20 results to a page. Over 20 and a 'More' button appears. The presentation of the search results is also improved, as only the first 6 matches on a page are displayed, preventing excess verbosity (but nevertheless giving an equal spread of matches between the operands of an AND or OR). The results are also ranked, displaying the page with most matches first. Enjoy. Ivor. Patch follows (incremental on the other patch of course): 133c133,134 < print hr,h2('Search Results'),start_ol,"\n"; --- > my $startpos = $q->param('next') || 0; > print hr,h2('Search Results'),start_ol({start=>$startpos+1}),"\n"; 138,139c139,145 < for (keys %results) { < print p(li(a({href=>$wikimain."?$_"},b($_)) . br . $results{$_})); --- > my @res_selected = sort {@{$results{$b}} <=> @{$results{$a}}} keys %results; > my $tot_results = @res_selected; > splice @res_selected,0,$startpos; > for (@res_selected[0..19]) { > (print end_ol,"\n"),last RESULTS if !$_; > > print p(li(a({href=>$wikimain."?$_"},b($_)),br,@{$results{$_}}[0..5])); 141c147,157 < print end_ol,"\n"; --- > print end_ol,p($startpos+20,'/',$tot_results,"matches"),"\n"; > > if ($tot_results > $startpos + 20) { > print start_form, > hidden( -name=>'search', > -value=>$srh), > hidden( -name=>'next', > -value=>$startpos + 20), > submit( 'More'), > end_form; > } 161c177 < my $out = ''; --- > my @out; 168c184 < $out .= $match; --- > push @out,$match; 171c187 < $res{$k} = $out if $out; --- > $res{$k} = \@out if @out; 176a193,208 > sub intersperse { > my $pagnam = shift; > > my @mixed; > > for my $j (@_) { > if (exists $j->{$pagnam}) { > push @mixed,[$_,$j->{$pagnam}[$_]] for 0..$#{$j->{$pagnam}}; > } > } > > my @interspersed = map $_->[1], sort {$a->[0] <=> $b->[0]} @mixed; > > \@interspersed; > } > 207c239,240 < my %out=%{shift @comby_res}; --- > my @out= keys %{$comby_res[0]}; > my %out; 212,213c245,246 < for my $page (keys %out) { < for (@comby_res) { --- > for my $page (@out) { > for (@comby_res[1..$#comby_res]) { 217c250 < $out{$page} .= $_->{$page} for @comby_res; --- > $out{$page} = intersperse($page,@comby_res); 231c264 < my %out; --- > my %union; 237c270 < $out{$k} .= $v; --- > $union{$k}++; 240a274,277 > my %out; > > $out{$_} = intersperse($_,@list_res) for keys %union; > 249c286 < my %out = map {$_=>''} keys %wikitext; --- > my %out = map {$_=>[]} keys %wikitext; -- grubstreet mailing list http://london.openguides.org/old-list-archives/
-
[grubstreet] Ivor's search script
Earle Martin 23:35 on 28 Oct 2002
I would reply to the original post, but I managed to lose it. Have a go:-
Re: [grubstreet] Ivor's search script
Ivor Williams 00:05 on 29 Oct 2002
From: "Earle Martin" <grubstreet@downlode.org>-
Kate L Pugh
09:50 on 29 Oct 2002
I like the way that the matches are highlighted in the results, also- too deep to show
-
Earle Martin
17:29 on 29 Oct 2002
I think it would be good to be able to do that, because as the site gets
-
Kate L Pugh
09:50 on 29 Oct 2002
-
RE: [grubstreet] Ivor's search script
Ivor Williams 10:20 on 29 Oct 2002
work-
Re: [grubstreet] Ivor's search script
Earle Martin 17:25 on 29 Oct 2002
Patched.
-
Re: [grubstreet] Ivor's search script
Earle Martin 17:25 on 29 Oct 2002
-
RE: [grubstreet] Ivor's search script
Ivor Williams 10:02 on 30 Oct 2002
At the moment, the search presents the raw wiki text, including its and HTML -
Ivor Williams
10:06 on 30 Oct 2002
At the moment, the search presents the raw wiki text, including its and HTML -
Ivor Williams
16:44 on 30 Oct 2002
I have written some code to implement this. 20 results to a page. Over 20 and a -
Ivor Williams
14:06 on 04 Nov 2002
150,154c150,155
-
Re: [grubstreet] Ivor's search script
Ivor Williams 00:05 on 29 Oct 2002