From: Frank Lichtenheld Date: Thu, 2 Feb 2006 16:00:16 +0000 (+0000) Subject: Also move the result printing to a function X-Git-Tag: switch-to-templates~180 X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=5182ae034dddba23fe956fbfc373829e6574b88e;p=deb%2Fpackages.git Also move the result printing to a function --- diff --git a/cgi-bin/search_packages.pl b/cgi-bin/search_packages.pl index da41da0..b62821d 100755 --- a/cgi-bin/search_packages.pl +++ b/cgi-bin/search_packages.pl @@ -57,11 +57,6 @@ my $debug = $debug_allowed && $input->param("debug"); $debug = 0 if not defined($debug); #$Packages::Search::debug = 1 if $debug > 1; -# If you want, just print out a list of all of the variables and exit. -#print $input->header if $debug; -# print $input->dump; -# exit; - if (my $path = $input->param('path')) { my @components = map { lc $_ } split /\//, $path; @@ -116,12 +111,8 @@ my %params = Packages::Search::parse_params( $input, \%params_def, \%opts ); #XXX: Don't use alternative output formats yet $format = 'html'; - if ($format eq 'html') { print $input->header; -} elsif ($format eq 'xml') { -# print $input->header( -type=>'application/rdf+xml' ); - print $input->header( -type=>'text/plain' ); } my (@errors, @debug, @msgs, @hints); @@ -454,99 +445,106 @@ print_msgs; print_errors; print_hints; print_debug; +&print_results; +&printfooter; -my (%pkgs, %sect, %part, %desc, %binaries); +sub print_results { + return unless @results; -unless ($search_on_sources) { - foreach (@results) { - my ($pkg_t, $suite, $arch, $section, $subsection, - $priority, $version, $desc) = @$_; - - my ($package) = $pkg_t =~ m/^(.+)/; # untaint - $pkgs{$package}{$suite}{$version}{$arch} = 1; - $sect{$package}{$suite}{$version} = $subsection; - $part{$package}{$suite}{$version} = $section unless $section eq 'main'; + my (%pkgs, %sect, %part, %desc, %binaries); + + unless ($search_on_sources) { + foreach (@results) { + my ($pkg_t, $suite, $arch, $section, $subsection, + $priority, $version, $desc) = @$_; - $desc{$package}{$suite}{$version} = $desc; - } + my ($pkg) = $pkg_t =~ m/^(.+)/; # untaint + $pkgs{$pkg}{$suite}{$version}{$arch} = 1; + $sect{$pkg}{$suite}{$version} = $subsection; + $part{$pkg}{$suite}{$version} = $section + unless $section eq 'main'; + + $desc{$pkg}{$suite}{$version} = $desc; + } - if ($format eq 'html') { - my ($start, $end) = multipageheader( scalar keys %pkgs ); - my $count = 0; + if ($format eq 'html') { + my ($start, $end) = multipageheader( scalar keys %pkgs ); + my $count = 0; - foreach my $pkg (sort keys %pkgs) { - $count++; - next if $count < $start or $count > $end; - printf "

Package %s

\n", $pkg; - print "\n"; } - } -} else { - foreach (@results) { - my ($package, $suite, $section, $subsection, $priority, - $version) = @$_; + } else { + foreach (@results) { + my ($pkg, $suite, $section, $subsection, $priority, + $version) = @$_; - $pkgs{$package}{$suite} = $version; - $sect{$package}{$suite}{source} = $subsection; - $part{$package}{$suite}{source} = $section unless $section eq 'main'; + $pkgs{$pkg}{$suite} = $version; + $sect{$pkg}{$suite}{source} = $subsection; + $part{$pkg}{$suite}{source} = $section + unless $section eq 'main'; - $binaries{$package}{$suite} = find_binaries( $package, $suite ); - } + $binaries{$pkg}{$suite} = find_binaries( $pkg, $suite ); + } - if ($format eq 'html') { - my ($start, $end) = multipageheader( scalar keys %pkgs ); - my $count = 0; - - foreach my $pkg (sort keys %pkgs) { - $count++; - next if ($count < $start) or ($count > $end); - printf "

Source package %s

\n", $pkg; - print "\n"; } } -} - -if ($format eq 'html') { - &printindexline( scalar keys %pkgs ); - &printfooter; + printindexline( scalar keys %pkgs ); } exit; @@ -609,20 +607,15 @@ sub multipageheader { } sub printfooter { -print < - -
-

Packages search page

- -END + my $pete = new Benchmark; + my $petd = timediff($pete, $pet0); + print "Total page evaluation took ".timestr($petd)."
" + if $debug_allowed; -my $pete = new Benchmark; -my $petd = timediff($pete, $pet0); -print "Total page evaluation took ".timestr($petd)."
" - if $debug_allowed; -print $input->end_html; + my $trailer = Packages::HTML::trailer( $ROOT ); + $trailer =~ s/LAST_MODIFIED_DATE/gmtime()/e; #FIXME + print $trailer; } # vim: ts=8 sw=4