]> git.deb.at Git - deb/packages.git/commitdiff
Clean up footer handling
authorFrank Lichtenheld <frank@lichtenheld.de>
Mon, 18 Jun 2007 12:36:35 +0000 (14:36 +0200)
committerFrank Lichtenheld <frank@lichtenheld.de>
Mon, 18 Jun 2007 17:43:00 +0000 (19:43 +0200)
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.

17 files changed:
bin/create_index_pages
bin/parse-debtags-voc
cgi-bin/dispatcher.pl
lib/Packages/DoShow.pm
lib/Packages/Template.pm
templates/html/download.tmpl
templates/html/error.tmpl
templates/html/foot.tmpl
templates/html/index.tmpl
templates/html/newpkg.tmpl
templates/html/search.tmpl
templates/html/search_contents.tmpl
templates/html/show.tmpl
templates/html/suite_index.tmpl
templates/html/tag_index.tmpl
templates/rfc822/foot.tmpl [deleted file]
templates/rss/foot.tmpl [deleted file]

index 79d6e9e78b016bba7c35c93811abdad842263451..2c62033ddce7a22d6a3155b906ad7b99ce214904 100755 (executable)
@@ -71,7 +71,7 @@ foreach my $s (@SUITES) {
 
        my %content = ( subsections => [], suite => $s,
                        lang => $lang, charset => $charset,
 
        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
        $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 );
        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",
        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 );
        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",
        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",
index ebd65471b33dd2af1c8beb61565e02c76cd4e969..4caf0b0444089302c5567f93b6c6d6cf22fde7ec 100755 (executable)
@@ -120,7 +120,6 @@ $content{quotemeta} = sub { return quotemeta($_[0]) };
 $content{string2id} = sub { return &Packages::CGI::string2id(@_) };
 
 print TAGLST $template->page( 'tag_index', \%content );
 $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",
 close TAGLST or warn "Couldn't close tag list: $!";
 
 rename( "$wwwdir/debtags.en.html.new",
index b4374cbe99d56df4bec424dc6b589e4c416f1985..adbee1c6fadb826ad3b77a4a59c9056993345d9a 100755 (executable)
@@ -125,8 +125,9 @@ if (my $path = $input->path_info() || $input->param('PATH_INFO')) {
 
     push @components, 'index' if @components && $path =~ m,/$,;
 
 
     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') {
        $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 '<pre>'.Dumper(\%ENV, \%page_content, get_all_messages()).'</pre>';
     print $template->page( $what_to_do, { %page_content, %{ get_all_messages() } } );
     #use Data::Dumper;
     #print '<pre>'.Dumper(\%ENV, \%page_content, get_all_messages()).'</pre>';
     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 {
 } 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() );
     # so no format support here
     print $input->header( -charset => $charset );
     print $template->error_page( get_all_messages() );
-    print $template->trailer();;
 }
 
 
 }
 
 
index 419c59799ca7feba0b3bc8eecc36396a8001de7d..1d21462878d4dbcf0e2a21f8e9d16c48000bcab8 100644 (file)
@@ -175,6 +175,7 @@ sub do_show {
                        my $trans_desc = $desctrans{$desc_md5};
                        if ($trans_desc) {
                            my %trans_desc = split /\000|\001/, $trans_desc;
                        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) {
                            debug( "TRANSLATIONS: ".join(" ",keys %trans_desc), 2)
                                if DEBUG;
                            while (my ($l, $d) = each %trans_desc) {
index 7d85f46ba1cd53b1c3315bfc32525df0d89775c6..554f2ce0e4c8551248ad625a9d0224190c1fff01 100644 (file)
@@ -38,6 +38,7 @@ sub new {
        %$options,
     } ) or fatal_error( sprintf( _g( "Initialization of Template Engine failed: %s" ), $Template::ERROR ) );
     $self->{format} = $format;
        %$options,
     } ) or fatal_error( sprintf( _g( "Initialization of Template Engine failed: %s" ), $Template::ERROR ) );
     $self->{format} = $format;
+    $self->{vars} = $vars;
 
     return $self;
 }
 
     return $self;
 }
@@ -56,6 +57,10 @@ sub page {
 
     #use Data::Dumper;
     #die Dumper($self, $action, $page_content);
 
     #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)
 
     my $txt;
     $self->process("$self->{format}/$action.tmpl", $page_content, \$txt)
@@ -77,18 +82,6 @@ sub error_page {
     return $txt;
 }
 
     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 ) = @_;
     
 sub languages {
     my ( $lang, @used_langs ) = @_;
     
index e08aff21b00be974e416b4f49615242f3cd84e25..27a4cf5b4733dff42d7cbd6e3595dfc62a5ffa41 100644 (file)
@@ -113,3 +113,5 @@ For example, in Firefox or Mozilla, you should hold the Shift key when you click
 <tr><th>SHA1 checksum</th>             <td><tt>[% sha1 || 'Not Available' %]</tt></td>
 <tr><th>SHA256 checksum</th>           <td><tt>[% sha256  || 'Not Available' %]</tt></td>
 </table>
 <tr><th>SHA1 checksum</th>             <td><tt>[% sha1 || 'Not Available' %]</tt></td>
 <tr><th>SHA256 checksum</th>           <td><tt>[% sha256  || 'Not Available' %]</tt></td>
 </table>
+
+[%- PROCESS 'html/foot.tmpl' -%]
index 72c4fd49107757d31e34fd89ecd016d1e986237f..6c0cd8964885610ec64a17ff19399ae64f52131d 100644 (file)
@@ -2,3 +2,5 @@
    title_tag = 'Error'
    page_title = 'Error'
 -%]
    title_tag = 'Error'
    page_title = 'Error'
 -%]
