From: Frank Lichtenheld Date: Mon, 18 Jun 2007 12:36:35 +0000 (+0200) Subject: Clean up footer handling X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=bedf14e393ba83316aca3e442c14f24914a6cd84;p=deb%2Fpackages.git Clean up footer handling Remove Packages::Template->trailer which essentially forced any format to have a foot.tmpl even it made no sense for them. Now formats that want something like that can handle it themself. Fix handling of languages in the footer so that we get a list of available translations again. Currently this only reflects DDTP translations since the po stuff isn't reenabled yet since the switch to templates. --- diff --git a/bin/create_index_pages b/bin/create_index_pages index 79d6e9e..2c62033 100755 --- a/bin/create_index_pages +++ b/bin/create_index_pages @@ -71,7 +71,7 @@ foreach my $s (@SUITES) { my %content = ( subsections => [], suite => $s, lang => $lang, charset => $charset, - suites => \@SUITES ); + used_langs => \@LANGUAGES, suites => \@SUITES ); $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 @@ -93,7 +93,6 @@ 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", @@ -103,7 +102,6 @@ foreach my $s (@SUITES) { 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 ); - print {$pages{$key}{$lang}{source_index}{fh}} $template->trailer( 'index', $lang, \@LANGUAGES ); 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", diff --git a/bin/parse-debtags-voc b/bin/parse-debtags-voc index ebd6547..4caf0b0 100755 --- a/bin/parse-debtags-voc +++ b/bin/parse-debtags-voc @@ -120,7 +120,6 @@ $content{quotemeta} = sub { return quotemeta($_[0]) }; $content{string2id} = sub { return &Packages::CGI::string2id(@_) }; print TAGLST $template->page( 'tag_index', \%content ); -print TAGLST $template->trailer(); close TAGLST or warn "Couldn't close tag list: $!"; rename( "$wwwdir/debtags.en.html.new", diff --git a/cgi-bin/dispatcher.pl b/cgi-bin/dispatcher.pl index b4374cb..adbee1c 100755 --- a/cgi-bin/dispatcher.pl +++ b/cgi-bin/dispatcher.pl @@ -125,8 +125,9 @@ if (my $path = $input->path_info() || $input->param('PATH_INFO')) { push @components, 'index' if @components && $path =~ m,/$,; - my %LANGUAGES = map { $_ => 1 } @LANGUAGES; - if (@components > 0 and $LANGUAGES{$components[0]}) { + my %LANGUAGES = map { $_ => 1 } @all_langs; + if (@components > 0 and $LANGUAGES{$components[0]} + and !$input->param('lang')) { $input->param( 'lang', shift(@components) ); } if (@components > 0 and $components[0] eq 'source') { @@ -321,9 +322,6 @@ unless (@Packages::CGI::fatal_errors) { #use Data::Dumper; #print '
'.Dumper(\%ENV, \%page_content, get_all_messages()).'
'; print $template->page( $what_to_do, { %page_content, %{ get_all_messages() } } ); - my $tet1 = new Benchmark; - my $tetd = timediff($tet1, $tet0); - print $template->trailer( undef, undef, undef, $tetd ); } elsif ($Packages::CGI::http_code && $Packages::CGI::http_code !~ /^2\d\d/) { print $input->header( -charset => $charset, -status => $Packages::CGI::http_code ); } else { @@ -331,7 +329,6 @@ unless (@Packages::CGI::fatal_errors) { # so no format support here print $input->header( -charset => $charset ); print $template->error_page( get_all_messages() ); - print $template->trailer();; } diff --git a/lib/Packages/DoShow.pm b/lib/Packages/DoShow.pm index 419c597..1d21462 100644 --- a/lib/Packages/DoShow.pm +++ b/lib/Packages/DoShow.pm @@ -175,6 +175,7 @@ sub do_show { my $trans_desc = $desctrans{$desc_md5}; if ($trans_desc) { my %trans_desc = split /\000|\001/, $trans_desc; + $contents{used_langs} = ['en', sort keys %trans_desc]; debug( "TRANSLATIONS: ".join(" ",keys %trans_desc), 2) if DEBUG; while (my ($l, $d) = each %trans_desc) { diff --git a/lib/Packages/Template.pm b/lib/Packages/Template.pm index 7d85f46..554f2ce 100644 --- a/lib/Packages/Template.pm +++ b/lib/Packages/Template.pm @@ -38,6 +38,7 @@ sub new { %$options, } ) or fatal_error( sprintf( _g( "Initialization of Template Engine failed: %s" ), $Template::ERROR ) ); $self->{format} = $format; + $self->{vars} = $vars; return $self; } @@ -56,6 +57,10 @@ sub page { #use Data::Dumper; #die Dumper($self, $action, $page_content); + $page_content->{used_langs} ||= [ 'en' ]; + $page_content->{langs} = languages( $page_content->{lang} + || $self->{vars}{lang} || 'en', + @{$page_content->{used_langs}} ); my $txt; $self->process("$self->{format}/$action.tmpl", $page_content, \$txt) @@ -77,18 +82,6 @@ sub error_page { return $txt; } -sub trailer { - my ($self, $NAME, $LANG, $USED_LANGS, $timediff) = @_; - - my $langs = languages( $LANG, @$USED_LANGS ); - - my $txt; - $self->process("$self->{format}/foot.tmpl", { langs => $langs, name => $NAME, benchmark => $timediff ? timestr($timediff) : '' }, \$txt) - or die sprintf( "template error: %s", $self->error ); # too late for reporting on-line - - return $txt; -} - sub languages { my ( $lang, @used_langs ) = @_; diff --git a/templates/html/download.tmpl b/templates/html/download.tmpl index e08aff2..27a4cf5 100644 --- a/templates/html/download.tmpl +++ b/templates/html/download.tmpl @@ -113,3 +113,5 @@ For example, in Firefox or Mozilla, you should hold the Shift key when you click SHA1 checksum [% sha1 || 'Not Available' %] SHA256 checksum [% sha256 || 'Not Available' %] + +[%- PROCESS 'html/foot.tmpl' -%] diff --git a/templates/html/error.tmpl b/templates/html/error.tmpl index 72c4fd4..6c0cd89 100644 --- a/templates/html/error.tmpl +++ b/templates/html/error.tmpl @@ -2,3 +2,5 @@ title_tag = 'Error' page_title = 'Error' -%] + +[%- PROCESS 'html/foot.tmpl' -%] diff --git a/templates/html/foot.tmpl b/templates/html/foot.tmpl index c7c273e..f54d494 100644 --- a/templates/html/foot.tmpl +++ b/templates/html/foot.tmpl @@ -11,7 +11,7 @@ Total page evaluation took [% benchmark %]

