aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/Page.pm18
-rwxr-xr-xweb/alert.cgi3
-rwxr-xr-xweb/index.cgi18
3 files changed, 21 insertions, 18 deletions
diff --git a/perllib/Page.pm b/perllib/Page.pm
index b64b1f1f7..b605992b7 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.65 2007-09-03 21:03:31 matthew Exp $
+# $Id: Page.pm,v 1.66 2007-09-18 08:27:05 matthew Exp $
#
package Page;
@@ -547,6 +547,22 @@ sub geocode_string {
return ($x, $y, $easting, $northing, $error);
}
+# geocode_choice
+# Prints response if there's more than one possible result
+sub geocode_choice {
+ my ($choices, $page) = @_;
+ my $out = '<p>We found more than one match for that location. We show up to ten matches, please try a different search if yours is not here.</p> <ul>';
+ foreach my $choice (@$choices) {
+ $choice =~ s/, United Kingdom//;
+ $choice =~ s/, UK//;
+ my $url = uri_escape($choice);
+ $url =~ s/%20/+/g;
+ $out .= '<li><a href="' . $page . '?pc=' . $url . '">' . $choice . "</a></li>\n";
+ }
+ $out .= '</ul>';
+ return $out;
+}
+
sub short_name {
my $name = shift;
# Special case Durham as it's the only place with two councils of the same name
diff --git a/web/alert.cgi b/web/alert.cgi
index 086d6c32c..ba5ac0e71 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.15 2007-09-14 13:57:51 matthew Exp $
+# $Id: alert.cgi,v 1.16 2007-09-18 08:27:05 matthew Exp $
use strict;
use Standard;
@@ -63,6 +63,7 @@ sub alert_list {
my %input = map { $_ => scalar $q->param($_) } qw(pc email);
my %input_h = map { $_ => $q->param($_) ? ent($q->param($_)) : '' } qw(pc email);
my ($x, $y, $e, $n, $error) = Page::geocode($input{pc});
+ return Page::geocode_choice($error, '/alert') if ref($error) eq 'ARRAY';
return alert_front_page($q, $error) if $error;
my $errors = '';
diff --git a/web/index.cgi b/web/index.cgi
index 11fc57b4c..dd7c19bf7 100755
--- a/web/index.cgi
+++ b/web/index.cgi
@@ -6,7 +6,7 @@
# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: index.cgi,v 1.163 2007-08-29 23:03:16 matthew Exp $
+# $Id: index.cgi,v 1.164 2007-09-18 08:27:05 matthew Exp $
use strict;
use Standard;
@@ -582,7 +582,7 @@ sub display_location {
$error = shift;
};
}
- return geocode_choice($error) if (ref($error) eq 'ARRAY');
+ return Page::geocode_choice($error, '/') if (ref($error) eq 'ARRAY');
return front_page($q, $error) if ($error);
my ($pins, $current_map, $current, $fixed, $dist) = map_pins($q, $x, $y);
@@ -815,17 +815,3 @@ sub map_pins {
return ($pins, $current_map, $current, $fixed, $dist);
}
-sub geocode_choice {
- my $choices = shift;
- my $out = '<p>We found more than one match for that location. We show up to ten matches, please try a different search if yours is not here.</p> <ul>';
- foreach my $choice (@$choices) {
- $choice =~ s/, United Kingdom//;
- $choice =~ s/, UK//;
- my $url = uri_escape($choice);
- $url =~ s/%20/+/g;
- $out .= '<li><a href="/?pc=' . $url . '">' . $choice . "</a></li>\n";
- }
- $out .= '</ul>';
- return $out;
-}
-