aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xweb/alert.cgi35
-rwxr-xr-xweb/index.cgi5
2 files changed, 29 insertions, 11 deletions
diff --git a/web/alert.cgi b/web/alert.cgi
index dbb131684..e311aaf2c 100755
--- a/web/alert.cgi
+++ b/web/alert.cgi
@@ -6,11 +6,12 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: alert.cgi,v 1.30 2008-09-16 15:45:10 matthew Exp $
+# $Id: alert.cgi,v 1.31 2008-09-19 17:47:19 matthew Exp $
use strict;
use Standard;
use Digest::SHA1 qw(sha1_hex);
+use Error qw(:try);
use CrossSell;
use mySociety::Alert;
use mySociety::AuthToken;
@@ -45,7 +46,7 @@ EOF
$out = alert_do_subscribe($q, $q->param('email'));
} elsif ($q->param('id')) {
$out = alert_updates_form($q);
- } elsif ($q->param('pc')) {
+ } elsif ($q->param('pc') || ($q->param('x') && $q->param('y'))) {
$title = _('Local RSS feeds and email alerts');
$out = alert_list($q);
} else {
@@ -61,9 +62,24 @@ Page::do_fastcgi(\&main);
sub alert_list {
my ($q, @errors) = @_;
- 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});
+ my @vars = qw(pc email x y);
+ my %input = map { $_ => scalar $q->param($_) } @vars;
+ my %input_h = map { $_ => $q->param($_) ? ent($q->param($_)) : '' } @vars;
+
+ my($error, $e, $n);
+ my $x = $input{x}; my $y = $input{y};
+ $x ||= 0; $x += 0;
+ $y ||= 0; $y += 0;
+ if ($x || $y) {
+ $e = Page::tile_to_os($input{x});
+ $n = Page::tile_to_os($input{y});
+ } else {
+ try {
+ ($x, $y, $e, $n, $error) = Page::geocode($input{pc});
+ } catch Error::Simple with {
+ $error = shift;
+ };
+ }
return Page::geocode_choice($error, '/alert') if ref($error) eq 'ARRAY';
return alert_front_page($q, $error) if $error;
@@ -176,7 +192,8 @@ but will only appear in the "Within the boundary" alert for the county council.'
my $pics = Problems::recent_photos(5, $e, $n, $dist);
$pics = '<div id="alert_photos">' . $q->h2(_('Photos of recent nearby reports')) . $pics . '</div>' if $pics;
- my $out = $q->h1(sprintf(_('Local RSS feeds and email alerts for &lsquo;%s&rsquo;'), $pretty_pc));
+ my $out = $q->h1('Local RSS feeds and email alerts'
+ . ($pretty_pc ? ' for &lsquo;' . $pretty_pc . '&rsquo;' : ''));
$out .= <<EOF;
<form id="alerts" method="post" action="/alert">
<input type="hidden" name="type" value="local">
@@ -185,9 +202,9 @@ but will only appear in the "Within the boundary" alert for the county council.'
$pics
EOF
- $out .= $q->p(sprintf(_('Here are the types of local problem alerts for &lsquo;%s&rsquo;.
-Select which type of alert you&rsquo;d like and click the button for an RSS
-feed, or enter your email address to subscribe to an email alert.'), $pretty_pc));
+ $out .= $q->p(($pretty_pc ? 'Here are the types of local problem alerts for &lsquo;' . $pretty_pc . '&rsquo;. '
+ : '') . 'Select which type of alert you&rsquo;d like and click the button for an RSS
+feed, or enter your email address to subscribe to an email alert.');
$out .= $errors;
$out .= $q->p(_('The simplest alert is our geographic one:'));
my $label = sprintf(_('Problems within %skm of this location'), $dist);
diff --git a/web/index.cgi b/web/index.cgi
index 608eae07e..415eea669 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.210 2008-09-19 10:24:55 matthew Exp $
+# $Id: index.cgi,v 1.211 2008-09-19 17:47:19 matthew Exp $
use strict;
use Standard;
@@ -682,9 +682,10 @@ sub display_location {
my $rss_title = _('RSS feed of recent local problems');
my $rss_alt = _('RSS feed');
my $u_pc = uri_escape($input{pc});
+ my $email_me_link = NewURL($q, -url=>'/alert', x=>$x, y=>$y, feed=>"local:$x:$y");
$out .= <<EOF;
<p id="alert_links_area">
- <a id="email_alert" href="/alert?pc=$u_pc;type=local;feed=local:$x:$y;alert=Subscribe">$email_me</a>
+ <a id="email_alert" href="$email_me_link">$email_me</a>
| <a href="/rss/$x,$y" id="rss_alert"><span>RSS feed</span> <img src="/i/feed.png" width="16" height="16" title="$rss_title" alt="$rss_alt" border="0" style="vertical-align: top"></a>
</p>
EOF