]> git.deb.at Git - deb/packages.git/blobdiff - lib/Packages/DoSearch.pm
remove $SEARCH_CGI since it is always identical with $SEARCH_URL
[deb/packages.git] / lib / Packages / DoSearch.pm
index 630411f5de9e76db68997d25bd6bce62947c24b1..d8aa6d8194dbe97ffccffefaf83395052058db12 100644 (file)
@@ -15,12 +15,14 @@ use Deb::Versions;
 use Packages::Search qw( :all );
 use Packages::CGI;
 use Packages::DB;
-use Packages::Config qw( $DBDIR $SEARCH_URL $SEARCH_CGI $SEARCH_PAGE
+use Packages::Config qw( $DBDIR $SEARCH_URL $SEARCH_PAGE
                         @SUITES @ARCHIVES $ROOT );
 
 sub do_search {
     my ($params, $opts, $html_header, $menu, $page_content) = @_;
 
+    $Params::Search::too_many_hits = 0;
+
     if ($params->{errors}{keywords}) {
        fatal_error( "keyword not valid or missing" );
     } elsif (length($opts->{keywords}) < 2) {
@@ -37,6 +39,7 @@ sub do_search {
     my $suites_param = join ',', @{$params->{values}{suite}{no_replace}};
     my $sections_param = join ',', @{$params->{values}{section}{no_replace}};
     my $archs_param = join ',', @{$params->{values}{arch}{no_replace}};
+    $opts->{common_params} = "suite=$suites_param;section=$sections_param;keywords=$keyword_esc;searchon=$searchon;arch=$archs_param";
 
     # for output
     my $keyword_enc = encode_entities $keyword || '';
@@ -123,7 +126,7 @@ sub do_search {
            
            if ($opts->{exact}) {
                $printed++;
-               hint( "You have searched only for words exactly matching your keywords. You can try to search <a href=\"$SEARCH_CGI?exact=0;searchon=$searchon;suite=$suites_param;section=$sections_param;keywords=$keyword_esc;arch=$archs_param\">allowing subword matching</a>." );
+               hint( "You have searched only for words exactly matching your keywords. You can try to search <a href=\"$SEARCH_URL?exact=0;$opts->{common_params}\">allowing subword matching</a>." );
            }
        }
        hint( ( $printed ? "Or you" : "You" )." can try a different search on the <a href=\"$SEARCH_PAGE#search_packages\">Packages search page</a>." );
@@ -219,20 +222,21 @@ sub print_packages {
     my ($pkgs, $pkgs_list, $opts, $keyword, $print_func, @func_args) = @_;
 
     #my ($start, $end) = multipageheader( $input, scalar @pkgs, \%opts );
-    my $str .= "<p>Found <em>".(scalar @$pkgs_list)."</em> matching packages.";
+    my $str = '<div id="psearchres">';
+    $str .= "<p>Found <em>".(scalar @$pkgs_list)."</em> matching packages.";
     #my $count = 0;
            
     my $have_exact;
     if (grep { $_ eq $keyword } @$pkgs_list) {
        $have_exact = 1;
-       $str .= '<h2 style="padding:.3em;border-top:solid grey thin;border-bottom:solid grey thin;background-color:#bdf">Exact hits</h2>';
+       $str .= '<h2>Exact hits</h2>';
        $str .= &$print_func( $keyword, $pkgs->{$keyword}||{},
                              map { $_->{$keyword}||{} } @func_args );
        @$pkgs_list = grep { $_ ne $keyword } @$pkgs_list;
     }
            
     if (@$pkgs_list && (($opts->{searchon} ne 'names') || !$opts->{exact})) {
-       $str .= '<h2 style="padding:.3em;border-top:solid grey thin;border-bottom:solid grey thin;background-color:#bdf">Other hits</h2>'
+       $str .= '<h2>Other hits</h2>'
            if $have_exact;
        
        foreach my $pkg (@$pkgs_list) {
@@ -242,9 +246,10 @@ sub print_packages {
                                  map { $_->{$pkg}||{} } @func_args );
        }
     } elsif (@$pkgs_list) {
-       $str .= "<p><a href=\"$SEARCH_URL/FIXME\">".
+       $str .= "<p><a href=\"$SEARCH_URL?exact=0;$opts->{common_params}\">".
            ($#{$pkgs_list}+1)."</a> results have not been displayed because you requested only exact matches.</p>";
     }
+    $str .= '</div>';
 
     return $str;
 }
@@ -264,7 +269,7 @@ sub print_package {
                my @versions = version_sort keys %{$pkgs->{$suite}{$archive}};
                my $origin_str = "";
                if ($sect->{$suite}{$archive}{$versions[0]}) {
-                   $origin_str .= " [<span style=\"color:red\">$sect->{$suite}{$archive}{$versions[0]}</span>]";
+                   $origin_str .= " ".marker($sect->{$suite}{$archive}{$versions[0]});
                }
                $str .= sprintf( "<li><a href=\"$ROOT/%s/%s\">%s</a> (%s): %s   %s\n",
                                 $path, $pkg, $path, $subsect->{$suite}{$archive}{$versions[0]},
@@ -273,7 +278,7 @@ sub print_package {
                foreach my $v (@versions) {
                    my $archive_str = "";
                    if ($archives->{$suite}{$archive}{$v}) {
-                       $archive_str .= " [<span style=\"color:red\">$archives->{$suite}{$archive}{$v}</span>]";
+                       $archive_str .= " ".marker($archives->{$suite}{$archive}{$v});
                    }
                    
                    my @archs_to_print = grep { !$archs_printed{$_} } sort keys %{$pkgs->{$suite}{$archive}{$v}};
@@ -309,10 +314,10 @@ sub print_src_package {
            if (exists $pkgs->{$suite}{$archive}) {
                my $origin_str = "";
                if ($sect->{$suite}{$archive}{source}) {
-                   $origin_str .= " [<span style=\"color:red\">$sect->{$suite}{$archive}{source}</span>]";
+                   $origin_str .= " ".marker($sect->{$suite}{$archive}{source});
                }
                if ($archives->{$suite}{$archive}{source}) {
-                   $origin_str .= " [<span style=\"color:red\">$archives->{$suite}{$archive}{source}</span>]";
+                   $origin_str .= " ".marker($archives->{$suite}{$archive}{source});
                }
                $str .= sprintf( "<li><a href=\"$ROOT/%s/source/%s\">%s</a> (%s): %s   %s",
                                 $suite.(($archive ne 'us')?"/$archive":''), $pkg, $suite.(($archive ne 'us')?"/$archive":''), $subsect->{$suite}{$archive}{source},