[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#137860: Patch



tags 137860 patch
thanks

Hmm, my first mail doesn't seem to have reached the BTS. Trying again.

I prepared a patch that adds some basic hints after failed searches
like those proposed in the bug report. Feedback (especially on my
wording) welcome.

Gruesse,
-- 
Frank Lichtenheld <djpig@debian.org>
www: http://www.djpig.de/
Index: cgi-bin/search_packages.pl
===================================================================
RCS file: /var/cvs/debian.de/packages.debian.org/cgi-bin/search_packages.pl,v
retrieving revision 1.13
diff -u -r1.13 search_packages.pl
--- cgi-bin/search_packages.pl	5 Feb 2004 20:22:07 -0000	1.13
+++ cgi-bin/search_packages.pl	5 Feb 2004 21:54:02 -0000
@@ -56,24 +56,27 @@
    exit 0;
 }
 (my $version) = $input->param('version') =~ m/^(\w+)$/; # $version now untainted
+my $version_param = $version || 'all'; # for constructing URLs
 $version = "stable" unless (defined $version);
 $version = '*' if ($version eq 'all');
-my $case = '';
-$case = $input->param('case');
+(my $case) = $input->param('case') =~ m/^(\w+)$/;
 $case = "insensitive" unless (defined $case);
-my $subword = $input->param('subword');
+(my $subword) = $input->param('subword') =~ m/^(\w+)$/;
 $subword = 0 unless (defined $subword);
-my $searchon = $input->param('searchon');
+(my $searchon) = $input->param('searchon') =~ m/^(\w+)$/;
 $searchon = 'all' unless (defined $searchon);
-my $exact = $input->param('exact');
+(my $exact) = $input->param('exact') =~ m/^(\w+)$/;
 $exact = 0 unless (defined $exact);
-my $releases = $input->param('release');
+(my $releases) = $input->param('release') =~ m/^(\w+)$/;
+my $releases_param = $releases || 'all';
 $releases = '*' unless (defined $releases);
 $releases = '*' if ($releases eq 'all');
 
 my $arch = "*";
+my $arch_param = 'any';
 if (defined $input->param('arch') && $input->param('arch') =~ m/^([\w-]+)$/) {
   $arch = $1; # $arch now untainted
+  $arch_param = $1;
 }
 $arch = '*' if ($arch eq 'any');
 
@@ -200,11 +203,22 @@
 my @results = qx( $command );
 
 if (!@results) {
+  my $keyword_esc = uri_escape( $keyword );
   if ($searchon eq "names") {
     print "<p><strong>Can't find that package, at least not in that distribution and on that architecture.</strong></p>\n";
+
+    if ($exact) {
+	print "<p>You have searched only for exact matches of the package name. You can try to search for <a href=\"?exact=0&amp;searchon=$searchon&amp;version=$version_param&amp;case=$case&amp;release=$releases_param&amp;keywords=$keyword_esc&amp;arch=$arch_param\">package names that contain your search string</a>.</p>";
+    }
   } else {
     print "<p><strong>Can't find that string, at least not in that distribution and on that architecture.</strong></p>\n";
+
+    unless ($subword) {
+        print "<p>You have searched only for words exact matching your keywords. You can try to search <a href=\"?subword=1&amp;searchon=$searchon&amp;version=$version_param&amp;case=$case&amp;release=$releases_param&amp;keywords=$keyword_esc&amp;arch=$arch_param\">allowing subword matching</a>.</p>";
+    }
   }
+  print "<p>Or you can try a different search on the <a href=\"http://packages.debian.org/#search_packages\";>Packages search page</a>.</p>";
+
   &printfooter;
   exit
 }
@@ -238,6 +252,7 @@
 		printf "<br>%s: %s\n",
 		$v, join (" ", (sort keys %{$pkgs{$pkg}{$ver}{$v}}) );
 	    }
+	    print "</li>\n";
 	}
     }
     print "</ul>\n";
@@ -251,7 +266,7 @@
 sub printfooter {
 print <<END;
 
-<p align=right><small><i><a href="http://packages.debian.org/";>
+<p align="right"><small><i><a href="http://packages.debian.org/";>
 Packages search page</a></i></small></p>
 END
 

Attachment: pgp3UOkI7mqZW.pgp
Description: PGP signature


Reply to: