diff options
author | Edmund von der Burg <evdb@ecclestoad.co.uk> | 2011-02-08 17:05:47 -0300 |
---|---|---|
committer | Edmund von der Burg <evdb@ecclestoad.co.uk> | 2011-02-08 17:05:47 -0300 |
commit | 2c18b9614a1c7505a246cbfa5b768784845b635b (patch) | |
tree | 4f44dfe0d8b90d6496bc1e6cb522bfc73c890a2a | |
parent | b2cfc51fe1e8d1d95d251380902ab4e69c5a5af9 (diff) |
correct RSS url
redirect e,n query to lat lon
serve lat,lon
-rw-r--r-- | conf/httpd.conf | 14 | ||||
-rwxr-xr-x | web/index.cgi | 2 | ||||
-rwxr-xr-x | web/rss.cgi | 19 |
3 files changed, 18 insertions, 17 deletions
diff --git a/conf/httpd.conf b/conf/httpd.conf index 67170bad5..8bc50645a 100644 --- a/conf/httpd.conf +++ b/conf/httpd.conf @@ -60,14 +60,14 @@ RewriteRule ^/[Tt]/([0-9A-Za-z]{16,18}).*$ /tms-signup.cgi?token=$1 RewriteRule ^/rss/([0-9]+)$ /rss.cgi?type=new_updates;id=$1 [QSA] # RSS feeds for new local problems -RewriteRule ^/rss/([0-9]+)[,/]([0-9]+)$ /rss.cgi?type=local_problems;x=$1;y=$2 [QSA] -RewriteRule ^/rss/n/([0-9]+)[,/]([0-9]+)$ /rss.cgi?type=local_problems;e=$1;n=$2 [QSA] -RewriteRule ^/rss/l/([0-9.-]+)[,/]([0-9.-]+)$ /rss.cgi?type=local_problems;lat=$1;lon=$2 [QSA] -RewriteRule ^/rss/([0-9]+)[,/]([0-9]+)/([0-9]+)$ /rss.cgi?type=local_problems;x=$1;y=$2;d=$3 [QSA] -RewriteRule ^/rss/n/([0-9]+)[,/]([0-9]+)/([0-9]+)$ /rss.cgi?type=local_problems;e=$1;n=$2;d=$3 [QSA] +RewriteRule ^/rss/([0-9]+)[,/]([0-9]+)$ /rss.cgi?type=local_problems;x=$1;y=$2 [QSA] +RewriteRule ^/rss/n/([0-9]+)[,/]([0-9]+)$ /rss.cgi?type=local_problems;e=$1;n=$2 [QSA] +RewriteRule ^/rss/l/([0-9.-]+)[,/]([0-9.-]+)$ /rss.cgi?type=local_problems;lat=$1;lon=$2 [QSA] +RewriteRule ^/rss/([0-9]+)[,/]([0-9]+)/([0-9]+)$ /rss.cgi?type=local_problems;x=$1;y=$2;d=$3 [QSA] +RewriteRule ^/rss/n/([0-9]+)[,/]([0-9]+)/([0-9]+)$ /rss.cgi?type=local_problems;e=$1;n=$2;d=$3 [QSA] RewriteRule ^/rss/l/([0-9.-]+)[,/]([0-9.-]+)/([0-9]+)$ /rss.cgi?type=local_problems;lat=$1;lon=$2;d=$3 [QSA] -RewriteRule ^/rss/pc/(.*)$ /rss.cgi?type=local_problems;pc=$1 [QSA] -RewriteRule ^/rss/problems$ /rss.cgi?type=new_problems [QSA] +RewriteRule ^/rss/pc/(.*)$ /rss.cgi?type=local_problems;pc=$1 [QSA] +RewriteRule ^/rss/problems$ /rss.cgi?type=new_problems [QSA] # RSS feeds for voting areas RewriteRule ^/rss/council/([0-9]+)$ /rss/reports/$1 [R=permanent] diff --git a/web/index.cgi b/web/index.cgi index 6b9121436..c1a034df7 100755 --- a/web/index.cgi +++ b/web/index.cgi @@ -943,7 +943,7 @@ sub display_location { ), map_end => FixMyStreet::Map::display_map_end(1), url_home => Cobrand::url($cobrand, '/', $q), - url_rss => Cobrand::url($cobrand, NewURL($q, -retain => 1, -url=> "/rss/l/$latitude,$longitude", pc => undef, x => undef, 'y' => undef), $q), + url_rss => Cobrand::url($cobrand, NewURL($q, -retain => 1, -url=> "/rss/l/$latitude,$longitude", pc => undef, x => undef, y => undef, lat => undef, lon => undef ), $q), url_email => Cobrand::url($cobrand, NewURL($q, -retain => 1, pc => undef, -url=>'/alert', lat=>$latitude, lon=>$longitude, feed=>"local:$latitude:$longitude"), $q), url_skip => $url_skip, email_me => _('Email me new local problems'), diff --git a/web/rss.cgi b/web/rss.cgi index 0ac7fa45d..093e9a330 100755 --- a/web/rss.cgi +++ b/web/rss.cgi @@ -83,20 +83,17 @@ sub rss_local_problems { my $cobrand = Page::get_cobrand($q); my $base = Cobrand::base_url($cobrand); - if ($lat) { # In the UK, it'll never be 0 :) - ($e, $n) = mySociety::GeoUtil::wgs84_to_national_grid($lat, $lon, 'G'); - $e = int($e + 0.5); - $n = int($n + 0.5); - print $q->redirect(-location => "$base/rss/n/$e,$n$d_str$state_qs"); - return ''; - } elsif ($x && $y) { + if ($x && $y) { # 5000/31 as initial scale factor for these RSS feeds, now variable so redirect. $e = int( ($x * 5000/31) + 0.5 ); $n = int( ($y * 5000/31) + 0.5 ); - print $q->redirect(-location => "$base/rss/n/$e,$n$d_str$state_qs"); + ($lat, $lon) = mySociety::GeoUtil::national_grid_to_wgs84($e, $n, 'G'); + print $q->redirect(-location => "$base/rss/l/$lat,$lon$d_str$state_qs"); return ''; } elsif ($e && $n) { ($lat, $lon) = mySociety::GeoUtil::national_grid_to_wgs84($e, $n, 'G'); + print $q->redirect(-location => "$base/rss/l/$lat,$lon$d_str$state_qs"); + return ''; } elsif ($pc) { my $error; try { @@ -108,10 +105,14 @@ sub rss_local_problems { print $q->redirect(-location => "$base/rss/n/$e,$n$d_str$state_qs"); } return ''; + } elsif ( $lat || $lon ) { + # pass through } else { die "Missing E/N, x/y, lat/lon, or postcode parameter in RSS feed"; } - my $qs = '?e=' . int($e) . ';n=' . int($n); + + my $qs = "?lat=$lat;lon/=$lon"; + if ($d) { $qs .= ";d=$d"; $d = 100 if $d > 100; |