From 0e2a94fd63e8f95dac115fde72163cf44aba9290 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Sat, 4 Jul 2009 23:33:22 +0200 Subject: [PATCH] Emply various dark magic, so that the language override works for the homepage Oh, so many parts of this need a clean rewrite... --- conf/apache.conf.sed.in | 13 +++++++------ lib/Packages/Dispatcher.pm | 6 +++++- lib/Packages/DoIndex.pm | 9 +++++++-- templates/html/homepage.tmpl | 2 +- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/conf/apache.conf.sed.in b/conf/apache.conf.sed.in index b0b33e3..91833a6 100644 --- a/conf/apache.conf.sed.in +++ b/conf/apache.conf.sed.in @@ -111,22 +111,23 @@ RewriteRule ^/robots.txt$ - [L] # RewriteRule ^/$ http://www.debian.org/distrib/packages - RewriteRule ^/$ /index.html [L] + RewriteRule ^/$ /index [L] RewriteRule ^/([^/+]*)([+])([^/]*)$ "/$1%%{%}2B$3" [N] RewriteRule ^/changelog:(.+)$ /changelogs/${changelog-url:$1} [R,L,NE] RewriteRule ^/src:([^/]+)$ /search?searchon=sourcenames&keywords=$1 [R,L,NE] RewriteRule ^/file:(.+)$ /search?searchon=contents&keywords=$1 [R,L,NE] - RewriteCond %{QUERY_STRING} ^$ [OR] - RewriteCond %{REQUEST_URI} !^/search$ - RewriteCond %{REQUEST_URI} !^/cgi-bin/search_(contents|packages)\.pl$ - RewriteRule ^/([^/]+)$ /search?keywords=$1 [R,L,NE] - + RewriteCond %{QUERY_STRING} ="" RewriteCond %TOPDIR%/www%{REQUEST_FILENAME} -f [OR] RewriteCond %TOPDIR%/www%{REQUEST_FILENAME}.en.html -f [OR] RewriteCond %TOPDIR%/www%{REQUEST_FILENAME} -l RewriteRule . - [L] + RewriteCond %{QUERY_STRING} ^$ [OR] + RewriteCond %{REQUEST_URI} !^/search$ + RewriteCond %{REQUEST_URI} !^/cgi-bin/search_(contents|packages)\.pl$ + RewriteRule ^/([^/]+)$ /search?keywords=$1 [R,L,NE] + RewriteRule ^/(.+)$ /cgi-bin/dispatcher.pl/$1 [L,PT] # In case we need to disable the site again diff --git a/lib/Packages/Dispatcher.pm b/lib/Packages/Dispatcher.pm index 484e222..08c6f96 100755 --- a/lib/Packages/Dispatcher.pm +++ b/lib/Packages/Dispatcher.pm @@ -177,7 +177,11 @@ sub do_dispatch { } elsif (@components == 0) { fatal_error( "We're supposed to display the homepage here, instead of getting dispatch.pl" ); } elsif (@components == 1) { - $what_to_do = 'search'; + if ($components[0] eq 'index') { + $what_to_do = 'homepage'; + } else { + $what_to_do = 'search'; + } } else { for ($components[-1]) { diff --git a/lib/Packages/DoIndex.pm b/lib/Packages/DoIndex.pm index 5aba6b3..6af0c3a 100644 --- a/lib/Packages/DoIndex.pm +++ b/lib/Packages/DoIndex.pm @@ -12,7 +12,12 @@ use Packages::Config qw( $TOPDIR ); use Packages::CGI; our @ISA = qw( Exporter ); -our @EXPORT = qw( do_index do_allpackages ); +our @EXPORT = qw( do_homepage do_index do_allpackages ); + +sub do_homepage { + $_[1]->{suite} = []; + return send_file( 'index', @_ ); +} sub do_index { return send_file( 'index', @_ ); @@ -46,7 +51,7 @@ sub send_file { my $wwwdir = "$TOPDIR/www"; my $path = ""; $path .= "source/" if $opts->{source}; - $path .= "$opts->{suite}[0]/"; + $path .= "$opts->{suite}[0]/" if @{$opts->{suite}}; $path .= "$opts->{archive}[0]/" if @{$opts->{archive}} == 1; $path .= "$opts->{subsection}[0]/" if @{$opts->{subsection}}; $path .= "$opts->{priority}[0]/" if @{$opts->{priority}}; diff --git a/templates/html/homepage.tmpl b/templates/html/homepage.tmpl index 7aa276e..6dabe9f 100644 --- a/templates/html/homepage.tmpl +++ b/templates/html/homepage.tmpl @@ -115,4 +115,4 @@ Distribution: -[% PROCESS 'html/foot.tmpl' copyright.years = '1997 - 2009' %] +[% PROCESS 'html/foot.tmpl' page_name=packages_homepage copyright.years = '1997 - 2009' %] -- 2.39.2