aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatthew <matthew>2007-01-23 23:59:08 +0000
committermatthew <matthew>2007-01-23 23:59:08 +0000
commita97ed7209fd81ee25c1160ba0f832e4d9da4ab4f (patch)
treee2777a21d64bef83a8ccd27b3ee5fbe65f81a55d
parent404df7b90289206a4c6010299cc6dd7fbd8814c6 (diff)
Text update, colour tweak, possible JS edge cage perhaps fixed?
-rw-r--r--perllib/Page.pm7
-rw-r--r--web/css.css15
-rwxr-xr-xweb/faq.cgi15
-rwxr-xr-xweb/index.cgi93
-rw-r--r--web/js.js18
5 files changed, 79 insertions, 69 deletions
diff --git a/perllib/Page.pm b/perllib/Page.pm
index 110971c55..3c1d687e7 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.30 2007-01-17 23:58:30 matthew Exp $
+# $Id: Page.pm,v 1.31 2007-01-23 23:59:08 matthew Exp $
#
package Page;
@@ -107,8 +107,9 @@ sub footer {
</ul>
<p id="footer">Built by <a href="http://www.mysociety.org/">mySociety</a>.
-Using lots of <a href="http://www.ordnancesurvey.co.uk/">Ordnance Survey</a> data, under licence, and <a href="http://www.localsearchmaps.com/">LocalSearchMap</a>'s geocoder.
-And some <a href="https://secure.mysociety.org/cvstrac/dir?d=mysociety/bci">very clever code</a>.</p>
+Using lots of <a href="http://www.ordnancesurvey.co.uk/">Ordnance Survey</a> data, under licence,
+and some <a href="https://secure.mysociety.org/cvstrac/dir?d=mysociety/bci">clever</a>
+<a href="https://secure.mysociety.org/cvstrac/dir?d=mysociety/services/TilMa">code</a>.</p>
</body>
</html>
diff --git a/web/css.css b/web/css.css
index af4b907c0..524ae4be5 100644
--- a/web/css.css
+++ b/web/css.css
@@ -72,15 +72,15 @@ ul#error {
#header {
font-size: 200%;
font-weight: bold;
- border-bottom: solid 2px #968d63;
+ border-bottom: solid 2px #5e552b;
margin: 0;
padding: 5px 0.5em;
background-color: #e3d595;
- color: #968d63;
+ color: #5e552b;
}
#header a:link, #header a:visited {
- color: #968d63;
+ color: #5e552b;
background-color: #e3d595;
text-decoration: none;
}
@@ -120,11 +120,11 @@ ul#error {
padding: 0.5em 2em;
}
#navigation a:link, #navigation a:visited {
- color: #968d63;
+ color: #5e552b;
background-color: #e3d595;
}
#navigation a:hover, #navigation a:active {
- background-color: #968d63;
+ background-color: #5e552b;
color: #e3d595;
}
@@ -132,7 +132,7 @@ ul#error {
clear: both;
text-align: right;
font-size: 83%;
- border-top: solid 1px #968d63;
+ border-top: solid 1px #5e552b;
display: table;
margin: 1em 0 1em auto;
padding: 2px 4px;
@@ -182,6 +182,7 @@ fieldset div.checkbox label, label.n {
float: right;
position: relative;
background-color: #f1f1f1;
+ margin-bottom: 1em;
}
#drag {
@@ -250,5 +251,5 @@ ol#current img {
}
#comments div em {
- border-bottom: dotted 1px #968d63;
+ border-bottom: dotted 1px #5e552b;
}
diff --git a/web/faq.cgi b/web/faq.cgi
index 5e13a9cb2..971188f61 100755
--- a/web/faq.cgi
+++ b/web/faq.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: faq.cgi,v 1.4 2006-09-27 13:51:23 matthew Exp $
+# $Id: faq.cgi,v 1.5 2007-01-23 23:59:08 matthew Exp $
use strict;
require 5.8.0;
@@ -42,7 +42,7 @@ path; anything like that that could be usefully reported to your council
to be fixed.</dd>
<dt>How does it work?</dt>
-<dd>After entering a postcode, users are presented with a map of that
+<dd>After entering a postcode or location, users are presented with a map of that
area. They can view problems already reported in that area, or report
ones of their own simply by clicking on the map at the location of the
problem.</dd>
@@ -50,11 +50,11 @@ problem.</dd>
<dt>Is it free?</dt>
<dd>The site is free to use, yes. Neighbourhood Fix-It
is run by a charitable organisation, though, so if you want to make
-a contribution, please contact us.</dd>
+a contribution, <a href="https://secure.mysociety.org/donate/">please do</a>.</dd>
</dl>
<dt>Do you remove silly or illegal content?</dt>
-<dd>We reserve the right to remove any problems or comments which we
+<dd>We reserve the right to remove any problems or updates which we
consider to be inappropriate.</dd>
<h2>Privacy Questions</h2>
@@ -64,7 +64,7 @@ consider to be inappropriate.</dd>
<dd>If you submit a problem, we (do we?) pass on your name, email address, and details
of the problem to the council contact responsible for the area where you
located the problem. Your name is displayed upon the site, but not your email address;
-similarly with comments.
+similarly with updates.
We will never give or sell your
email address to anyone else, unless we are obliged to by law.
@@ -72,11 +72,10 @@ email address to anyone else, unless we are obliged to by law.
</dd>
<dt>Will you send nasty, brutish spam to my email address?</dt>
-<dd>Never. If you opt to when adding a problem or comment, you will receive emails
+<dd>Never. If you opt to when adding a problem or update, you will receive emails
about updates to that problem, but that's it.
</dd>
-
</dl>
<h2>Organisation Questions</h2>
@@ -85,7 +84,7 @@ about updates to that problem, but that's it.
<dt>Who built Neighbourhood Fix-It?</dt>
<dd>This site was built by <a href="http://www.mysociety.org">mySociety</a>.
-mySociety is a charitable organisation which has grown out of this community of
+mySociety is a charitable organisation which has grown out of the community of
volunteers who built sites like <a href="http://www.theyworkforyou.com/">TheyWorkForYou.com</a>.
mySociety's primary
mission is to build Internet projects which give people simple, tangible
diff --git a/web/index.cgi b/web/index.cgi
index cfe9dad47..3cbf9b31f 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.54 2007-01-19 23:26:32 matthew Exp $
+# $Id: index.cgi,v 1.55 2007-01-23 23:59:08 matthew Exp $
# TODO
# Nothing is done about the update checkboxes - not stored anywhere on anything!
@@ -26,6 +26,7 @@ use RABX;
use POSIX qw(strftime);
use CGI::Carp;
use Digest::MD5 qw(md5_hex);
+use URI::Escape;
use Page;
use mySociety::AuthToken;
@@ -95,20 +96,20 @@ sub front_page {
<p id="expl">Report, view, or discuss local problems
like graffiti, fly tipping, broken paving slabs, or street lighting</p>
EOF
- $out .= '<p id="error">' . $error . 'Please try again.</p>' if ($error);
+ $out .= '<p id="error">' . $error . '</p>' if ($error);
$out .= <<EOF;
<form action="./" method="get" id="postcodeForm">
-<label for="pc">Enter a nearby postcode or street name:</label>
+<label for="pc">Enter a nearby postcode, or street name and area:</label>
&nbsp;<input type="text" name="pc" value="$pc_h" id="pc" size="10" maxlength="200">
&nbsp;<input type="submit" value="Go">
</form>
-<p>Reports are sent directly to the local council, apart from a few councils where we're missing details.</p>
+<p>Reports are sent directly to the local council, apart from a few councils where we&rsquo;re missing details.</p>
<p>Reporting a problem is very simple:</p>
<ol>
-<li>Enter a postcode or street name;
+<li>Enter a postcode or street name and area;
<li>Locate the problem on a high-scale map;
<li>Enter details of the problem;
<li>Submit to your council.
@@ -406,7 +407,7 @@ sub display {
my $e = shift;
if ($e->value() == mySociety::MaPit::BAD_POSTCODE
|| $e->value() == mySociety::MaPit::POSTCODE_NOT_FOUND) {
- $error = 'That postcode was not recognised, sorry. ';
+ $error = 'That postcode was not recognised, sorry.';
} else {
$error = $e;
}
@@ -414,6 +415,7 @@ sub display {
my $e = shift;
$error = $e;
};
+ return geocode_choice($error) if (ref($error) eq 'ARRAY');
return front_page($q, $error) if ($error);
my ($pins, $current_map, $current, $fixed) = map_pins($q, $x, $y);
@@ -622,8 +624,10 @@ sub map_pins {
}
}
my $fixed = select_all(
- "select id, title, easting, northing from problem where state='fixed'
- order by created desc limit 9");
+ "select id, title, easting, northing, distance
+ from problem_find_nearby(?, ?, 10) as nearby, problem
+ where nearby.problem_id = problem.id and state='fixed'
+ order by created desc limit 9", $mid_e, $mid_n);
foreach (@$fixed) {
my $px = os_to_px($_->{easting}, $x);
my $py = os_to_px($_->{northing}, $y);
@@ -712,44 +716,51 @@ sub display_map_end {
return $out;
}
+sub geocode_choice {
+ my $choices = shift;
+ my $out = '<p>We found more than one match for that location:</p> <ul>';
+ foreach my $choice (@$choices) {
+ my $qs = $choice->[0];
+ my $text = $choice->[1];
+ $text =~ s/<\/?(?:b|i)>//g;
+ $text =~ s/, United Kingdom//;
+ $qs =~ s/,\+United\+Kingdom//;
+ $out .= '<li><a href="/?pc=' . $qs . '">' . $text . "</a></li>\n";
+ }
+ $out .= '</ul>';
+ return $out;
+}
+
sub geocode {
my ($s) = @_;
my ($x, $y, $error);
- my @loc = split /\s*,\s*/, $s;
- #if (2 == @loc) {
- # my $url = 'http://geo.localsearchmaps.com/?country=UK&cb=cb&cbe=cbe&address='.$loc[0].'&city='.$loc[1];
- # my $js = LWP::Simple::get($url);
+ $s = lc($s);
+ $s =~ s/[^-&0-9a-z ']//g;
+ $s = uri_escape($s);
+ $s =~ s/%20/+/g;
+ my $url = 'http://maps.google.co.uk/maps?output=js&q=' . $s;
my $cache_dir = mySociety::Config::get('GEO_CACHE');
- if (1 == @loc) {
- my $url = 'http://geo.localsearchmaps.com/?country=UK&format=xml&address='.$loc[0].'&city=London';
- my $cache_file = $cache_dir . md5_hex($url);
- my $js;
- if (-e $cache_file) {
- $js = File::Slurp::read_file($cache_file);
- } else {
- $js = LWP::Simple::get($url);
- File::Slurp::write_file($cache_file, $js);
- }
- if ($js =~ /^<response>\s+(.*?)\s+<\/response>$/s) {
- my $response = $1;
- my ($e) = $response =~ /<error>(.*?)<\/error>/;
- my ($lat) = $response =~ /<latitude>(.*?)<\/latitude>/;
- my ($lon) = $response =~ /<longitude>(.*?)<\/longitude>/;
- my ($level) = $response =~ /<matchlevel>(.*?)<\/matchlevel>/;
- if ($e) {
- $error = $e;
- } elsif ($level =~ /city/i) {
- $error = 'Could not understand that currently, sorry. ';
- } else {
- my ($easting,$northing) = mySociety::GeoUtil::wgs84_to_national_grid($lat, $lon, 'G');
- $x = int(os_to_tile($easting))-1;
- $y = int(os_to_tile($northing))-1;
- }
- } else {
- $error = 'Could not understand that currently, sorry. ';
+ my $cache_file = $cache_dir . md5_hex($url);
+ my $js;
+ if (-s $cache_file) {
+ $js = File::Slurp::read_file($cache_file);
+ } else {
+ $js = LWP::Simple::get($url);
+ File::Slurp::write_file($cache_file, $js);
+ }
+ if ($js =~ /panel: '(.*?)'/ && $js =~ /We could not understand/) {
+ $error = $1;
+ } elsif ($js =~ /panel: '(.*?)'/) {
+ my $refine = $1;
+ while ($refine =~ /<div class=\\042ref\\042><a href=\\042\/maps\?q=(.*?)&.*?>(.*?)<\/a><\/div>/g) {
+ push (@$error, [ $1, $2 ]);
}
} else {
- $error = 'Could not understand that currently, sorry. ';
+ $js =~ /center: {lat: (.*?),lng: (.*?)}/;
+ my $lat = $1; my $lon = $2;
+ my ($easting,$northing) = mySociety::GeoUtil::wgs84_to_national_grid($lat, $lon, 'G');
+ $x = int(os_to_tile($easting))-1;
+ $y = int(os_to_tile($northing))-1;
}
return ($x, $y, $error);
}
@@ -760,7 +771,7 @@ sub postcode_check {
my ($pc, $x, $y) = @_;
my $areas = mySociety::MaPit::get_voting_areas($pc);
my $valid = remove_invalid_councils($areas);
- throw Error::Simple("I'm afraid that postcode isn't yet covered by us.\n") unless $areas && $valid;
+ throw Error::Simple("We don't have the details for the council for this area.") unless $areas && $valid;
$x ||= 0; $x += 0;
$y ||= 0; $y += 0;
diff --git a/web/js.js b/web/js.js
index 24f1a7c05..fc1e7409b 100644
--- a/web/js.js
+++ b/web/js.js
@@ -73,15 +73,13 @@ function update_tiles(dx, dy, force) {
y -= vertical;
tile_y += vertical;
- var url = '/tilma/tileserver/10k-full-london/' + x + '-' + (x+5) + ',' + y + '-' + (y+5) + '/JSON';
- var req = YAHOO.util.Connect.asyncRequest('GET', url, async_response);
+ var url = '/tilma/tileserver/10k-full/' + x + '-' + (x+5) + ',' + y + '-' + (y+5) + '/JSON';
+ var req = YAHOO.util.Connect.asyncRequest('GET', url, {
+ success: urls_loaded, failure: urls_not_loaded,
+ argument: [tile_x, tile_y]
+ });
}
-var async_response = {
- success: urls_loaded,
- failure: urls_not_loaded
-};
-
function urls_not_loaded(o) { /* Nothing yet */ }
// Load 6x6 grid of tiles around current 2x2
@@ -89,9 +87,9 @@ function urls_loaded(o) {
var tiles = eval(o.responseText);
var drag = document.getElementById('drag');
for (var i=0; i<6; i++) {
- var ii = (i + tile_y);
+ var ii = (i + o.argument[1]);
for (var j=0; j<6; j++) {
- var jj = (j + tile_x);
+ var jj = (j + o.argument[0]);
var id = 't'+ii+'.'+jj;
var xx = x+j;
var yy = y+5-i;
@@ -111,7 +109,7 @@ function urls_loaded(o) {
img.style.visibility = 'hidden';
img.onload=function() { this.style.visibility = 'visible'; }
}
- img.src = 'http://tilma.mysociety.org/tileserver/10k-full-london/' + tiles[i][j];
+ img.src = 'http://tilma.mysociety.org/tileserver/10k-full/' + tiles[i][j];
tileCache[id] = { x: xx, y: yy, t: img };
drag.appendChild(img);
}