#!/usr/bin/perl # # Page.pm: # Various HTML stuff for the BCI site. # # Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org; WWW: http://www.mysociety.org/ # # $Id: Page.pm,v 1.23 2006-09-28 16:36:08 matthew Exp $ # package Page; use strict; use Carp; use CGI::Fast qw(-no_xhtml); use Error qw(:try); use mySociety::WatchUpdate; use mySociety::Web qw(ent NewURL); sub do_fastcgi { my $func = shift; try { my $W = new mySociety::WatchUpdate(); while (my $q = new CGI::Fast()) { &$func($q); $W->exit_if_changed(); } } catch Error::Simple with { my $E = shift; my $msg = sprintf('%s:%d: %s', $E->file(), $E->line(), $E->text()); warn "caught fatal exception: $msg"; warn "aborting"; ent($msg); print "Status: 500\nContent-Type: text/html; charset=iso-8859-1\n\n", q(Sorry! Something's gone wrong.), q(), q(

Sorry! Something's gone wrong.

), q(

Please try again later, or email us to let us know.

), q(
), q(

The text of the error was:

), qq(
$msg
), q( 1 } qw(); foreach (keys %params) { croak "bad parameter '$_'" if (!exists($permitted_params{$_})); } print $q->header(-charset=>'utf-8'); my $html = < EOF # Causes onLoad never to fire in IE... # $html .= < ${title}Neighbourhood Fix-It EOF my $home = !$title && $ENV{SCRIPT_NAME} eq '/index.cgi' && !$ENV{QUERY_STRING}; $html .= $home ? '

' : '

' : ''; $html .= '
'; return $html; } =item footer =cut sub footer { return <

Navigation

EOF } =item error_page Q MESSAGE =cut sub error_page ($$) { my ($q, $message); my $html = header($q, "Error") . $q->p($message) . footer(); print $q->header(-content_length => length($html)), $html; } sub compass ($$$) { 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 < NW N NE W E SW S SE EOF } 1;