]> git.deb.at Git - deb/packages.git/commitdiff
create_index_pages: Make common functions available to all templates
authorFrank Lichtenheld <frank@lichtenheld.de>
Fri, 14 Sep 2007 20:35:16 +0000 (22:35 +0200)
committerFrank Lichtenheld <frank@lichtenheld.de>
Fri, 14 Sep 2007 20:35:16 +0000 (22:35 +0200)
The common functions were only available in suite_index.tmpl, but not
in index.tmpl. Fix that by giving them to the initial Packages::Template->new
call.

bin/create_index_pages

index 30962ea8653bef1dc4ab969ca8c77ad5b14bc5c9..8586671bdbbffb52616d7d331ab4d6255ebb02f1 100755 (executable)
@@ -49,9 +49,16 @@ my $priorities = retrieve "$DBDIR/priorities.info";
 #use Data::Dumper;
 #print STDERR Dumper($sections, $subsections, $priorities);
 
 #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) {
 
 print "write suite index files ...\n";
 foreach my $s (@SUITES) {
@@ -70,13 +77,6 @@ foreach my $s (@SUITES) {
        my %content = ( subsections => [], suite => $s,
                        lang => $lang, charset => $charset,
                        used_langs => \@LANGUAGES, suites => \@SUITES );
        my %content = ( subsections => [], suite => $s,
                        lang => $lang, charset => $charset,
                        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{html_encode} = sub { return HTML::Entities::encode_entities(@_,'<>&"') };
-       $content{uri_escape} = sub { return URI::Escape::uri_escape(@_) };
-       $content{quotemeta} = sub { return quotemeta($_[0]) };
-
        foreach my $ssec ((keys %{$subsections->{$s}}, 'virtual')) {
            next if $ssec eq '-';
            if ($sections_descs{$ssec}) {
        foreach my $ssec ((keys %{$subsections->{$s}}, 'virtual')) {
            next if $ssec eq '-';
            if ($sections_descs{$ssec}) {