From c6fdd0f2653303fcc8a5307e106e77161f436b44 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Fri, 8 Feb 2008 01:06:00 +0100 Subject: [PATCH] Complete rewrite of create_index_pages The old version was very hard on all of CPU, memory, and I/O. The new version tries to at least lessen the burden on memory (and to a lesser extend on CPU), in the hopes that this will indirectly (by lesser swapping) also reduce the stress on I/O. In the old version we first collected all the information about all packages and then wrote the index files one after one with TT. The newer version tries to write all of the index files while collecting the package information, therefor eliminating the need to store any information longer than needed. Because the amount of files we can open simulaniously is limited though, we can't write all the index files at once. Instead we write one index files for all languages, and in a second step then use these files to write one file per language. I tried to use the "slice" program for that, but it also computes all the results in memory, while I wanted to have a concurrent approach here as well. Since we only use a very limited subset of the features of slice I wrote a simple replacement that supports the bare minimum of what we need with the price that we need to be a bit careful about the format of the slice source files. I also don't use TT for the package entries anymore since here as well we only used a very limited set of features and I wanted to make this script as fast as possible (without having to rewrite it in C ;). The header and footer still use TT since this part isn't speed critical and we can reuse the templates we have for the dynamic pages. --- bin/create_index_pages | 378 ++++++++++++++++++++++++--------- bin/trivial_slice | 103 +++++++++ cron.d/900index_pages | 21 ++ templates/html/index.tmpl | 60 ------ templates/html/index_foot.tmpl | 3 + templates/html/index_head.tmpl | 27 +++ templates/txt/index.tmpl | 20 -- templates/txt/index_foot.tmpl | 0 templates/txt/index_head.tmpl | 5 + 9 files changed, 436 insertions(+), 181 deletions(-) create mode 100755 bin/trivial_slice delete mode 100644 templates/html/index.tmpl create mode 100644 templates/html/index_foot.tmpl create mode 100644 templates/html/index_head.tmpl delete mode 100644 templates/txt/index.tmpl create mode 100644 templates/txt/index_foot.tmpl create mode 100644 templates/txt/index_head.tmpl diff --git a/bin/create_index_pages b/bin/create_index_pages index 53443bc..0766f78 100755 --- a/bin/create_index_pages +++ b/bin/create_index_pages @@ -13,6 +13,7 @@ use Compress::Zlib; use lib './lib'; +use Packages::CommonCode qw(:all); use Packages::Config qw( $TOPDIR $DBDIR @ARCHIVES @SUITES @LANGUAGES ); use Packages::Template; use Packages::I18N::Locale; @@ -21,6 +22,8 @@ use Packages::SrcPage; use Packages::Sections; &Packages::Config::init( './' ); +use constant DEBUG => 0; + my $wwwdir = "$TOPDIR/www"; tie my %packages, 'DB_File', "$DBDIR/packages_small.db", @@ -40,20 +43,152 @@ my $sections = retrieve "$DBDIR/sections.info"; my $subsections = retrieve "$DBDIR/subsections.info"; my $priorities = retrieve "$DBDIR/priorities.info"; -#use Data::Dumper; +use Data::Dumper; #print STDERR Dumper($sections, $subsections, $priorities); -my (%pages); +my @PACKAGES = sort keys %packages; +my @SRC_PACKAGES = sort keys %src_packages; + +print "Found ".scalar(@PACKAGES)." packages\n"; +print "Found ".scalar(@SRC_PACKAGES)." source packages\n"; my $template = new Packages::Template( "$TOPDIR/templates", 'html'); my $txt_template = new Packages::Template( "$TOPDIR/templates", 'txt'); -print "collecting package info ...\n"; -my %allpkgs; -while (my ($pkg, $data) = each %packages) { +my $charset = 'UTF-8'; +my (%cat, %lang_vars, $prov_string, %s, %fh); +foreach my $lang (@LANGUAGES) { + $cat{$lang} = Packages::I18N::Locale->get_handle($lang) + or die "get_handle failed for $lang"; + $lang_vars{$lang} = { po_lang => $lang, ddtp_lang => $lang, + charset => $charset, + cat => $cat{$lang}, used_langs => \@LANGUAGES }; + $s{begin}{$lang} = '['.uc($lang).':'; + $s{end}{$lang} = ':'.uc($lang).']'; + $prov_string .= $s{begin}{$lang}.$cat{$lang}->g('virtual package provided by').$s{end}{$lang}; +} + +sub open_file { + my ($key, $vars, $file) = @_; + + $file ||= 'index'; + + print "opening $key\n"; + mkdirp ( "$wwwdir/$key" ); + open($fh{$key}, '>', + "$wwwdir/$key/$file.slices.new") + or die "Cannot open file $wwwdir/$key/$file.slices.new: $!"; + + foreach my $lang (@LANGUAGES) { + print {$fh{$key}} "$s{begin}{$lang}\n"; + $template->page( 'index_head', + { %{$lang_vars{$lang}}, + %$vars }, + $fh{$key}); + print {$fh{$key}} "\n$s{end}{$lang}\n"; + } +} + +sub close_file { + my ($key, $vars, $file) = @_; + + $file ||= 'index'; + + print "closing $key\n"; + + foreach my $lang (@LANGUAGES) { + print {$fh{$key}} "$s{begin}{$lang}\n"; + $template->page( 'index_foot', + { %{$lang_vars{$lang}}, + %$vars }, + $fh{$key}); + print {$fh{$key}} "\n$s{end}{$lang}\n"; + } + close($fh{$key}) + or die "Cannot close file $wwwdir/$key/$file.slices.new: $!"; + + activate("$wwwdir/$key/$file.slices"); +} + + +sub open_txt_file { + my ($key, $vars, $file) = @_; + + $file ||= 'allpackages'; + my $lang = 'en'; + + print "opening $key (txt,lang=$lang)\n"; + mkdirp ( "$wwwdir/$key" ); + $fh{"$key/$lang/txt"} = gzopen("$wwwdir/$key/$file.$lang.txt.gz.new", 'wb9') + or die "Cannot open file $wwwdir/$key/$file.$lang.txt.gz.new: $!"; + + my $gztxt = $txt_template->page( 'index_head', + { %{$lang_vars{$lang}}, + %$vars }); + $fh{"$key/$lang/txt"}->gzwrite($gztxt); +} + +sub close_txt_file { + my ($key, $vars, $file) = @_; + + $file ||= 'allpackages'; + my $lang = 'en'; + + print "closing $key (txt,lang=$lang)\n"; + my $gztxt = $txt_template->page( 'index_foot', + { %{$lang_vars{$lang}}, + %$vars }); + $fh{"$key/$lang/txt"}->gzwrite($gztxt); + ($fh{"$key/$lang/txt"}->gzclose == Z_OK) or + warn("can't close text index file $wwwdir/$key/$file.$lang.txt.gz.new: " + . $fh{"$key/$lang/txt"}->gzerror); + activate("$wwwdir/$key/$file.$lang.txt.gz"); +} + + +print "write headers ...\n"; +foreach my $source (("", "source/")) { + foreach my $s (@SUITES) { + mkdirp ( "$wwwdir/$source$s" ); + my %common_vars = ( suite => $s, + is_source => $source ); + + open_file("$source$s", \%common_vars, 'allpackages'); + open_txt_file("$source$s", \%common_vars, 'allpackages'); + + foreach my $sec (keys %{$sections->{$s}}) { + open_file("$source$s/$sec", + { %common_vars, + category => { id => N_('Section'), + name => $sec }}); + } + foreach my $ssec ((keys %{$subsections->{$s}}, 'virtual')) { + next if $ssec eq '-'; + open_file("$source$s/$ssec", + { %common_vars, + category => { id => N_('Subsection'), + name => $ssec }}); + } + foreach my $prio (keys %{$priorities->{$s}}) { + next if $prio eq '-'; + open_file("$source$s/$prio", + { %common_vars, + category => { id => N_('Priority'), + name => $prio }}); + } + } +} + + +print "processing package info ...\n"; +my $count = 0; +foreach my $pkg (@PACKAGES) { + warn "pkg=$pkg\n" if DEBUG; + print "$count\n" unless ++$count % 1000; + my (%pkg,%virt); - my ($virt, $p_data) = split /\000/o, $data, 2; - %virt = split /\01/o, $virt; + my ($virt, $p_data) = split /\000/o, $packages{$pkg}, 2; + %virt = split /\01/o, $virt; foreach (split /\000/o, $p_data||'') { my @data = split ( /\s/o, $_, 9 ); $pkg{$data[1]} ||= new Packages::Page( $pkg ); @@ -74,15 +209,16 @@ while (my ($pkg, $data) = each %packages) { $pkg{$_}->add_provided_by([split /\s+/, $virt{$_}]); } - while (my ($key, $entry) = each %pkg) { - $allpkgs{$key} ||= []; + while (my ($suite, $entry) = each %pkg) { + warn "\tsuite=$suite\n" if DEBUG; my %p = ( name => $pkg, providers => [], versions => '' ); if (my $provided_by = $entry->{provided_by}) { $p{providers} = $provided_by; - } - $p{subsection} = $p{section} = $p{archive} = $p{desc} = $p{priority} = ''; - unless ($entry->is_virtual) { + } + $p{subsection} = $p{section} = $p{archive} = + $p{desc} = $p{priority} = ''; + unless ($entry->is_virtual) { (undef, $p{versions}) = $entry->get_version_string; $p{subsection} = $entry->get_newest( 'subsection' ); $p{section} = $entry->get_newest( 'section' ); @@ -102,17 +238,80 @@ while (my ($pkg, $data) = each %packages) { } $p{priority} = $entry->get_newest( 'priority' ); } - push @{$allpkgs{$key}}, \%p; + + my $html = my $txt = ""; + my $id = " id='$p{name}'"; + if ($p{versions}) { + warn "\tversions=$p{versions}\n" if DEBUG; + + $html .= "\n
$p{name} ($p{versions})"; + $id = ""; + $html .= " [$p{section}]" + if $p{section} ne 'main'; + $html .= " [$p{archive}]" + if $p{archive} ne 'us'; + $html .= "
\n&"\''), + 'en'); + if ($p{trans_desc}{$lang}) { + $sdesc = $p{trans_desc}{$lang}; + $sdesc_html = encode_entities($sdesc, '<>&"\''); + $desclang = $lang; + } + + $html .= $s{begin}{$lang}; + $html .= " lang='$desclang'" if $desclang ne $lang; + $html .= ">$sdesc_html$s{end}{$lang}"; + } + } else { + $html .= " lang='en'>".encode_entities($p{desc}, '<>&"\''); + } + $html .= ""; + $txt .= $p{desc}; + } + + if (@{$p{providers}}) { + warn "\tproviders=@{$p{providers}}\n" if DEBUG; + $html .= "\n
$p{name}
$prov_string "; + my @prov; + foreach my $prov (@{$p{providers}}) { + my $prov_uri = uri_escape($prov); + push @prov, "$prov"; + } + $html .= join(', ', @prov)."
"; + $txt .= "\n$p{name} virtual package provided by ". + join(', ', @{$p{providers}}); + } + warn "HTML=$html\n" if DEBUG > 1; + warn "TXT=$txt\n" if DEBUG > 1; + + print {$fh{$suite}} $html; + $fh{"$suite/en/txt"}->gzwrite($txt); + foreach my $key (qw(section subsection priority)) { + next unless $fh{"$suite/$p{$key}"}; + warn "\t\t$suite/$p{$key}\n" if DEBUG; + print {$fh{"$suite/$p{$key}"}} $html; + } } } -write_files(\%allpkgs); - print "collecting source package info ...\n"; -my %allsrcpkgs; -while (my ($pkg, $data) = each %src_packages) { - my %pkg; - foreach (split /\000/o, $data||'') { +$count = 0; +foreach my $pkg (@SRC_PACKAGES) { + warn "pkg=$pkg\n" if DEBUG; + print "$count\n" unless ++$count % 1000; + + my %pkg; + foreach (split /\000/o, $src_packages{$pkg}||'') { my @data = split ( /\s/o, $_ ); $pkg{$data[1]} ||= new Packages::SrcPage( $pkg ); $pkg{$data[1]}->merge_package( { package => $pkg, @@ -125,101 +324,78 @@ while (my ($pkg, $data) = each %src_packages) { } ); } - while (my ($key, $entry) = each %pkg) { - $allsrcpkgs{$key} ||= []; - + while (my ($suite, $entry) = each %pkg) { my %p = ( name => $pkg, providers => [], versions => '' ); $p{versions} = $entry->{version}; $p{subsection} = $entry->get_newest( 'subsection' ); $p{section} = $entry->get_newest( 'section' ); $p{archive} = $entry->get_newest( 'archive' ); $p{priority} = $entry->get_newest( 'priority' ); - + $p{desc} = ''; - $p{binaries} = []; -# my $binaries = find_binaries( $pkg, $p{archive}, $p{suite}, \%src2bin ); -# if ($binaries && @$binaries) { -# pkg_list( \%packages, $opts, $binaries, 'en', $contents{binaries} ); -# } + $p{binaries} = []; +# my $binaries = find_binaries( $pkg, $p{archive}, $p{suite}, \%src2bin ); +# if ($binaries && @$binaries) { +# pkg_list( \%packages, $opts, $binaries, 'en', $contents{binaries} ); +# } + + my $html = my $txt = ""; + warn "\tversions=$p{versions}\n" if DEBUG; - push @{$allsrcpkgs{$key}}, \%p; + $html .= "\n
$p{name} ($p{versions})"; + $html .= " [$p{section}]" + if $p{section} ne 'main'; + $html .= " [$p{archive}]" + if $p{archive} ne 'us'; + $html .= "
"; + + $txt .= "\n$p{name} ($p{versions})"; + $txt .= " [$p{section}]" if $p{section} ne 'main'; + $txt .= " [$p{archive}]" if $p{archive} ne 'us'; + + warn "HTML=$html\n" if DEBUG > 1; + warn "TXT=$txt\n" if DEBUG > 1; + + print {$fh{"source/$suite"}} $html; + $fh{"source/$suite/en/txt"}->gzwrite($txt); + foreach my $key (qw(section subsection priority)) { + next unless $fh{"source/$suite/$p{$key}"}; + warn "\t\tsource/$suite/$p{$key}\n" if DEBUG; + print {$fh{"source/$suite/$p{$key}"}} $html; + } } } -write_files(\%allsrcpkgs, 1); -sub write_files { - my ($pkgs, $source) = @_; - - $source = $source ? 'source/' : ''; - print "writing files ...\n"; +print "write footers ...\n"; +foreach my $source (("", "source/")) { foreach my $s (@SUITES) { - 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 = ( po_lang => $lang, ddtp_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 }}); } } } + +__END__ diff --git a/bin/trivial_slice b/bin/trivial_slice new file mode 100755 index 0000000..63c6a2e --- /dev/null +++ b/bin/trivial_slice @@ -0,0 +1,103 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use File::Basename; + +use lib './lib'; + +use Packages::CommonCode qw(:all); + +my @langs; +my @files; + +my $lrx = qr/[a-z]{2}(-[a-z]{2})?/; +my $ulrx = qr/[A-Z]{2}(-[A-Z]{2})?/; + +while ($_ = shift @ARGV) { + last if $_ eq '--'; + + /^$lrx$/ + or die "Invalid lang $_\n"; + + push @langs, $_; +} + +while ($_ = shift @ARGV) { + /\.slices$/ or die "Invalid file $_\n"; + + push @files, $_; +} + +if (!@langs || !@files) { + die "No langs or no files\n"; +} + +warn "langs=@langs\nfiles=@files\n"; + +foreach my $file (@files) { + my ($name, $path, undef) = fileparse($file,qw(.slices)); + + warn "name=$name path=$path out=$path$name.LANG.html.tmp\n"; + + my %out; + foreach my $lang (@langs) { + my $ulang = uc($lang); + open($out{$ulang}, '>', + "$path$name.$lang.html.tmp") + or die "Couldn't open $path$name.$lang.html.tmp\n"; + } + + open my $in, '<', $file + or die "Couldn't open $file\n"; + + my $active_lang; + while (<$in>) { + /^\s*$/o && next; + + /^\[($ulrx):$/o && do { +# warn "open slice $1"; + die "Nested slices" if $active_lang; + die "Unknown lang $1" unless exists $out{$1}; + $active_lang = $1; + next; + }; + /^:($ulrx)\]$/o && do { +# warn "close slice $1"; + die "No open slice" unless $active_lang; + die "Overlapping slices" unless $1 eq $active_lang; + $active_lang = undef; + next; + }; + + !$active_lang && /\[($ulrx):.*?:($ulrx)\]/o && do { +# warn "slices found"; + + foreach my $l (keys %out) { + my $tmp = $_; + + $tmp =~ s/\[\Q$l\E:(.*?):\Q$l\E\]/$1/g; + $tmp =~ s/\[($ulrx):.*?:($ulrx)\]//g; + + print {$out{$l}} $tmp; + } + next; + }; + + if ($active_lang) { + print {$out{$active_lang}} $_; + } else { + foreach my $l (keys %out) { + print {$out{$l}} $_; + } + } + } + + foreach my $lang (keys %out) { + close($out{$lang}) + or die "Couldn't close $path$name.$lang.html.tmp\n"; + activate("$path$name.$lang.html"); + } + +} diff --git a/cron.d/900index_pages b/cron.d/900index_pages index 1213e36..6268c12 100755 --- a/cron.d/900index_pages +++ b/cron.d/900index_pages @@ -4,8 +4,29 @@ cd "$topdir" +set -e + date ./bin/create_suite_index_pages date ./bin/create_index_pages date + +# for file in $(find www/ -name *.slices) +# do +# dir=$(dirname $file) +# base=$(basename $file .slices) +# target= +# for l in $polangs +# do +# lu=$(echo $l|tr /a-z/ /A-Z/) +# target="$target -o ${lu}uUNDEF:$dir/$base.$l.html.tmp" +# done + +# echo slice $target $file +# slice $target $file +# done + +./bin/trivial_slice en $polangs -- $(find www/ -name *.slices) + +date diff --git a/templates/html/index.tmpl b/templates/html/index.tmpl deleted file mode 100644 index cac305c..0000000 --- a/templates/html/index.tmpl +++ /dev/null @@ -1,60 +0,0 @@ -[% PROCESS 'config/archive_layout.tmpl' %] -[% IF is_source; - title_common = category ? g('Source Packages in "%s", %s %s', suite, category.id, category.name) - : g('Source Packages in "%s"', suite); - ELSE; - title_common = category ? g('Software Packages in "%s", %s %s', suite, category.id, category.name) - : g('Software Packages in "%s"', suite); - END; - - nav_arr = [ { prefix=>g('Distribution:'), title=>g('Overview over this suite'), url=>make_url('/','','suite',suite), name=>suite } ]; - IF category; - nav_last = { prefix=>"$category.id:", name=>category.name }; - ELSE; - nav_last = { name=>g('All Packages') }; - END; - nav_arr.push( { name=>g('Source'), - url=>make_url('/','','suite',suite,'source','source') } ) - IF is_source; - nav_arr.push( nav_last ); -%] -[% PROCESS 'html/head.tmpl' - title_tag = title_common - page_title = title_common - keywords = "$suite, $category.name" - navigation = nav_arr -%] - -[% FOREACH p IN packages %] - [% '
' IF loop.first %] - - [% BLOCK marker %] [[% text %]] [%- END %] - [% BLOCK markers %] - [% PROCESS marker text=p.section IF p.section != main_section %] - [% PROCESS marker text=p.archive IF p.archive != main_archive %] - [% END %] - [%- desclang = 'en'; - IF p.trans_desc.$ddtp_lang; - sdesc = p.trans_desc.$ddtp_lang; - desclang = $ddtp_lang; - ELSE; - sdesc = p.desc; - END -%] - [% IF p.providers.size %] -
[% p.name %]
-
[% g('virtual package provided by') %] - [% FOREACH provider IN p.providers %][% provider %] - [%- ', ' UNLESS loop.last %][% END %]
- [% IF p.versions.length %] -
[% p.name %] ([% p.versions %])[% PROCESS markers %]
-
[% sdesc | html %]
- [% END %] - [% ELSE %] -
[% p.name %] ([% p.versions %])[% PROCESS markers %]
-
[% sdesc | html %]
- [% END %] - - [% '
' IF loop.last %] -[% END %] - -[%- PROCESS 'html/foot.tmpl' -%] diff --git a/templates/html/index_foot.tmpl b/templates/html/index_foot.tmpl new file mode 100644 index 0000000..23db4cf --- /dev/null +++ b/templates/html/index_foot.tmpl @@ -0,0 +1,3 @@ + + +[%- PROCESS 'html/foot.tmpl' -%] diff --git a/templates/html/index_head.tmpl b/templates/html/index_head.tmpl new file mode 100644 index 0000000..43fe97c --- /dev/null +++ b/templates/html/index_head.tmpl @@ -0,0 +1,27 @@ +[% IF is_source; + title_common = category ? g('Source Packages in "%s", %s %s', suite, g(category.id), category.name) + : g('Source Packages in "%s"', suite); + ELSE; + title_common = category ? g('Software Packages in "%s", %s %s', suite, g(category.id), category.name) + : g('Software Packages in "%s"', suite); + END; + + nav_arr = [ { prefix=>g('Distribution:'), title=>g('Overview over this suite'), url=>make_url('/','','suite',suite), name=>suite } ]; + IF category; + nav_last = { prefix=>g(category.id) _ ":", name=>category.name }; + ELSE; + nav_last = { name=>g('All Packages') }; + END; + nav_arr.push( { name=>g('Source'), + url=>make_url('/','','suite',suite,'source','source') } ) + IF is_source; + nav_arr.push( nav_last ); +%] +[% PROCESS 'html/head.tmpl' + title_tag = title_common + page_title = title_common + keywords = "$suite, $category.name" + navigation = nav_arr +%] + +
diff --git a/templates/txt/index.tmpl b/templates/txt/index.tmpl deleted file mode 100644 index 226f03e..0000000 --- a/templates/txt/index.tmpl +++ /dev/null @@ -1,20 +0,0 @@ -[%- PROCESS 'config/archive_layout.tmpl' -%] -[% g('All %s Packages in "%s"', organisation, suite) %] - -[% g('Generated:') _ ' ' _ timestamp.string %] -[% g('Copyright ©') _ ' ' _ copyright.years _ ' ' _ copyright.name %]; -[% g('See for the license terms.', license.url) %] - -[% FOREACH packages -%] - [%- BLOCK marker %] [[% text %]][% END -%] - [%- BLOCK markers -%] - [%- PROCESS marker text=section IF section != main_section -%] - [%- PROCESS marker text=archive IF archive != main_archive -%] - [%- END -%] - [%- IF providers.size %] -[% name %] [% g('virtual package provided by') _ ' ' _ providers.join(', ') %] - [%- END -%] - [%- IF versions %] -[% name %] ([% versions %])[% PROCESS markers %] [% desc %] - [%- END -%] -[%- END %] diff --git a/templates/txt/index_foot.tmpl b/templates/txt/index_foot.tmpl new file mode 100644 index 0000000..e69de29 diff --git a/templates/txt/index_head.tmpl b/templates/txt/index_head.tmpl new file mode 100644 index 0000000..7fd13a3 --- /dev/null +++ b/templates/txt/index_head.tmpl @@ -0,0 +1,5 @@ +[% g('All %s Packages in "%s"', organisation, suite) %] + +[% g('Generated:') _ ' ' _ timestamp.string %] +[% g('Copyright ©') _ ' ' _ copyright.years _ ' ' _ copyright.name %]; +[% g('See for the license terms.', license.url) %] -- 2.39.2