]> git.deb.at Git - deb/packages.git/blobdiff - lib/Packages/DoIndex.pm
The Big, the Fat and the Ugly commit ;)
[deb/packages.git] / lib / Packages / DoIndex.pm
index 8ca34f5a0097a2a235be92465f0260a1441dce26..0ed874a24ce31a4dcf5865a3036c0cd25330fe58 100644 (file)
@@ -21,6 +21,15 @@ sub do_allpackages {
     return send_file( 'allpackages', @_ );
 }
 
+# no real need for more flexibility here, I think...
+my %mime_types = (
+                 txt => 'text/plain',
+                 'txt.gz' => 'text/plain',
+                 html => 'text/html',
+                 );
+my %encoding = (
+               'txt.gz' => 'x-gzip',
+               );
 sub send_file {
     my ($file, $params, $opts, $html_header) = @_;
 
@@ -35,18 +44,24 @@ sub send_file {
     }
 
     my $wwwdir = "$TOPDIR/www";
-    my $path = "$opts->{suite}[0]/";
+    my $path = "";
+    $path .= "source/" if $opts->{source};
+    $path .= "$opts->{suite}[0]/";
     $path .= "$opts->{archive}[0]/" if @{$opts->{archive}} == 1;
     $path .= "$opts->{subsection}[0]/" if @{$opts->{subsection}};
+    $path .= "$opts->{priority}[0]/" if @{$opts->{priority}};
     # we don't have translated index pages for subsections yet
-    $opts->{lang} = 'en' if @{$opts->{subsection}};
+    $opts->{lang} = 'en' if @{$opts->{subsection}} or $file eq 'allpackages';
     $path .= "$file.$opts->{lang}.$opts->{format}";
 
     unless (@Packages::CGI::fatal_errors) {
        my $buffer;
        if (open( INDEX, '<', "$wwwdir/$path" )) {
-           my $charset = get_charset( $opts->{lang} );
-           print header( -charset => $charset );
+           my %headers;
+           $headers{'-charset'} = get_charset( $opts->{lang} );
+           $headers{'-type'} = $mime_types{$opts->{format}} || 'text/plain';
+           $headers{'-content-encoding'} = $encoding{$opts->{format}} if exists $encoding{$opts->{format}};
+           print header( %headers );
 
            binmode INDEX;
            while (read INDEX, $buffer, 4096) {
@@ -59,21 +74,6 @@ sub send_file {
                                  $path, $! ) );
        }
     }
-
-    %$html_header = ( title => _g('Error'),
-                     lang => $opts->{lang},
-                     print_title => 1,
-                     print_search_field => 'packages',
-                     search_field_values => { 
-                         keywords => _g('search for a package'),
-                         searchon => 'default',
-                         arch => 'any',
-                         suite => 'all',
-                         section => 'all',
-                         exact => 1,
-                         debug => $Packages::CGI::debug,
-                     },
-                     );
 }
 
 1;