- my $key = $s;
- mkpath ( "$wwwdir/$source$key" );
- foreach my $lang (@LANGUAGES) {
- my $charset = 'UTF-8';
- my $cat = Packages::I18N::Locale->get_handle($lang)
- or die "get_handle failed for $lang";
-
- my %lang_vars = ( lang => $lang, charset => $charset,
- cat => $cat, used_langs => \@LANGUAGES );
- print "writing $source$s/allpackages (lang=$lang)...\n";
- $template->page( 'index', { %lang_vars, packages => $pkgs->{$key},
- suite => $s, is_source => $source },
- "$wwwdir/$source$key/allpackages.$lang.html.new" );
- print "writing $source$s/allpackages (txt,lang=$lang)...\n";
- my $gzfh = gzopen("$wwwdir/$source$key/allpackages.$lang.txt.gz.new",
- 'wb9')
- or die "can't open text index file for output: $!";
- my $gztxt;
- $gztxt = $txt_template->page( 'index', { %lang_vars, packages => $pkgs->{$key},
- suite => $s, is_source => $source },
- );
- $gzfh->gzwrite($gztxt);
- ($gzfh->gzclose == Z_OK) or
- warn "can't close text index file $wwwdir/$source$key/allpackages.$lang.txt.gz.new: ".$gzfh->gzerror;
-
- rename( "$wwwdir/$source$key/allpackages.$lang.html.new",
- "$wwwdir/$source$key/allpackages.$lang.html" );
- rename( "$wwwdir/$source$key/allpackages.$lang.txt.gz.new",
- "$wwwdir/$source$key/allpackages.$lang.txt.gz" );
-
- foreach my $sec (keys %{$sections->{$s}}) {
- mkpath ( "$wwwdir/$source$key/$sec" );
-
- print "writing $source$s/$sec/index (lang=$lang)...\n";
- $template->page( 'index', { packages => [ grep { $_->{section} eq $sec } @{$pkgs->{$key}} ],
- %lang_vars, suite => $s, is_source => $source,
- category => { id => $cat->g('Section'), name => $sec } },
- "$wwwdir/$source$key/$sec/index.$lang.html.new" );
- rename( "$wwwdir/$source$key/$sec/index.$lang.html.new",
- "$wwwdir/$source$key/$sec/index.$lang.html" );
- }
- foreach my $ssec ((keys %{$subsections->{$s}}, 'virtual')) {
- next if $ssec eq '-';
- mkpath ( "$wwwdir/$source$key/$ssec" );
-
- print "writing $source$s/$ssec/index (lang=$lang)...\n";
- $template->page( 'index', { packages => [ grep { $_->{subsection} eq $ssec } @{$pkgs->{$key}} ],
- %lang_vars, suite => $s, is_source => $source,
- category => { id => $cat->g('Subsection'), name => $ssec } },
- "$wwwdir/$source$key/$ssec/index.$lang.html.new" );
- rename( "$wwwdir/$source$key/$ssec/index.$lang.html.new",
- "$wwwdir/$source$key/$ssec/index.$lang.html" );
- }
- foreach my $prio (keys %{$priorities->{$s}}) {
- next if $prio eq '-';
- mkpath ( "$wwwdir/$source$key/$prio" );
-
- print "writing $source$s/$prio/index (lang=$lang)...\n";
- $template->page( 'index', { packages => [ grep { $_->{priority} eq $prio } @{$pkgs->{$key}} ],
- %lang_vars, suite => $s, is_source => $source,
- category => { id => $cat->g('Priority'), name => $prio } },
- "$wwwdir/$source$key/$prio/index.$lang.html.new" );
- rename( "$wwwdir/$source$key/$prio/index.$lang.html.new",
- "$wwwdir/$source$key/$prio/index.$lang.html" );
- }
+ my %common_vars = ( suite => $s,
+ is_source => $source );
+ close_file("$source$s", \%common_vars, 'allpackages');
+ close_txt_file("$source$s", \%common_vars, 'allpackages');
+
+ foreach my $sec (keys %{$sections->{$s}}) {
+ close_file("$source$s/$sec",
+ { %common_vars,
+ category => { id => N_('Section'),
+ name => $sec }});
+ }
+ foreach my $ssec ((keys %{$subsections->{$s}}, 'virtual')) {
+ next if $ssec eq '-';
+ close_file("$source$s/$ssec",
+ { %common_vars,
+ category => { id => N_('Subsection'),
+ name => $ssec }});
+ }
+ foreach my $prio (keys %{$priorities->{$s}}) {
+ next if $prio eq '-';
+ close_file("$source$s/$prio",
+ { %common_vars,
+ category => { id => N_('Priority'),
+ name => $prio }});