+
+[%- PROCESS 'html/foot.tmpl' -%]
index c7c273ea3fc38a5079dcaef7d742c090ee094bea..f54d494fd188c6032d9da1b5464014662a7db833 100644 (file)
@@ -11,7 +11,7 @@ Total page evaluation took [% benchmark %]<br>
 <p>This page is also available in the following languages:</p>
 <p class="navpara">
 [% FOREACH langs %]
 <p>This page is also available in the following languages:</p>
 <p class="navpara">
 [% FOREACH langs %]
-<a href="[% "$name?lang=$lang" %]" title="[% tooltip %]" hreflang="[% lang %]" lang="[% lang %]" rel="alternate">[% selfname %]
+<a href="[% "$page_name?lang=$lang" %]" title="[% tooltip %]" hreflang="[% lang %]" lang="[% lang %]" rel="alternate">[% selfname %]
 [%- IF transliteration %] ([% transliteration %])[% END %]</a>
 [% END %]
 </p>
 [%- IF transliteration %] ([% transliteration %])[% END %]</a>
 [% END %]
 </p>
index 9daa9a5d0542d4157efadfe865a6c7639b36ba3c..11cab5ceee6e2ed3dee2a745109df6f2b3b7ec7a 100644 (file)
@@ -43,3 +43,5 @@
 
   [% '</dl>' IF loop.last %]
 [% END %]
 
   [% '</dl>' IF loop.last %]
 [% END %]
+
+[%- PROCESS 'html/foot.tmpl' -%]
index cfa6bd3288abe316bd5c409d9257033f95c5f198..016dcb5b2623d64168f1ac33fb96cd1061716dd0 100644 (file)
@@ -28,4 +28,6 @@
   [%- END -%]
 [% ', ' UNLESS loop.last %]
 [% END %]
   [%- END -%]
 [% ', ' UNLESS loop.last %]
 [% END %]
-</p>
\ No newline at end of file
+</p>
+
+[%- PROCESS 'html/foot.tmpl' -%]
index bbb4cde6e93d408f05d5ed8ccdd35da2018a119f..9eafd1ee313428e0bf9a35575e982c3a0096b7f2 100644 (file)
@@ -123,3 +123,5 @@ Please consider using a longer keyword or more keywords.</p>
 [% END %]
 
 </div>
 [% END %]
 
 </div>
+
+[%- PROCESS 'html/foot.tmpl' -%]
index 77836fec87bea076604d16068923c42564b4d5b9..7cfc54fa77846bc1e6d7934a33cddf279a874dd3 100644 (file)
@@ -125,3 +125,5 @@ Please consider using a longer keyword or more keywords.</p>
 <p id="psearchnoresult">Sorry, your search gave no results</p>
 
 [% END %]
 <p id="psearchnoresult">Sorry, your search gave no results</p>
 
 [% END %]
+
+[%- PROCESS 'html/foot.tmpl' -%]
index 0ef593e7bafd9bc51598bbe2d90ee15d9b4bb78f..c4b1e904f1bd7df684e1fffbf8a2f2a8f00a4fa7 100644 (file)
@@ -315,3 +315,4 @@ Do not install it on a normal Debian system.</p>
 
 <script type="text/javascript">init_tab_list("ptablist")</script>
 
 
 <script type="text/javascript">init_tab_list("ptablist")</script>
 
+[%- PROCESS 'html/foot.tmpl' -%]
index 92b7d97a590f2dd1e456140edc9817a12b2c544f..465c6930ae0e125483a3a7e78b310457e4f10f2a 100644 (file)
@@ -39,3 +39,5 @@
        <a href="allpackages" title="List of all [% "source " IF source %]packages">All [% "source " IF source %]packages</a><br>
        (<a href="allpackages?format=txt.gz">compact compressed textlist</a>)
 </p>
        <a href="allpackages" title="List of all [% "source " IF source %]packages">All [% "source " IF source %]packages</a><br>
        (<a href="allpackages?format=txt.gz">compact compressed textlist</a>)
 </p>
+
+[%- PROCESS 'html/foot.tmpl' -%]
index df51e22483207f853f1c30437f83b17ac54884f7..1df4853cbfe0a82d3d275fd34bfe2c7961d44db6 100644 (file)
@@ -21,3 +21,5 @@
        [% END %]
 
 [% END %]
        [% END %]
 
 [% END %]
+
+[%- PROCESS 'html/foot.tmpl' -%]
diff --git a/templates/rfc822/foot.tmpl b/templates/rfc822/foot.tmpl
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/templates/rss/foot.tmpl b/templates/rss/foot.tmpl
deleted file mode 100644 (file)
index e69de29..0000000