This page is also available in the following languages:

diff --git a/templates/html/index.tmpl b/templates/html/index.tmpl index 9daa9a5..11cab5c 100644 --- a/templates/html/index.tmpl +++ b/templates/html/index.tmpl @@ -43,3 +43,5 @@ [% '' IF loop.last %] [% END %] + +[%- PROCESS 'html/foot.tmpl' -%] diff --git a/templates/html/newpkg.tmpl b/templates/html/newpkg.tmpl index cfa6bd3..016dcb5 100644 --- a/templates/html/newpkg.tmpl +++ b/templates/html/newpkg.tmpl @@ -28,4 +28,6 @@ [%- END -%] [% ', ' UNLESS loop.last %] [% END %] -

\ No newline at end of file +

+ +[%- PROCESS 'html/foot.tmpl' -%] diff --git a/templates/html/search.tmpl b/templates/html/search.tmpl index bbb4cde..9eafd1e 100644 --- a/templates/html/search.tmpl +++ b/templates/html/search.tmpl @@ -123,3 +123,5 @@ Please consider using a longer keyword or more keywords.

[% END %] + +[%- PROCESS 'html/foot.tmpl' -%] diff --git a/templates/html/search_contents.tmpl b/templates/html/search_contents.tmpl index 77836fe..7cfc54f 100644 --- a/templates/html/search_contents.tmpl +++ b/templates/html/search_contents.tmpl @@ -125,3 +125,5 @@ Please consider using a longer keyword or more keywords.

Sorry, your search gave no results

[% END %] + +[%- PROCESS 'html/foot.tmpl' -%] diff --git a/templates/html/show.tmpl b/templates/html/show.tmpl index 0ef593e..c4b1e90 100644 --- a/templates/html/show.tmpl +++ b/templates/html/show.tmpl @@ -315,3 +315,4 @@ Do not install it on a normal Debian system.

+[%- PROCESS 'html/foot.tmpl' -%] diff --git a/templates/html/suite_index.tmpl b/templates/html/suite_index.tmpl index 92b7d97..465c693 100644 --- a/templates/html/suite_index.tmpl +++ b/templates/html/suite_index.tmpl @@ -39,3 +39,5 @@ All [% "source " IF source %]packages
(compact compressed textlist)

+ +[%- PROCESS 'html/foot.tmpl' -%] diff --git a/templates/html/tag_index.tmpl b/templates/html/tag_index.tmpl index df51e22..1df4853 100644 --- a/templates/html/tag_index.tmpl +++ b/templates/html/tag_index.tmpl @@ -21,3 +21,5 @@ [% END %] [% END %] + +[%- PROCESS 'html/foot.tmpl' -%] diff --git a/templates/rfc822/foot.tmpl b/templates/rfc822/foot.tmpl deleted file mode 100644 index e69de29..0000000 diff --git a/templates/rss/foot.tmpl b/templates/rss/foot.tmpl deleted file mode 100644 index e69de29..0000000