]> git.deb.at Git - deb/packages.git/commitdiff
Display the index pages from within dispatcher.pl. That reduces the complexity
authorFrank Lichtenheld <frank@lichtenheld.de>
Wed, 22 Feb 2006 22:20:20 +0000 (22:20 +0000)
committerFrank Lichtenheld <frank@lichtenheld.de>
Wed, 22 Feb 2006 22:20:20 +0000 (22:20 +0000)
of the Apache setup

bin/create_index_pages
cgi-bin/dispatcher.pl
conf/apache.conf
lib/Packages/DoIndex.pm [new file with mode: 0644]
lib/Packages/DoShow.pm

index d9dc8b43b60bc000a9380631941bffabd23b53a8..8b20ebd7fcf010be4e0306ea4b18d328a990c965 100755 (executable)
@@ -61,7 +61,7 @@ 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: $!";
            my $index_title = sprintf( _g( "List of sections in \"%s\"" ),
-                                      $s );
+                                      $key );
            print {$pages{$key}{$lang}{index}{fh}} header( title => $index_title,
                                                           title_keywords => "debian, $s",
                                                           desc => encode_entities( $index_title, '"' ),
@@ -105,7 +105,7 @@ foreach my $s (@SUITES) {
            or die "can't open index file for output: $!";
 
        my $title = sprintf( _g( "Software Packages in \"%s\"" ),
-                            $s );
+                            $key );
        print {$pages{$key}{fh}} header( title => $title,
                                         title_keywords => "debian, $s",
                                         desc => encode_entities( $title, '"' ),
@@ -117,7 +117,7 @@ foreach my $s (@SUITES) {
            open $pages{$key}{$sec}{fh}, '>', "$wwwdir/$key/$sec/index.en.html.new"
                or die "can't open index file for output: $!";
            $title = sprintf( _g( "Software Packages in \"%s\", section %s" ),
-                             $s, $sec );
+                             $key, $sec );
            print {$pages{$key}{$sec}{fh}} header( title => $title,
                                                   title_keywords => "debian, $s, $sec",
                                                   desc => encode_entities( $title, '"' ),
@@ -130,7 +130,7 @@ foreach my $s (@SUITES) {
            open $pages{$key}{$ssec}{fh}, '>', "$wwwdir/$key/$ssec/index.en.html.new"
                or die "can't open index file for output: $!";
            $title = sprintf( _g( "Software Packages in \"%s\", subsection %s" ),
-                             $s, $ssec );
+                             $key, $ssec );
            print {$pages{$key}{$ssec}{fh}} header( title => $title,
                                                    title_keywords => "debian, $s, $ssec",
                                                    desc => encode_entities( $title, '"' ),
@@ -143,7 +143,7 @@ foreach my $s (@SUITES) {
            open $pages{$key}{$prio}{fh}, '>', "$wwwdir/$key/$prio/index.en.html.new"
                or die "can't open index file for output: $!";
            $title = sprintf( _g( "Software Packages in \"%s\", priority %s" ),
-                             $s, $prio );
+                             $key, $prio );
            print {$pages{$key}{$prio}{fh}} header( title => $title,
                                                    title_keywords => "debian, $s, $prio",
                                                    desc => encode_entities( $title, '"' ),
index b0913eab684e2bea963f85224af167bf3818cd5f..99c547998e54ac98405383c8ec4190e62665fd63 100755 (executable)
@@ -32,6 +32,7 @@ use Packages::I18N::Locale;
 use Packages::DoSearch;
 use Packages::DoSearchContents;
 use Packages::DoShow;
+use Packages::DoIndex;
 use Packages::DoDownload;
 use Packages::DoFilelist;
 
@@ -75,17 +76,19 @@ my $source = 0;
 if (my $path = $input->path_info() || $input->param('PATH_INFO')) {
     my @components = grep { $_ } map { lc $_ } split /\/+/, $path;
 
-    debug( "components[0]=$components[0]", 2 ) if @components>0;
+    push @components, 'index' if $path =~ m,/$,;
+
+    debug( "components[0]=$components[0]", 2 ) if DEBUG and @components>0;
     if (@components > 0 and $components[0] eq 'source') {
        shift @components;
        $input->param( 'source', 1 );
     }
-    if (@components > 0 and $components[0] eq 'search') {
+    if (@components > 1 and $components[0] eq 'search') {
        shift @components;
        $what_to_do = 'search';
        # Done
        fatal_error( _g( "search doesn't take any more path elements" ) )
-           if @components > 0;
+           if @components;
     } elsif (@components == 0) {
        fatal_error( _g( "We're supposed to display the homepage here, instead of getting dispatch.pl" ) );
     } elsif (@components == 1) {
@@ -93,7 +96,7 @@ if (my $path = $input->path_info() || $input->param('PATH_INFO')) {
     } else {
 
        for ($components[-1]) {
-           /^(changelog|copyright|download|filelist)$/ && do {
+           /^(index|changelog|copyright|download|filelist)$/ && do {
                pop @components;
                $what_to_do = $1;
                last;
@@ -220,8 +223,6 @@ my $pet1 = new Benchmark;
 my $petd = timediff($pet1, $pet0);
 debug( "Parameter evaluation took ".timestr($petd) ) if DEBUG;
 
-print $input->header( -charset => $charset );
-
 my (%html_header, $menu, $page_content);
 unless (@Packages::CGI::fatal_errors) {
     no strict 'refs';
@@ -244,6 +245,8 @@ unless (@Packages::CGI::fatal_errors) {
                     );
 }
 
+print $input->header( -charset => $charset );
+
 print Packages::HTML::header( %html_header );
 
 print $menu||'';
index 5c1248c52eda6bbc54e4152ef48bbc48971143cb..29a9b835e9ab46f37075a89b6e260d5b45a8dc02 100644 (file)
 
    RewriteEngine on
    RewriteLog /var/log/apache/rewrite.log
-   RewriteLogLevel 9
+   RewriteLogLevel 0
 
    # we never want to rewrite those URLs
    RewriteRule ^/cgi-(bin|old)/ - [L]
    RewriteRule ^/Pics/ - [L]
    RewriteRule ^/[^/]+\.css - [L]
 
-   RewriteCond %{DOCUMENT_ROOT}/%{SCRIPT_FILENAME} "-f"
-   RewriteRule ^. - [L]
-
-   RewriteCond %{DOCUMENT_ROOT}/%{SCRIPT_FILENAME}.en.html "-f"
-   RewriteRule ^. - [L]
-
-   RewriteCond %{DOCUMENT_ROOT}/%{SCRIPT_FILENAME} "-d"
-   RewriteRule ^. - [L]
-
 #   RewriteRule ^/$ http://www.debian.org/distrib/packages
    RewriteRule ^/([^/+]*)([+])([^/]*)$ "/$1%%{%}2B$3" [N]
    RewriteRule ^/src:([^/]+)$ /search/source/$1 [R,L,NE]
diff --git a/lib/Packages/DoIndex.pm b/lib/Packages/DoIndex.pm
new file mode 100644 (file)
index 0000000..3e6041d
--- /dev/null
@@ -0,0 +1,73 @@
+package Packages::DoIndex;
+
+use strict;
+use warnings;
+
+use CGI qw( :cgi );
+use Exporter;
+
+use Deb::Versions;
+use Packages::Config qw( $TOPDIR );
+use Packages::I18N::Locale;
+use Packages::CGI;
+
+our @ISA = qw( Exporter );
+our @EXPORT = qw( do_index );
+
+sub do_index {
+    my ($params, $opts, $html_header) = @_;
+
+    if ($params->{errors}{suite}) {
+       fatal_error( _g( "suite not valid or not specified" ) );
+    }
+    if (@{$opts->{suite}} > 1) {
+       fatal_error( sprintf( _g( "more than one suite specified for show_static (%s)" ), "@{$opts->{suite}}" ) );
+    }
+    if (@{$opts->{subsection}} > 1) {
+       fatal_error( sprintf( _g( "more than one suite specified for show_static (%s)" ), "@{$opts->{suite}}" ) );
+    }
+
+    my $wwwdir = "$TOPDIR/www";
+    my $path = "$opts->{suite}[0]/";
+    $path .= "$opts->{archive}[0]/" if @{$opts->{archive}} == 1;
+    $path .= "$opts->{subsection}[0]/" if @{$opts->{subsection}};
+    # we don't have translated index pages for subsections yet
+    $opts->{lang} = 'en' if @{$opts->{subsection}};
+    $path .= "index.$opts->{lang}.html";
+
+    unless (@Packages::CGI::fatal_errors) {
+       my $buffer;
+       if (open( INDEX, '<', "$wwwdir/$path" )) {
+           my $charset = get_charset( $opts->{lang} );
+           print header( -charset => $charset );
+
+           binmode INDEX;
+           while (read INDEX, $buffer, 4096) {
+               print $buffer;
+           }
+           close INDEX;
+           exit;
+       } else {
+           fatal_error( sprintf( _g( "couldn't read index file %s: %s" ),
+                                 $path, $! ) );
+       }
+    }
+
+    %$html_header = ( title => _g('Error'),
+                     lang => $opts->{lang},
+                     print_title => 1,
+                     print_search_field => 'packages',
+                     search_field_values => { 
+                         keywords => _g('search for a package'),
+                         searchon => 'default',
+                         arch => 'any',
+                         suite => 'all',
+                         section => 'all',
+                         exact => 1,
+                         debug => $Packages::Search::debug,
+                     },
+                     );
+}
+
+1;
+
index 08eb376d236ddb237999af2258cae7048eabb64d..b5a12876b58cc3caba94dfcafab19d57d68755bc 100644 (file)
@@ -163,7 +163,7 @@ sub do_show {
 
                        my $v_str = $version;
                        my $multiple_versions = grep { $_ ne $version } values %$versions;
-                       $v_str .= " (and others)" if $multiple_versions;
+                       $v_str .= _g(" and others") if $multiple_versions;
                        my $title .= sprintf( _g( "Package: %s (%s)" ), $pkg, $v_str );
                        $title .=  " ".marker( $archive ) if $archive ne 'us';
                        $title .=  " ".marker( $subsection ) if $subsection eq 'non-US'