#!/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.5 2006-09-19 23:45:33 matthew Exp $ # package Page; use strict; use Carp; use CGI::Fast qw(-no_xhtml); use HTML::Entities; use Error qw(:try); use mySociety::WatchUpdate; 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"; encode_entities($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( Neighbourhood Fix-It

Neighbourhood Fix-It

EOF return $html; } =item footer Q =cut sub footer ($) { my ($q) = @_; return < EOF } =item error_page Q MESSAGE =cut sub error_page ($$) { my ($q, $message); my $html = header($q, "Error") . $q->p($message) . footer($q); print $q->header(-content_length => length($html)), $html; } sub compass ($$) { my ($x, $y) = @_; my $nw = url($x-1, $y-1); my $n = url($x, $y-1); my $ne = url($x+1, $y-1); my $w = url($x-1,$y); my $e = url($x+1,$y); my $sw = url($x-1, $y+1); my $s = url($x, $y+1); my $se = url($x+1, $y+1); return < NW N NE W E SW S SE EOF } 1;