]> git.deb.at Git - deb/packages.git/blobdiff - bin/create_index_pages
parse-contents: Update progress approximation
[deb/packages.git] / bin / create_index_pages
index 69b60a28b26ddf866b92f18446a5a560ddc4581d..8586671bdbbffb52616d7d331ab4d6255ebb02f1 100755 (executable)
@@ -44,21 +44,27 @@ tie my %src2bin, 'DB_File', "$DBDIR/sources_packages.db",
 
 my $sections = retrieve "$DBDIR/sections.info";
 my $subsections = retrieve "$DBDIR/subsections.info";
-# work around problems with non-US security updates
-$subsections->{oldstable}{us}{'non-US'}++;
 my $priorities = retrieve "$DBDIR/priorities.info";
 
 #use Data::Dumper;
 #print STDERR Dumper($sections, $subsections, $priorities);
 
-my (%pages);
+my (%pages, %tt_vars);
 
-my $template = new Packages::Template( "$TOPDIR/templates", 'html', {} );
+$tt_vars{make_search_url} = sub { return &Packages::CGI::make_search_url(@_) };
+$tt_vars{make_url} = sub { return &Packages::CGI::make_url(@_) };
+# needed to work around the limitations of the the FILTER syntax
+$tt_vars{html_encode} = sub { return HTML::Entities::encode_entities(@_,'<>&"') };
+$tt_vars{uri_escape} = sub { return URI::Escape::uri_escape(@_) };
+$tt_vars{quotemeta} = sub { return quotemeta($_[0]) };
+
+my $template = new Packages::Template( "$TOPDIR/templates", 'html', \%tt_vars );
 
 print "write suite index files ...\n";
 foreach my $s (@SUITES) {
     my $key = $s;
     mkpath ( "$wwwdir/$key" );
+    mkpath ( "$wwwdir/source/$key" );
     foreach my $lang (@LANGUAGES) {
        my $locale = get_locale( $lang );
        my $charset = get_locale( $lang );
@@ -67,18 +73,10 @@ foreach my $s (@SUITES) {
            next;
        };
        print "writing $key/index (lang=$lang)...\n";
-       open $pages{$key}{$lang}{index}{fh}, '>', "$wwwdir/$key/index.$lang.html.new"
-           or die "can't open index file for output: $!";
 
        my %content = ( subsections => [], suite => $s,
-                       lang => $lang, charset => $charset );
-       $content{make_search_url} = sub { return &Packages::CGI::make_search_url(@_) };
-       $content{make_url} = sub { return &Packages::CGI::make_url(@_) };
-        # needed to work around the limitations of the the FILTER syntax
-       $content{html_encode} = sub { return HTML::Entities::encode_entities(@_,'<>&"') };
-       $content{uri_escape} = sub { return URI::Escape::uri_escape(@_) };
-       $content{quotemeta} = sub { return quotemeta($_[0]) };
-
+                       lang => $lang, charset => $charset,
+                       used_langs => \@LANGUAGES, suites => \@SUITES );
        foreach my $ssec ((keys %{$subsections->{$s}}, 'virtual')) {
            next if $ssec eq '-';
            if ($sections_descs{$ssec}) {
@@ -89,14 +87,24 @@ foreach my $s (@SUITES) {
                };
            }
        }
-       
+
+       open $pages{$key}{$lang}{index}{fh}, '>', "$wwwdir/$key/index.$lang.html.new"
+           or die "can't open index file for output: $!";
        print {$pages{$key}{$lang}{index}{fh}} $template->page( 'suite_index', \%content );
-       print {$pages{$key}{$lang}{index}{fh}} $template->trailer( 'index', $lang, \@LANGUAGES );
        close $pages{$key}{$lang}{index}{fh} or
            warn "can't close index file $wwwdir/$key/index.$lang.html.new: $!";
        rename( "$wwwdir/$key/index.$lang.html.new",
                "$wwwdir/$key/index.$lang.html" );
-       
+
+       $content{source} = 'source';
+       open $pages{$key}{$lang}{source_index}{fh}, '>', "$wwwdir/source/$key/index.$lang.html.new"
+           or die "can't open index file for output: $!";
+       print {$pages{$key}{$lang}{source_index}{fh}} $template->page( 'suite_index', \%content );
+       close $pages{$key}{$lang}{source_index}{fh} or
+           warn "can't close index file $wwwdir/source/$key/index.$lang.html.new: $!";
+       rename( "$wwwdir/source/$key/index.$lang.html.new",
+               "$wwwdir/source/$key/index.$lang.html" );
+
     }
 }
 setlocale( LC_ALL, 'C' ) or die "couldn't reset locale";