diff options
-rw-r--r-- | web/css.css | 102 | ||||
-rwxr-xr-x | web/index.cgi | 49 | ||||
-rwxr-xr-x | web/photo.cgi | 13 |
3 files changed, 128 insertions, 36 deletions
diff --git a/web/css.css b/web/css.css index c8081837c..4fe06bf4b 100644 --- a/web/css.css +++ b/web/css.css @@ -163,11 +163,18 @@ ul#error { padding: 2px 4px; } -/* Forms */ +/* Front page */ + +#expl { + text-align: center; + font-size: 150%; + margin: 0 2em; + font-weight: bolder; +} #postcodeForm { display: table; - _width: 18em; + _width: 31em; text-align: center; font-size: 150%; margin: 1em auto; @@ -182,6 +189,54 @@ ul#error { padding-right: 0; } +#postcodeForm #submit { + font-size: 83%; +} + +#front_intro { + float: left; + width: 48%; +} + +#front_intro p { + clear: both; + margin-top: 0; +} + +#front_stats { + margin: 0.5em auto 0; + width: 20em; +} + +#front_stats div { + text-align: center; + width: 5.5em; + background-color: #e3d595; + -moz-border-radius: 0.5em; + border-radius: 0.5em; + float: left; + margin: 0 0.5em 1em; +} + +#front_stats div big { + font-size: 150%; + display: block; +} + +#front_recent { + float: right; + width: 48%; +} +#front_recent img { + margin-right: 0.25em; + margin-bottom: 0.25em; +} +#front_recent > h2:first-child { + margin-top: 0; +} + +/* Forms */ + fieldset div { margin-top: 2px; clear: left; @@ -233,14 +288,6 @@ p#copyright { margin-right: 530px; } -/*#drag { - width: 1em; - height: 1em; - position: absolute; - top: 0; - left: 0; -} -*/ #drag input { cursor: crosshair; background-color: #cccccc; @@ -282,11 +329,21 @@ ol#current img { } */ -#expl { +/* Problem pages */ + +#fixed, #unknown { + margin: 1em auto; + width: 80%; + padding: 5px; text-align: center; - font-size: 150%; - margin: 2em; - font-weight: bolder; +} +#fixed { + background-color: #ccffcc; + border: solid 2px #009900; +} +#unknown { + background-color: #ffcccc; + border: solid 2px #990000; } #updates div { @@ -311,6 +368,8 @@ ol#current img { margin: 0; } +/* RSS feed XSL */ + #rss_items { width:62%; float:left; @@ -327,20 +386,7 @@ ol#current img { border:1px solid #999999; } -#fixed, #unknown { - margin: 1em auto; - width: 80%; - padding: 5px; - text-align: center; -} -#fixed { - background-color: #ccffcc; - border: solid 2px #009900; -} -#unknown { - background-color: #ffcccc; - border: solid 2px #990000; -} +/* Report page */ #col_problems, #col_fixed { float: left; diff --git a/web/index.cgi b/web/index.cgi index 7183cd6a9..9f90dd334 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.137 2007-06-01 14:27:31 matthew Exp $ +# $Id: index.cgi,v 1.138 2007-06-13 14:56:19 matthew Exp $ use strict; require 5.8.0; @@ -91,25 +91,60 @@ sub front_page { like graffiti, fly tipping, broken paving slabs, or street lighting</p> EOF $out .= '<p id="error">' . $error . '</p>' if ($error); + my $fixed = dbh()->selectrow_array("select count(*) from problem where state='fixed' and lastupdate>ms_current_timestamp()-'1 month'::interval"); + my $updates = dbh()->selectrow_array("select count(*) from comment where state='confirmed'"); + my $new = dbh()->selectrow_array("select count(*) from problem where state in ('confirmed','fixed') and confirmed>ms_current_timestamp()-'1 week'::interval"); $out .= <<EOF; <form action="./" method="get" id="postcodeForm"> <label for="pc">Enter a nearby postcode, or street name and area:</label> <input type="text" name="pc" value="$pc_h" id="pc" size="10" maxlength="200"> - <input type="submit" value="Go"> + <input type="submit" value="Go" id="submit"> </form> -<p>Reports are sent directly to the local council, apart from a few councils where we’re missing details.</p> +<div id="front_intro"> -<p>Reporting a problem is very simple:</p> +<div id="front_stats"> +<div><big>$new</big> reports in past week</div> +<div><big>$fixed</big> fixed in past month</div> +<div><big>$updates</big> problem updates</div> +</div> + +<p>Reports are sent directly to the local council. +Reporting a problem is very simple:</p> <ol> -<li>Enter a postcode or street name and area; +<li>Enter a postcode or street name and area above; <li>Locate the problem on a high-scale map; <li>Enter details of the problem; <li>Submit to the council. </ol> +</div> + +<div id="front_recent"> EOF + + my $probs = select_all("select id, title from problem + where state in ('confirmed', 'fixed') and photo is not null + order by confirmed desc limit 3"); + $out .= '<h2>Recently reported photos</h2>' if @$probs; + foreach (@$probs) { + my $title = ent($_->{title}); + $out .= '<a href="/?id=' . $_->{id} . + '"><img border="0" src="/photo?tn=1;id=' . $_->{id} . + '" alt="' . $title . '" title="' . $title . '"></a>'; + } + $probs = select_all("select id,title from problem + where state in ('confirmed', 'fixed') + order by confirmed desc limit 5"); + $out .= '<h2>Recently reported problems</h2> <ul>' if @$probs; + foreach (@$probs) { + $out .= '<li><a href="/?id=' . $_->{id} . '">'. ent($_->{title}); + $out .= '</a>'; + } + $out .= '</ul>' if @$probs; + $out .= '</div>'; + return $out; } @@ -589,7 +624,7 @@ sub display_problem { $q->small($q->a({href => '/contact?id=' . $input{id}}, 'Offensive? Unsuitable? Tell us')) ); my $back = NewURL($q, id=>undef, x=>$x_tile, y=>$y_tile); - $out .= '<p style="padding-bottom: 0.5em; border-bottom: dotted 1px #999999;" align="right"><a href="' . $back . '">Back to listings</a></p>'; + $out .= '<p style="padding-bottom: 0.5em; border-bottom: dotted 1px #999999;" align="right"><a href="' . $back . '">More problems nearby</a></p>'; $out .= '<a href="/rss/'.$input_h{id}.'"><img align="right" src="/i/feed.png" width="16" height="16" title="RSS feed" alt="RSS feed of updates to this problem" border="0" hspace="4"></a> '; $out .= '<a id="email_alert" href="/alert?type=updates;id='.$input_h{id}.'"><img src="/i/email.png" width="16" height="16" title="Email alerts" alt="Email alerts of updates to this problem" border="0"></a>'; @@ -636,7 +671,7 @@ EOF my %params = ( rss => [ 'Updates to this problem, Neighbourhood Fix-It', "/rss/$input_h{id}" ], - title => $problem->{title} + title => $problem->{title} ); return ($out, %params); } diff --git a/web/photo.cgi b/web/photo.cgi index 71542b169..afcfa4751 100755 --- a/web/photo.cgi +++ b/web/photo.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: photo.cgi,v 1.3 2007-05-09 11:18:36 matthew Exp $ +# $Id: photo.cgi,v 1.4 2007-06-13 14:56:19 matthew Exp $ use strict; require 5.8.0; @@ -43,6 +43,17 @@ sub main { and photo is not null", {}, $id); return unless $problem; my $photo = $problem->[0]; + if ($q->param('tn')) { + use Image::Magick; + my $image = Image::Magick->new; + $image->BlobToImage($photo); + my $err = $image->Scale(geometry => "x100>"); + throw Error::Simple("resize failed: $err") if "$err"; + my @blobs = $image->ImageToBlob(); + undef $image; + $photo = $blobs[0]; + } + print $photo; dbh()->rollback(); } |