aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Page.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/Page.pm')
-rw-r--r--perllib/Page.pm46
1 files changed, 19 insertions, 27 deletions
diff --git a/perllib/Page.pm b/perllib/Page.pm
index 3a3fa9ca8..02581960c 100644
--- a/perllib/Page.pm
+++ b/perllib/Page.pm
@@ -6,7 +6,7 @@
# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: Page.pm,v 1.8 2006-09-20 16:47:51 matthew Exp $
+# $Id: Page.pm,v 1.9 2006-09-21 18:09:19 matthew Exp $
#
package Page;
@@ -14,10 +14,9 @@ package Page;
use strict;
use Carp;
use CGI::Fast qw(-no_xhtml);
-use HTML::Entities;
-use URI::Escape;
use Error qw(:try);
use mySociety::WatchUpdate;
+use mySociety::Web qw(ent NewURL);
sub do_fastcgi {
my $func = shift;
@@ -33,7 +32,7 @@ sub do_fastcgi {
my $msg = sprintf('%s:%d: %s', $E->file(), $E->line(), $E->text());
warn "caught fatal exception: $msg";
warn "aborting";
- encode_entities($msg);
+ ent($msg);
print "Status: 500\nContent-Type: text/html; charset=iso-8859-1\n\n",
q(<html><head><title>Sorry! Something's gone wrong.</title></head></html>),
q(<body>),
@@ -46,12 +45,6 @@ sub do_fastcgi {
};
}
-sub url {
- my ($pc, $x, $y) = @_;
- return '?pc=' . uri_escape($pc) . ';x=' . uri_escape($x)
- . ';y=' . uri_escape($y);
-}
-
=item header Q TITLE [PARAM VALUE ...]
Return HTML for the top of the page, given the TITLE text and optional PARAMs.
@@ -65,6 +58,7 @@ sub header ($$%) {
croak "bad parameter '$_'" if (!exists($permitted_params{$_}));
}
+ print $q->header(-charset=>'utf-8');
my $html = <<EOF;
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en-gb">
@@ -113,31 +107,29 @@ sub error_page ($$) {
}
sub compass ($$$) {
- my ($pc, $x, $y) = @_;
- my $nw = url($pc, $x-1, $y+1);
- my $n = url($pc, $x, $y+1);
- my $ne = url($pc, $x+1, $y+1);
- my $w = url($pc, $x-1,$y);
- my $e = url($pc, $x+1,$y);
- my $sw = url($pc, $x-1, $y-1);
- my $s = url($pc, $x, $y-1);
- my $se = url($pc, $x+1, $y-1);
+ my ($q, $x, $y) = @_;
+ my @compass;
+ for (my $i=$x-1; $i<=$x+1; $i++) {
+ for (my $j=$y-1; $j<=$y+1; $j++) {
+ $compass[$i][$j] = NewURL($q, x=>$i, y=>$j);
+ }
+ }
return <<EOF;
<table cellpadding="0" cellspacing="0" border="0" id="compass">
<tr valign="bottom">
-<td align="right"><a href="$nw"><img src="i/arrow-northwest.gif" alt="NW"></a></td>
-<td align="center"><a href="$n"><img src="i/arrow-north.gif" vspace="3" alt="N"></a></td>
-<td><a href="$ne"><img src="i/arrow-northeast.gif" alt="NE"></a></td>
+<td align="right"><a href="${compass[$x-1][$y+1]}"><img src="i/arrow-northwest.gif" alt="NW"></a></td>
+<td align="center"><a href="${compass[$x][$y+1]}"><img src="i/arrow-north.gif" vspace="3" alt="N"></a></td>
+<td><a href="${compass[$x+1][$y+1]}"><img src="i/arrow-northeast.gif" alt="NE"></a></td>
</tr>
<tr>
-<td><a href="$w"><img src="i/arrow-west.gif" hspace="3" alt="W"></a></td>
+<td><a href="${compass[$x-1][$y]}"><img src="i/arrow-west.gif" hspace="3" alt="W"></a></td>
<td align="center"><img src="i/rose.gif" alt=""></a></td>
-<td><a href="$e"><img src="i/arrow-east.gif" hspace="3" alt="E"></a></td>
+<td><a href="${compass[$x+1][$y]}"><img src="i/arrow-east.gif" hspace="3" alt="E"></a></td>
</tr>
<tr valign="top">
-<td align="right"><a href="$sw"><img src="i/arrow-southwest.gif" alt="SW"></a></td>
-<td align="center"><a href="$s"><img src="i/arrow-south.gif" vspace="3" alt="S"></a></td>
-<td><a href="$se"><img src="i/arrow-southeast.gif" alt="SE"></a></td>
+<td align="right"><a href="${compass[$x-1][$y-1]}"><img src="i/arrow-southwest.gif" alt="SW"></a></td>
+<td align="center"><a href="${compass[$x][$y-1]}"><img src="i/arrow-south.gif" vspace="3" alt="S"></a></td>
+<td><a href="${compass[$x+1][$y-1]}"><img src="i/arrow-southeast.gif" alt="SE"></a></td>
</tr>
</table>
EOF