]> git.deb.at Git - deb/packages.git/commitdiff
Split the creation of the suite index pages out of create_index_pages
authorFrank Lichtenheld <frank@lichtenheld.de>
Thu, 7 Feb 2008 15:23:33 +0000 (16:23 +0100)
committerFrank Lichtenheld <frank@lichtenheld.de>
Thu, 7 Feb 2008 15:23:33 +0000 (16:23 +0100)
The whole index page stuff needs some serious tweaking because it just
doesn't scale very well with the growing number of packages and languages.

The creation of the suite index pages is not affected by this however, so
separate these two tasks.

bin/create_index_pages
bin/create_suite_index_pages [new file with mode: 0755]
cron.d/900index_pages

index 05123e7355923197b194b6a040b43f8350e96abb..53443bc08bb1d1f666064629590089cc2d9c3ebe 100755 (executable)
@@ -48,46 +48,6 @@ my (%pages);
 my $template = new Packages::Template( "$TOPDIR/templates", 'html');
 my $txt_template = new Packages::Template( "$TOPDIR/templates", 'txt');
 
-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 $charset = 'UTF-8';
-       my $cat = Packages::I18N::Locale->get_handle($lang)
-           or die "get_handle failed for $lang";
-       print "writing $key/index (lang=$lang)...\n";
-
-       my %content = ( subsections => [], suite => $s,
-                       po_lang => $lang, ddtp_lang => $lang,
-                       charset => $charset, cat => $cat,
-                       used_langs => \@LANGUAGES, suites => \@SUITES );
-       foreach my $ssec (sort (keys %{$subsections->{$s}}, 'virtual')) {
-           next if $ssec eq '-';
-           if ($sections_descs{$ssec}) {
-               push @{$content{subsections}}, {
-                   id => $ssec,
-                   name => $cat->g($sections_descs{$ssec}[0]),
-                   desc => $cat->g($sections_descs{$ssec}[1]),
-               };
-           }
-       }
-
-       $template->page( 'suite_index', \%content,
-                        "$wwwdir/$key/index.$lang.html.new");
-       rename( "$wwwdir/$key/index.$lang.html.new",
-               "$wwwdir/$key/index.$lang.html" );
-
-       $content{source} = 'source';
-       $template->page( 'suite_index', \%content,
-                        "$wwwdir/source/$key/index.$lang.html.new");
-       rename( "$wwwdir/source/$key/index.$lang.html.new",
-               "$wwwdir/source/$key/index.$lang.html" );
-
-    }
-}
-
 print "collecting package info ...\n";
 my %allpkgs;
 while (my ($pkg, $data) = each %packages) {
diff --git a/bin/create_suite_index_pages b/bin/create_suite_index_pages
new file mode 100755 (executable)
index 0000000..a14cfda
--- /dev/null
@@ -0,0 +1,65 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use POSIX;
+use Storable;
+
+use lib './lib';
+
+use Packages::CommonCode qw(:all);
+use Packages::Config qw( $TOPDIR $DBDIR @ARCHIVES @SUITES @LANGUAGES );
+use Packages::Template;
+use Packages::I18N::Locale;
+use Packages::Sections;
+&Packages::Config::init( './' );
+
+my $wwwdir = "$TOPDIR/www";
+
+my $subsections = retrieve "$DBDIR/subsections.info";
+
+#use Data::Dumper;
+#print STDERR Dumper($sections, $subsections, $priorities);
+
+my (%pages);
+
+my $template = new Packages::Template( "$TOPDIR/templates", 'html');
+
+print "write suite index files ...\n";
+foreach my $s (@SUITES) {
+    my $key = $s;
+    mkdirp ( "$wwwdir/$key" );
+    mkdirp ( "$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";
+       print "writing $key/index (lang=$lang)...\n";
+
+       my %content = ( subsections => [], suite => $s,
+                       po_lang => $lang, ddtp_lang => $lang,
+                       charset => $charset, cat => $cat,
+                       used_langs => \@LANGUAGES, suites => \@SUITES );
+       foreach my $ssec (sort (keys %{$subsections->{$s}}, 'virtual')) {
+           next if $ssec eq '-';
+           if ($sections_descs{$ssec}) {
+               push @{$content{subsections}}, {
+                   id => $ssec,
+                   name => $cat->g($sections_descs{$ssec}[0]),
+                   desc => $cat->g($sections_descs{$ssec}[1]),
+               };
+           }
+       }
+
+       $template->page( 'suite_index', \%content,
+                        "$wwwdir/$key/index.$lang.html.new");
+       activate( "$wwwdir/$key/index.$lang.html" );
+
+       $content{source} = 'source';
+       $template->page( 'suite_index', \%content,
+                        "$wwwdir/source/$key/index.$lang.html.new");
+       activate( "$wwwdir/source/$key/index.$lang.html" );
+
+    }
+}
index 5829d0b0dc5d6bc4c365629fdb92b8553f740dd0..1213e369ea02f2e40b53290fe0152580f6314f13 100755 (executable)
@@ -4,6 +4,8 @@
 
 cd "$topdir"
 
+date
+./bin/create_suite_index_pages
 date
 ./bin/create_index_pages
 date