1 package Packages::DoIndex;
10 use Packages::Config qw( $TOPDIR );
11 use Packages::I18N::Locale;
14 our @ISA = qw( Exporter );
15 our @EXPORT = qw( do_index do_allpackages );
18 return send_file( 'index', @_ );
21 return send_file( 'allpackages', @_ );
24 # no real need for more flexibility here, I think...
27 'txt.gz' => 'text/plain',
34 my ($file, $params, $opts, $html_header) = @_;
36 if ($params->{errors}{suite}) {
37 fatal_error( _g( "suite not valid or not specified" ) );
39 if (@{$opts->{suite}} > 1) {
40 fatal_error( sprintf( _g( "more than one suite specified for show_static (%s)" ), "@{$opts->{suite}}" ) );
42 if (@{$opts->{subsection}} > 1) {
43 fatal_error( sprintf( _g( "more than one suite specified for show_static (%s)" ), "@{$opts->{suite}}" ) );
46 my $wwwdir = "$TOPDIR/www";
48 $path .= "source/" if $opts->{source};
49 $path .= "$opts->{suite}[0]/";
50 $path .= "$opts->{archive}[0]/" if @{$opts->{archive}} == 1;
51 $path .= "$opts->{subsection}[0]/" if @{$opts->{subsection}};
52 $path .= "$opts->{priority}[0]/" if @{$opts->{priority}};
53 # we don't have translated index pages for subsections yet
54 $opts->{lang} = 'en' if @{$opts->{subsection}} or $file eq 'allpackages';
55 $path .= "$file.$opts->{lang}.$opts->{format}";
57 unless (@Packages::CGI::fatal_errors) {
59 if (open( INDEX, '<', "$wwwdir/$path" )) {
61 $headers{'-charset'} = get_charset( $opts->{lang} );
62 $headers{'-type'} = $mime_types{$opts->{format}} || 'text/plain';
63 $headers{'-content-encoding'} = $encoding{$opts->{format}} if exists $encoding{$opts->{format}};
64 print header( %headers );
67 while (read INDEX, $buffer, 4096) {
73 fatal_error( sprintf( _g( "couldn't read index file %s: %s" ),