diff options
author | matthew <matthew> | 2007-09-03 21:03:31 +0000 |
---|---|---|
committer | matthew <matthew> | 2007-09-03 21:03:31 +0000 |
commit | 87f0d0a40f5d0b84b75e18a864c42c2b9f6a52b4 (patch) | |
tree | a3eb67f6bb81dc96c658dfe948b51636f7146bc3 | |
parent | 07d321ca2b1656c65ebe8829a743ee0e22befeae (diff) |
Better error message if someone enters a zipcode.
-rw-r--r-- | perllib/Page.pm | 6 | ||||
-rwxr-xr-x | web/alert.cgi | 13 |
2 files changed, 14 insertions, 5 deletions
diff --git a/perllib/Page.pm b/perllib/Page.pm index 04c91dc8d..b64b1f1f7 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.64 2007-09-03 20:56:30 matthew Exp $ +# $Id: Page.pm,v 1.65 2007-09-03 21:03:31 matthew Exp $ # package Page; @@ -537,8 +537,10 @@ sub geocode_string { $y = int($yy); $x -= 1 if ($xx - $x < 0.5); $y -= 1 if ($yy - $y < 0.5); - } catch { + } catch Error::Simple with { $error = shift; + $error = "That location doesn't appear to be in Britain; please try again." + if $error =~ /out of the area covered/; } } } diff --git a/web/alert.cgi b/web/alert.cgi index fd4c74da8..c2f920cd4 100755 --- a/web/alert.cgi +++ b/web/alert.cgi @@ -6,7 +6,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: alert.cgi,v 1.13 2007-09-03 20:56:31 matthew Exp $ +# $Id: alert.cgi,v 1.14 2007-09-03 21:03:31 matthew Exp $ use strict; use Standard; @@ -49,7 +49,7 @@ EOF $out = alert_list($q); } else { $title = 'Local RSS feeds and email alerts'; - $out = alert_front_page(); + $out = alert_front_page($q); } print Page::header($q, title => $title); @@ -203,11 +203,18 @@ title="RSS feed of recent local problems" alt="RSS feed" border="0"></a>'; } sub alert_front_page { + my $q = shift; + my $error = shift; + my $errors = ''; + $errors = '<ul id="error"><li>' . $error . '</li></ul>' if $error; + + my %input_h = map { $_ => $q->param($_) ? ent($q->param($_)) : '' } qw(pc); my $out = <<EOF; <h1>Local RSS feeds and email alerts</h1> +$errors <form method="get" action="/alert"> <p>To find out what local alerts we have, please enter your UK postcode or street name here: -<input type="text" name="pc" value=""> +<input type="text" name="pc" value="$input_h{pc}"> <input type="submit" value="Look up"> </form> EOF |