diff options
-rw-r--r-- | perllib/Page.pm | 17 | ||||
-rw-r--r-- | web/css/core.css | 4 | ||||
-rwxr-xr-x | web/index.cgi | 6 | ||||
-rwxr-xr-x | web/photo.cgi | 22 |
4 files changed, 33 insertions, 16 deletions
diff --git a/perllib/Page.pm b/perllib/Page.pm index d27fe0f80..916918686 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.82 2008-03-21 14:31:39 matthew Exp $ +# $Id: Page.pm,v 1.83 2008-03-28 16:36:47 matthew Exp $ # package Page; @@ -72,7 +72,7 @@ sub microsite { my $q = shift; my $host = $ENV{HTTP_HOST} || ''; $q->{site} = 'fixmystreet'; - $q->{site} = 'scambs' if $host =~ /scambs/; + $q->{site} = 'scambs' if $host =~ /scambs/ || $q->param('scamb'); } =item header Q [PARAM VALUE ...] @@ -454,7 +454,8 @@ sub display_problem_text { sub display_problem_updates { my $id = shift; my $updates = select_all( - "select id, name, extract(epoch from created) as created, text, mark_fixed, mark_open + "select id, name, extract(epoch from created) as created, text, + mark_fixed, mark_open, (photo is not null) as has_photo from comment where problem_id = ? and state='confirmed' order by created", $id); my $out = ''; @@ -462,7 +463,7 @@ sub display_problem_updates { $out .= '<div id="updates">'; $out .= '<h2>Updates</h2>'; foreach my $row (@$updates) { - $out .= "<div><a name=\"update_$row->{id}\"></a><em>"; + $out .= "<div><p><a name=\"update_$row->{id}\"></a><em>"; if ($row->{name}) { $out .= 'Posted by ' . ent($row->{name}); } else { @@ -471,8 +472,12 @@ sub display_problem_updates { $out .= " at " . prettify_epoch($row->{created}); $out .= ', marked fixed' if ($row->{mark_fixed}); $out .= ', reopened' if ($row->{mark_open}); - $out .= '</em>'; - $out .= '<br>' . ent($row->{text}) . '</div>'; + $out .= '</em></p>'; + $out .= '<p>' . ent($row->{text}) . '</p>'; + if ($row->{has_photo}) { + $out .= '<p align="center"><img src="/photo?tn=1;c=' . $row->{id} . '"></p>'; + } + $out .= '</div>'; } $out .= '</div>'; } diff --git a/web/css/core.css b/web/css/core.css index 5a0fb652e..9a40bd052 100644 --- a/web/css/core.css +++ b/web/css/core.css @@ -254,6 +254,10 @@ p#copyright { margin: 0 0 0.25em; border-bottom: dotted 1px #5e552b; } +#updates p { + margin: 0; +} + #alert_links { float: right; } diff --git a/web/index.cgi b/web/index.cgi index 69cb598f7..ee2586f39 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.183 2008-03-28 15:11:48 matthew Exp $ +# $Id: index.cgi,v 1.184 2008-03-28 16:36:48 matthew Exp $ use strict; use Standard; @@ -205,7 +205,7 @@ sub submit_update { sub workaround_pg_bytea { my ($st, $img_idx, @elements) = @_; my $s = dbh()->prepare($st); - for ($i=1; $i<=@elements; $i++) { + for (my $i=1; $i<=@elements; $i++) { if ($i == $img_idx) { $s->bind_param($i, $elements[$i-1], { pg_type => DBD::Pg::PG_BYTEA }); } else { @@ -687,7 +687,7 @@ sub display_problem { # Get all information from database return display_location($q, 'Unknown problem ID') if $input{id} =~ /\D/; my $problem = dbh()->selectrow_hashref( - "select id, easting, northing, council, category, title, detail, photo, + "select id, easting, northing, council, category, title, detail, (photo is not null) as photo, used_map, name, anonymous, extract(epoch from confirmed) as time, state, extract(epoch from whensent-confirmed) as whensent, extract(epoch from ms_current_timestamp()-lastupdate) as duration diff --git a/web/photo.cgi b/web/photo.cgi index d6d920007..33bff0bd7 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.7 2007-08-29 23:03:16 matthew Exp $ +# $Id: photo.cgi,v 1.8 2008-03-28 16:36:48 matthew Exp $ use strict; use Standard; @@ -17,12 +17,20 @@ sub main { my $q = shift; print $q->header(-type => 'image/jpeg', -expires => '+1y' ); - my $id = $q->param('id') || return; - my $problem = dbh()->selectrow_arrayref( - "select photo from problem where id=? and state in ('confirmed', 'fixed', 'flickr') - and photo is not null", {}, $id); - return unless $problem; - my $photo = $problem->[0]; + my $id = $q->param('id'); + my $c = $q->param('c'); + return unless ($id || $c); + my $photo; + if ($c) { + $photo = dbh()->selectrow_arrayref("select photo from comment where + id=? and state = 'confirmed' and photo is not null", {}, $c); + } else { + $photo = dbh()->selectrow_arrayref( "select photo from problem where + id=? and state in ('confirmed', 'fixed', 'flickr') and photo is not + null", {}, $id); + } + return unless $photo; + $photo = $photo->[0]; if ($q->param('tn')) { use Image::Magick; my $image = Image::Magick->new; |