#![%- META type = 'text' -%] [% locate.in_path( 'speedy') || locate.in_path( 'perl' ) %] use strict; use warnings; ###################################################################### # A 404 script for swish-e.org use lib qw( [%- self.plugin_dir -%] ); use CGI; # provides a param() method -- could use Apache::Request, for example. use File::Basename; my $cgi = CGI->new; # Look for possible redirects # REQUEST_URI doens't have host, so not valid redirect. if ( $_ = $ENV{REDIRECT_SCRIPT_URI} || $ENV{REQUEST_URI} ) { redirect($_) if s[/Download][/download]; redirect($_) if s[/Discussion/archive][/archive]; redirect($_) if s[/Discussion/search/][/search_archive/]; redirect($_) if s[/Discussion/?.*$][/discuss.html]; redirect("/docs/" . lc( $1 ) . $2) if m[/current/docs/(.+)(\.html.*)$]; redirect($_) if s[/current/docs][/docs]; redirect($_) if s[/dev/docs/?][/devel/devel_docs/]; redirect($_) if s[/dev/swish-daily/?][/devel/daily.html]; } require Template; my $tt_options = { INCLUDE_PATH => '[% self.include_path.join(':') %]', PLUGIN_BASE => ['My'], PRE_PROCESS => 'config/main', WRAPPER => 'page/wrapper.tt', RECURSION => 1, #DEBUG => Template::Constants::DEBUG_PROVIDER, }; my $vars = { rooturl => dirname( $ENV{SCRIPT_NAME} ), # for .css file env => \%ENV, }; $vars->{rooturl} = '' if $vars->{rooturl} eq '/'; my $template = Template->new( $tt_options ) || die Template->error; print $cgi->header; $template->process( 'page/404.html', $vars ) || die $template->error."\n"; sub redirect { my $r = shift; print $cgi->redirect( $r ); exit; } # vim: set filetype=perl: