|
Revision 879, 1.0 kB
(checked in by earle, 2 years ago)
|
|
Add the openguides.org website!
|
-
Property svn:executable set to
*
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | use warnings; |
|---|
| 4 | use strict; |
|---|
| 5 | |
|---|
| 6 | use Template; |
|---|
| 7 | |
|---|
| 8 | my $tt = Template->new({ |
|---|
| 9 | EVAL_PERL => 1, |
|---|
| 10 | INCLUDE_PATH => 'templates', |
|---|
| 11 | PRE_PROCESS => 'config', |
|---|
| 12 | PRE_CHOMP => 1, |
|---|
| 13 | POST_CHOMP => 1 |
|---|
| 14 | }); |
|---|
| 15 | |
|---|
| 16 | my $page = $ENV{'REQUEST_URI'} || 'home'; |
|---|
| 17 | my $script = $ENV{'SCRIPT_NAME'}; |
|---|
| 18 | $page =~ s{^$script/}{}; |
|---|
| 19 | $page = 'home' if $page =~ m{\*|\?|/}; |
|---|
| 20 | |
|---|
| 21 | my $vars = { page => $page }; |
|---|
| 22 | |
|---|
| 23 | print "Content-Type: text/html\n\n"; |
|---|
| 24 | |
|---|
| 25 | $tt->process('wrapper', $vars) || error($tt->error); |
|---|
| 26 | |
|---|
| 27 | sub error { |
|---|
| 28 | my $error = shift; |
|---|
| 29 | |
|---|
| 30 | print <<HTML; |
|---|
| 31 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
|---|
| 32 | <html> |
|---|
| 33 | <head> |
|---|
| 34 | <title>Error</title> |
|---|
| 35 | <style type="text/css"> |
|---|
| 36 | body { |
|---|
| 37 | background: |
|---|
| 38 | color: |
|---|
| 39 | margin: 10px; |
|---|
| 40 | font: 1em Verdana, Arial, sans-serif |
|---|
| 41 | } |
|---|
| 42 | blockquote { |
|---|
| 43 | background: |
|---|
| 44 | color: |
|---|
| 45 | border: 1px dotted |
|---|
| 46 | padding: 10px |
|---|
| 47 | } |
|---|
| 48 | </style> |
|---|
| 49 | </head> |
|---|
| 50 | <body> |
|---|
| 51 | <h1>Error</h1> |
|---|
| 52 | <p> |
|---|
| 53 | Something has gone wrong. Here's what Template Toolkit had to say: |
|---|
| 54 | </p> |
|---|
| 55 | <blockquote> |
|---|
| 56 | $error |
|---|
| 57 | </blockquote> |
|---|
| 58 | </body> |
|---|
| 59 | </html> |
|---|
| 60 | HTML |
|---|
| 61 | |
|---|
| 62 | } |
|---|