From 13565c2add3c1f4c501cf0cba64cac10537e2eac Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Fri, 1 Feb 2008 02:03:46 +0100 Subject: [PATCH] Various improvements to the search result comments Don't pretend we know how many results have been suppressed, we really have no idea (that's the whole point of short cutting the search). Don't declare we will display results when we wont. We have all the necessary information so use it. Add some useful links similar to what is on the search_contents site. --- lib/Packages/DoSearch.pm | 9 ++++++-- templates/html/search.tmpl | 47 +++++++++++++++++++++++++++++++------- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/lib/Packages/DoSearch.pm b/lib/Packages/DoSearch.pm index 9fa8d3d..4d86d51 100644 --- a/lib/Packages/DoSearch.pm +++ b/lib/Packages/DoSearch.pm @@ -13,7 +13,7 @@ use Deb::Versions; use Packages::Search qw( :all ); use Packages::CGI qw( :DEFAULT ); use Packages::DB; -use Packages::Config qw( $DBDIR @SUITES @ARCHIVES $ROOT ); +use Packages::Config qw( $DBDIR @SUITES @ARCHIVES @ARCHITECTURES $ROOT ); sub do_search { my ($params, $opts, $page_content) = @_; @@ -30,7 +30,12 @@ sub do_search { my @keywords = @{$opts->{keywords}}; my $searchon = $opts->{searchon}; - $page_content->{search_keywords} = \@keywords; + $page_content->{search_keywords} = $opts->{keywords}; + $page_content->{all_architectures} = \@ARCHITECTURES; + $page_content->{all_suites} = \@SUITES; + $page_content->{search_architectures} = $opts->{arch}; + $page_content->{search_suites} = $opts->{suite}; + $page_content->{sections} = $opts->{section}; my $st0 = new Benchmark; my (@results, @non_results); diff --git a/templates/html/search.tmpl b/templates/html/search.tmpl index f7eace5..452e80b 100644 --- a/templates/html/search.tmpl +++ b/templates/html/search.tmpl @@ -30,17 +30,43 @@
[% UNLESS results %] -

[% g('You can try a different search on the Packages search page.', - searchformurl) %]

- [% IF opts.searchon != "names" && opts.exact %]

[% g('You have searched only for words exactly matching your keywords. You can try to search allowing subword matching.', make_search_url('',"keywords=$keyword_esc",'exact',0) ) %]

[% END %] [% END %] + +

[% g('Search in specific suite:') %] +[% FOREACH s IN all_suites %] + [% IF s != suite_str %] + [[% s %]] + [% ELSE %] + [[% s %]] + [% END %] +[% END %] +[% IF search_suites.size == 1 %] +

[% g('Search in all suites', + make_search_url('',"keywords=$keyword_esc",'suite','all')) %] +[% END %] + +

[% g('Limit search to a specific architecture:') %] +[% FOREACH a IN all_architectures %] + [% IF a != arch_str %] + [[% a %]] + [% ELSE %] + [[% a %]] + [% END %] +[% END %] +[% IF search_architectures.size == 1 %] +

[% g('Search in all architectures', + make_search_url('',"keywords=$keyword_esc",'arch','any')) %] +[% END %] + +

+ [% IF opts.searchon == "names" && non_results %] -

[% g('%u results have not been displayed due to the search parameters.', - "$search_url$keyword_esc", non_results) %]

+

[% g('Some results have not been displayed due to the search parameters.', + "$search_url$keyword_esc") %]

[% END %] @@ -71,11 +97,16 @@ [% IF opts.searchon != "names" %]

[% g("Note that this only shows the best matches, sorted by relevance. If the first few packages don't match what you searched for, try using more keywords or alternative keywords.") %]

[% ELSE %] -

[% g('Your search was too wide so we will only display exact matches. At least %u results have been omitted and will not be displayed. Please consider using a longer keyword or more keywords.', - too_many_hits) %]

+

+[%- IF results %] +[% g("Your keyword was too generic, for optimizing reasons some results might have been supressed.
Please consider using a longer keyword or more keywords.") %] +[%- ELSE -%] +[% g("Your keyword was too generic.
Please consider using a longer keyword or more keywords.") %] +[% END -%] +

[% END; END %] -[% UNLESS results %] +[% UNLESS results || too_many_hits %]

[% g('Sorry, your search gave no results') %]

[% END %] -- 2.39.2