aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rwxr-xr-xweb/confirm.cgi10
-rwxr-xr-xweb/contact.cgi6
-rw-r--r--web/css.css121
-rwxr-xr-xweb/index.cgi111
4 files changed, 152 insertions, 96 deletions
diff --git a/web/confirm.cgi b/web/confirm.cgi
index 29f0b7c98..6867169ac 100755
--- a/web/confirm.cgi
+++ b/web/confirm.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: confirm.cgi,v 1.1 2006-09-25 22:59:07 matthew Exp $
+# $Id: confirm.cgi,v 1.2 2006-09-26 16:11:51 matthew Exp $
use strict;
require 5.8.0;
@@ -43,15 +43,15 @@ sub main {
if ($type eq 'comment') {
dbh()->do("update comment set state='confirmed' where id=?", {}, $id);
my $id = dbh()->selectrow_array("select problem_id from comment where id=?", {}, $id);
- $out = <<EOF;
+ $out = <<EOF;
<p>You have successfully confirmed your comment and you can now <a href="/?id=$id">view it on the site</a>.</p>
EOF
- } elsif ($type eq 'problem') {
+ } elsif ($type eq 'problem') {
dbh()->do("update problem set state='confirmed' where id=?", {}, $id);
- $out = <<EOF;
+ $out = <<EOF;
<p>You have successfully confirmed your problem and you can now <a href="/?id=$id">view it on the site</a>.</p>
EOF
- }
+ }
dbh()->commit();
} else {
$out = <<EOF;
diff --git a/web/contact.cgi b/web/contact.cgi
index a77fa1c6a..1b5d620ec 100755
--- a/web/contact.cgi
+++ b/web/contact.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: contact.cgi,v 1.2 2006-09-25 18:39:54 matthew Exp $
+# $Id: contact.cgi,v 1.3 2006-09-26 16:11:51 matthew Exp $
use strict;
require 5.8.0;
@@ -23,9 +23,9 @@ sub main {
print Page::header($q, 'Contact');
my $out = '';
if ($q->param('submit_form')) {
- $out = contact_submit($q);
+ $out = contact_submit($q);
} else {
- $out = contact_page($q);
+ $out = contact_page($q);
}
print $out;
print Page::footer();
diff --git a/web/css.css b/web/css.css
index d8594d47f..aacd85b60 100644
--- a/web/css.css
+++ b/web/css.css
@@ -1,4 +1,3 @@
-
/* Generics */
body {
@@ -9,26 +8,8 @@ body {
}
h1 {
- font-size: 175%;
-}
-
-#header {
- font-size: 200%;
- font-weight: bold;
- border-bottom: solid 2px #968d63;
margin: 0;
- padding: 5px 0.5em;
- background-color: #e3d595;
- color: #968d63;
-}
-
-#header a:link, #header a:visited {
- color: #968d63;
- background-color: #e3d595;
- text-decoration: none;
-}
-#header a:active, #header a:hover {
- text-decoration: underline;
+ font-size: 175%;
}
a:link {
@@ -41,6 +22,26 @@ a:hover, a:active {
color: #ff0000;
}
+form {
+ margin: 0;
+}
+
+input {
+ font-size: 100%;
+}
+
+label {
+ float: left;
+ text-align: right;
+ padding-right: 0.5em;
+ width: 5em;
+}
+
+fieldset {
+ border: none;
+ padding: 0.5em;
+}
+
.v { display: none; }
#error {
@@ -59,6 +60,35 @@ ul#error {
/* Site-wide layout */
+#header {
+ font-size: 200%;
+ font-weight: bold;
+ border-bottom: solid 2px #968d63;
+ margin: 0;
+ padding: 5px 0.5em;
+ background-color: #e3d595;
+ color: #968d63;
+}
+
+#header a:link, #header a:visited {
+ color: #968d63;
+ background-color: #e3d595;
+ text-decoration: none;
+}
+#header a:active, #header a:hover {
+ text-decoration: underline;
+}
+
+#content {
+ width: 100%; /* Must specify a width or IE goes crazy wrong! */
+ position: relative;
+}
+
+/* Can't put the margin in #content because of above IE craziness */
+#wrapper {
+ margin: 2em;
+}
+
#navigation {
position: absolute;
top: 1em;
@@ -73,10 +103,13 @@ ul#error {
margin: 0;
}
+#navigation a {
+ display: block;
+}
#navigation a:link, #navigation a:visited {
color: #968d63;
background-color: #e3d595;
- padding: 5px 2em;
+ padding: 0.5em 2em;
}
#navigation a:hover, #navigation a:active {
background-color: #968d63;
@@ -95,14 +128,16 @@ ul#error {
/* Forms */
-input {
- font-size: 100%;
-}
-
#postcodeForm {
display: table;
+ _width: 18em;
+ text-align: center;
font-size: 150%;
- margin: 2em auto;
+ margin: 1em auto;
+ padding: 1em;
+ background-color: #e3d595;
+ -moz-border-radius: 1em;
+ border-radius: 1em;
}
#postcodeForm label {
@@ -110,16 +145,6 @@ input {
padding-right: 0;
}
-label {
- float: left;
- text-align: right;
- padding-right: 0.5em;
- width: 5em;
-}
-fieldset {
- border: none;
- padding: 0.5em;
-}
fieldset div {
margin-top: 2px;
}
@@ -133,14 +158,14 @@ fieldset div.checkbox label {
width: auto;
}
-/* Individual pages */
+/* Map */
#map {
border: solid 1px #000000;
width: 508px;
height: 508px;
position: relative;
- top: 0;
+ dtop: 0;
overflow: hidden;
float: right;
}
@@ -158,34 +183,32 @@ fieldset div.checkbox label {
}
*/
#map input {
- position: absolute;
cursor: crosshair;
}
-#log {
- border: solid 1px #ff0000;
- padding: 3px;
- font-size: 83%;
-}
+
#compass {
background-color: #ffffff;
color: #000000;
float: right;
margin: 0 1em 1em;
}
+
#compass img {
border: 0;
}
-#content {
- margin: 0 2em;
- position: relative;
-}
-
ul#current img {
position: absolute;
border: none;
}
+#expl {
+ text-align: center;
+ font-size: 150%;
+ margin: 2em;
+ font-weight: bolder;
+}
+
#comments div em {
border-bottom: dotted 1px #968d63;
}
diff --git a/web/index.cgi b/web/index.cgi
index fdd670520..e8d7fecdb 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.25 2006-09-25 22:59:07 matthew Exp $
+# $Id: index.cgi,v 1.26 2006-09-26 16:11:51 matthew Exp $
# TODO
# Nothing is done about the update checkboxes - not stored anywhere on anything!
@@ -88,18 +88,18 @@ sub front_page {
my ($q, $error) = @_;
my $pc_h = ent($q->param('pc') || '');
my $out = <<EOF;
-<p style="text-align: center; font-size: 150%; margin: 2em; font-weight: bolder;">Report or view local problems
+<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 .= <<EOF;
<form action="./" method="get" id="postcodeForm">
-<label for="pc">Enter your postcode:</label>
-<input type="text" name="pc" value="$pc_h" id="pc" size="10" maxlength="10">
-<input type="submit" value="Go">
+<label for="pc">Enter a postcode:</label>
+&nbsp;<input type="text" name="pc" value="$pc_h" id="pc" size="10" maxlength="10">
+&nbsp;<input type="submit" value="Go">
</form>
-<p>Reports are sent directly to your local council &ndash; at the moment, we only cover <em>Newham, Lewisham, and Islington</em> councils.</p>
+<p>Reports are sent directly to the local council &ndash; at the moment, we only cover <em>Newham, Lewisham, and Islington</em> councils.</p>
<p>Reporting a problem is hopefully very simple:</p>
@@ -118,7 +118,7 @@ EOF
sub submit_comment {
my $q = shift;
my @vars = qw(id name email comment updates);
- my %input = map { $_ => $q->param($_) } @vars;
+ my %input = map { $_ => $q->param($_) || '' } @vars;
my @errors;
push(@errors, 'Please enter a comment') unless $input{comment};
push(@errors, 'Please enter your name') unless $input{name};
@@ -139,10 +139,10 @@ sub submit_comment {
dbh()->commit();
my $email = mySociety::Email::construct_email({
- _template_ => $template,
- _parameters_ => \%h,
- From => [mySociety::Config::get('CONTACT_EMAIL'), 'Heighbourhood Fix-It'],
- To => [[$input{email}, $input{name}]],
+ _template_ => $template,
+ _parameters_ => \%h,
+ From => [mySociety::Config::get('CONTACT_EMAIL'), 'Heighbourhood Fix-It'],
+ To => [[$input{email}, $input{name}]],
});
my $result = mySociety::Util::send_email($email, mySociety::Config::get('CONTACT_EMAIL'), $input{email});
if ($result == mySociety::Util::EMAIL_SUCCESS) {
@@ -164,7 +164,7 @@ EOF
sub submit_problem {
my $q = shift;
my @vars = qw(title detail name email pc easting northing updates);
- my %input = map { $_ => $q->param($_) } @vars;
+ my %input = map { $_ => $q->param($_) || '' } @vars;
my @errors;
push(@errors, 'Please enter a title') unless $input{title};
push(@errors, 'Please enter some details') unless $input{detail};
@@ -190,10 +190,10 @@ sub submit_problem {
dbh()->commit();
my $email = mySociety::Email::construct_email({
- _template_ => $template,
- _parameters_ => \%h,
- From => [mySociety::Config::get('CONTACT_EMAIL'), 'Heighbourhood Fix-It'],
- To => [[$input{email}, $input{name}]],
+ _template_ => $template,
+ _parameters_ => \%h,
+ From => [mySociety::Config::get('CONTACT_EMAIL'), 'Heighbourhood Fix-It'],
+ To => [[$input{email}, $input{name}]],
});
my $result = mySociety::Util::send_email($email, mySociety::Config::get('CONTACT_EMAIL'), $input{email});
if ($result == mySociety::Util::EMAIL_SUCCESS) {
@@ -240,8 +240,8 @@ EOF
my ($px, $py, $easting, $northing);
if ($pin_x && $pin_y) {
# Map was clicked on
- $pin_x = click_to_tile($pin_tile_x, $pin_x);
- $pin_y = click_to_tile($pin_tile_y, $pin_y, 1);
+ $pin_x = click_to_tile($pin_tile_x, $pin_x);
+ $pin_y = click_to_tile($pin_tile_y, $pin_y, 1);
$px = tile_to_px($pin_x, $input{x});
$py = tile_to_px($pin_y, $input{y});
$easting = tile_to_os($pin_x);
@@ -288,10 +288,13 @@ EOF
sub display {
my ($q, @errors) = @_;
- my $pc = $q->param('pc');
+ my @vars = qw(pc x y);
+ my %input = map { $_ => $q->param($_) || '' } @vars;
+ my %input_h = map { $_ => $q->param($_) ? ent($q->param($_)) : '' } @vars;
+
my($error, $x, $y, $name);
try {
- ($name, $x, $y) = postcode_check($q, $pc);
+ ($name, $x, $y) = postcode_check($input{pc}, $input{x}, $input{y});
} catch RABX::Error with {
my $e = shift;
if ($e->value() == mySociety::MaPit::BAD_POSTCODE
@@ -302,36 +305,67 @@ sub display {
}
} catch Error::Simple with {
my $e = shift;
- $error = $e;
+ $error = $e;
};
return front_page($q, $error) if ($error);
my $out = '';
$out .= display_map($q, $x, $y, 1, 1);
- $out .= "<h1>$name</h1>";
+ if (!$input{x} && !$input{y}) {
+ $out .= "<h1>That postcode is in $name</h1>";
+ } else {
+ $out .= '<h1>Reporting a problem</h1>';
+ }
if (@errors) {
$out .= '<ul id="error"><li>' . join('</li><li>', @errors) . '</li></ul>';
}
$out .= <<EOF;
<p>To <strong>report a problem</strong>, please select the location of it on the map.
Use the arrows to the left of the map to scroll around.</p>
+<div>
+<h2>Recent problems reported on this map</h2>
+<ul id="current">
EOF
-
- # XXX: These lists are currently global; should presumably be local to map!
+ my $min_e = tile_to_os($x);
+ my $min_n = tile_to_os($y);
+ my $mid_e = tile_to_os($x+1);
+ my $mid_n = tile_to_os($y+1);
+ my $max_e = tile_to_os($x+2);
+ my $max_n = tile_to_os($y+2);
+ my $current_map = select_all(
+ "select id,title,easting,northing from problem where state='confirmed'
+ and easting>=? and easting<? and northing>=? and northing<?
+ order by created desc limit 3", $min_e, $max_e, $min_n, $max_n);
+ my @ids = ();
+ foreach (@$current_map) {
+ push(@ids, $_->{id});
+ my $px = os_to_px($_->{easting}, $x);
+ my $py = os_to_px($_->{northing}, $y);
+ $out .= '<li><a href="' . NewURL($q, id=>$_->{id}, x=>undef, y=>undef) . '">';
+ $out .= display_pin($px, $py);
+ $out .= $_->{title};
+ $out .= '</a></li>';
+ }
+ unless (@$current_map) {
+ $out .= '<li>No problems have been reported yet.</li>';
+ }
$out .= <<EOF;
- <div>
- <h2>Problems already reported</h2>
+ </ul>
+ <h2>Recent problems reported within 10km</h2>
<ul id="current">
EOF
my $current = select_all(
- "select id,title,easting,northing from problem where state='confirmed'
- order by created desc limit 3");
+ "select id, title, easting, northing, distance
+ from problem_find_nearby(?, ?, 10) as nearby, problem
+ where nearby.problem_id = problem.id
+ and state = 'confirmed'" . (@ids ? ' and id not in (' . join(',' , @ids) . ')' : '') . "
+ order by created desc limit 3", $mid_e, $mid_n);
foreach (@$current) {
my $px = os_to_px($_->{easting}, $x);
my $py = os_to_px($_->{northing}, $y);
$out .= '<li><a href="' . NewURL($q, id=>$_->{id}, x=>undef, y=>undef) . '">';
$out .= display_pin($px, $py);
- $out .= $_->{title};
+ $out .= $_->{title} . ' (' . int($_->{distance}+.5) . 'm)';
$out .= '</a></li>';
}
unless (@$current) {
@@ -357,7 +391,8 @@ EOF
$out .= '</ul></div>';
$out .= <<EOF;
<p>If you cannot see a map &ndash; if you have images turned off,
-or are using a text only browser, for example &ndash; please
+or are using a text only browser, for example &ndash; and you
+wish to report a problem, please
<a href="$skipurl">skip this step</a> and we will ask you
to describe the location of your problem instead.</p>
EOF
@@ -376,7 +411,7 @@ sub display_problem {
my ($q, @errors) = @_;
my @vars = qw(id name email comment updates x y);
- my %input = map { $_ => $q->param($_) } @vars;
+ my %input = map { $_ => $q->param($_) || '' } @vars;
my %input_h = map { $_ => $q->param($_) ? ent($q->param($_)) : '' } @vars;
$input{x} += 0;
$input{y} += 0;
@@ -417,9 +452,9 @@ sub display_problem {
$out .= '<div id="comments"> <h3>Comments</h3>';
foreach my $row (@$comments) {
$out .= "<div><em>Posted by $row->{name} at " . prettify_epoch($row->{whenposted}) . '</em>';
- $out .= '<br>' . $row->{text} . '</div>';
+ $out .= '<br>' . $row->{text} . '</div>';
}
- $out .= '</div>';
+ $out .= '</div>';
}
$out .= '<h3>Add Comment</h3>';
if (@errors) {
@@ -473,7 +508,7 @@ sub display_map {
if ($type) {
my $pc_enc = ent($q->param('pc'));
$out .= <<EOF;
-<form action="./" method="post">
+<form action="./" method="get">
<input type="hidden" name="map" value="1">
<input type="hidden" name="x" value="$x">
<input type="hidden" name="y" value="$y">
@@ -503,7 +538,7 @@ sub display_map_end {
# Checks the postcode is in one of the two London boroughs
# and sets default X/Y co-ordinates if not provided in the URI
sub postcode_check {
- my ($q, $pc) = @_;
+ my ($pc, $x, $y) = @_;
my $areas;
$areas = mySociety::MaPit::get_voting_areas($pc);
@@ -517,10 +552,8 @@ sub postcode_check {
my $area_info = mySociety::MaPit::get_voting_area_info($lbo);
my $name = $area_info->{name};
- my $x = $q->param('x') || 0;
- my $y = $q->param('y') || 0;
- $x += 0;
- $y += 0;
+ $x ||= 0; $x += 0;
+ $y ||= 0; $y += 0;
if (!$x && !$y) {
my $location = mySociety::MaPit::get_location($pc);
my $northing = $location->{northing};