1 package Packages::DoIndex;
7 use POSIX qw( strftime );
11 use Packages::Config qw( $TOPDIR );
14 our @ISA = qw( Exporter );
15 our @EXPORT = qw( do_homepage do_index do_allpackages );
19 return send_file( 'index', @_ );
23 return send_file( 'index', @_ );
26 return send_file( 'allpackages', @_ );
33 my ($file, $params, $opts) = @_;
34 my $cat = $opts->{cat};
36 if ($params->{errors}{suite}) {
37 fatal_error( $cat->g( "suite not valid or not specified" ) );
39 if (@{$opts->{suite}} > 1) {
40 fatal_error( $cat->g( "more than one suite specified for show_static (%s)",
41 "@{$opts->{suite}}" ) );
43 if (@{$opts->{subsection}} > 1) {
44 fatal_error( $cat->g( "more than one subsection specified for show_static (%s)",
45 "@{$opts->{suite}}" ) );
48 if ($opts->{format} eq 'txt.gz') {
49 $opts->{po_lang} = 'en';
51 my $wwwdir = "$TOPDIR/www";
53 $path .= "source/" if $opts->{source};
54 $path .= "$opts->{suite}[0]/" if @{$opts->{suite}};
55 $path .= "$opts->{archive}[0]/" if @{$opts->{archive}} == 1;
56 $path .= "$opts->{subsection}[0]/" if @{$opts->{subsection}};
57 $path .= "$opts->{priority}[0]/" if @{$opts->{priority}};
58 $path .= "$file.$opts->{po_lang}.$opts->{format}";
60 unless (@Packages::CGI::fatal_errors) {
62 if (open( INDEX, '<', "$wwwdir/$path" )) {
64 $headers{'-charset'} = 'UTF-8';
65 $headers{'-type'} = get_mime( $opts->{format}, 'text/plain' );
66 $headers{'-content-encoding'} = $encoding{$opts->{format}} if exists $encoding{$opts->{format}};
67 my ($size,$mtime) = (stat("$wwwdir/$path"))[7,9];
68 $headers{'-content-length'} = $size;
69 $headers{'-vary'} = 'negotiate,accept-language';
70 $headers{'-last-modified'} = strftime("%a, %d %b %Y %T %z", localtime($mtime));
71 $headers{'-expires'} = strftime("%a, %d %b %Y %T %z", localtime($mtime+(12*3600)));
72 print header( %headers );
75 while (read INDEX, $buffer, 4096) {
81 fatal_error( $cat->g( "couldn't read index file %s: %s",