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', @_ );
25 my ($file, $params, $opts, $html_header) = @_;
27 if ($params->{errors}{suite}) {
28 fatal_error( _g( "suite not valid or not specified" ) );
30 if (@{$opts->{suite}} > 1) {
31 fatal_error( sprintf( _g( "more than one suite specified for show_static (%s)" ), "@{$opts->{suite}}" ) );
33 if (@{$opts->{subsection}} > 1) {
34 fatal_error( sprintf( _g( "more than one suite specified for show_static (%s)" ), "@{$opts->{suite}}" ) );
37 my $wwwdir = "$TOPDIR/www";
38 my $path = "$opts->{suite}[0]/";
39 $path .= "$opts->{archive}[0]/" if @{$opts->{archive}} == 1;
40 $path .= "$opts->{subsection}[0]/" if @{$opts->{subsection}};
41 # we don't have translated index pages for subsections yet
42 $opts->{lang} = 'en' if @{$opts->{subsection}};
43 $path .= "$file.$opts->{lang}.$opts->{format}";
45 unless (@Packages::CGI::fatal_errors) {
47 if (open( INDEX, '<', "$wwwdir/$path" )) {
48 my $charset = get_charset( $opts->{lang} );
49 print header( -charset => $charset );
52 while (read INDEX, $buffer, 4096) {
58 fatal_error( sprintf( _g( "couldn't read index file %s: %s" ),
63 %$html_header = ( title => _g('Error'),
64 lang => $opts->{lang},
66 print_search_field => 'packages',
67 search_field_values => {
68 keywords => _g('search for a package'),
69 searchon => 'default',
74 debug => $Packages::Search::debug,