root/swish_website/src/404.html

Revision 1682, 1.8 kB (checked in by whmoseley, 3 years ago)

Move to using REQUEST_URI. Note to self: add host.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1 #![%- META type = 'text' -%]
2 [% locate.in_path( 'speedy') || locate.in_path( 'perl' ) %]
3
4 use strict;
5 use warnings;
6
7 ######################################################################
8 # A 404 script for swish-e.org
9 use lib qw( [%- self.plugin_dir -%] );
10 use CGI;                    # provides a param() method -- could use Apache::Request, for example.
11 use File::Basename;
12
13     my $cgi = CGI->new;
14
15     # Look for possible redirects
16     # REQUEST_URI doens't have host, so not valid redirect.
17
18     if ( $_ = $ENV{REDIRECT_SCRIPT_URI} || $ENV{REQUEST_URI} ) {
19         redirect($_) if s[/Download][/download];
20         redirect($_) if s[/Discussion/archive][/archive];
21         redirect($_) if s[/Discussion/search/][/search_archive/];
22         redirect($_) if s[/Discussion/?.*$][/discuss.html];
23
24         redirect("/docs/" . lc( $1 ) . $2) if m[/current/docs/(.+)(\.html.*)$];
25         redirect($_) if s[/current/docs][/docs];
26         redirect($_) if s[/dev/docs/?][/devel/devel_docs/];
27         redirect($_) if s[/dev/swish-daily/?][/devel/daily.html];
28     }
29
30     require Template;
31
32     my $tt_options = {
33         INCLUDE_PATH    => '[% self.include_path.join(':') %]',
34         PLUGIN_BASE     => ['My'],
35         PRE_PROCESS     => 'config/main',
36         WRAPPER         => 'page/wrapper.tt',
37         RECURSION       => 1,
38         #DEBUG           => Template::Constants::DEBUG_PROVIDER,
39     };
40
41
42     my $vars = {
43         rooturl => dirname( $ENV{SCRIPT_NAME} ), # for .css file
44         env     => \%ENV,
45     };
46
47     $vars->{rooturl} = '' if $vars->{rooturl} eq '/';
48
49
50     my $template = Template->new( $tt_options ) || die Template->error;
51
52     print $cgi->header;
53
54     $template->process( 'page/404.html', $vars ) || die $template->error."\n";
55
56 sub redirect {
57     my $r = shift;
58
59     print $cgi->redirect( $r );
60     exit;
61
62
63 }
64
65 # vim: set filetype=perl:
66
67
68
Note: See TracBrowser for help on using the browser.