diff options
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Open311.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Photo.pm | 16 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Reports.pm | 18 | ||||
-rwxr-xr-x | perllib/FixMyStreet/App/Controller/Rss.pm | 9 |
4 files changed, 17 insertions, 28 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Open311.pm b/perllib/FixMyStreet/App/Controller/Open311.pm index f35dc64a5..4f1727b1a 100644 --- a/perllib/FixMyStreet/App/Controller/Open311.pm +++ b/perllib/FixMyStreet/App/Controller/Open311.pm @@ -284,7 +284,7 @@ sub output_requests : Private { my $display_photos = $c->cobrand->allow_photo_display($problem); if ($display_photos && $problem->photo) { my $url = $c->cobrand->base_url(); - my $imgurl = $url . "/photo/$id.full.jpeg"; + my $imgurl = $url . $problem->photos->[0]->{url_full}; $request->{'media_url'} = [ $imgurl ]; } push(@problemlist, $request); diff --git a/perllib/FixMyStreet/App/Controller/Photo.pm b/perllib/FixMyStreet/App/Controller/Photo.pm index bfb1c5535..d24d3ff71 100644 --- a/perllib/FixMyStreet/App/Controller/Photo.pm +++ b/perllib/FixMyStreet/App/Controller/Photo.pm @@ -29,12 +29,12 @@ Display a photo =cut -sub during :LocalRegex('^([0-9a-f]{40})\.(temp|fulltemp)\.jpeg$') { +sub during :LocalRegex('^(temp|fulltemp)\.([0-9a-f]{40}\.(?:jpeg|png|gif|tiff))$') { my ( $self, $c ) = @_; - my ( $hash, $size ) = @{ $c->req->captures }; + my ( $size, $filename ) = @{ $c->req->captures }; my $photoset = FixMyStreet::App::Model::PhotoSet->new({ - data_items => [ $hash ] + data_items => [ $filename ] }); $size = $size eq 'temp' ? 'default' : 'full'; @@ -43,7 +43,7 @@ sub during :LocalRegex('^([0-9a-f]{40})\.(temp|fulltemp)\.jpeg$') { $c->forward( 'output', [ $photo ] ); } -sub index :LocalRegex('^(c/)?(\d+)(?:\.(\d+))?(?:\.(full|tn|fp))?\.jpeg$') { +sub index :LocalRegex('^(c/)?(\d+)(?:\.(\d+))?(?:\.(full|tn|fp))?\.(?:jpeg|png|gif|tiff)$') { my ( $self, $c ) = @_; my ( $is_update, $id, $photo_number, $size ) = @{ $c->req->captures }; @@ -79,10 +79,10 @@ sub output : Private { # Save to file File::Path::make_path( FixMyStreet->path_to( 'web', 'photo', 'c' )->stringify ); - File::Slurp::write_file( FixMyStreet->path_to( 'web', $c->req->path )->stringify, \$photo ); + File::Slurp::write_file( FixMyStreet->path_to( 'web', $c->req->path )->stringify, \$photo->{data} ); - $c->res->content_type( 'image/jpeg' ); - $c->res->body( $photo ); + $c->res->content_type( $photo->{content_type} ); + $c->res->body( $photo->{data} ); } sub no_photo : Private { @@ -140,7 +140,7 @@ sub process_photo_upload_or_cache : Private { /^photo/ ? # photo, photo1, photo2 etc. ($c->req->upload($_)) : () } sort $c->req->upload), - split /,/, ($c->get_param('upload_fileid') || '') + grep { $_ } split /,/, ($c->get_param('upload_fileid') || '') ); my $photoset = FixMyStreet::App::Model::PhotoSet->new({ diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm index 027b0d5a4..02dc4dc11 100644 --- a/perllib/FixMyStreet/App/Controller/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Reports.pm @@ -188,15 +188,6 @@ sub rss_area_ward : Path('/rss/area') : Args(2) { # We're checking an area here, but this function is currently doing that. return if $c->cobrand->reports_body_check( $c, $area ); - # If we're passed an ID number (don't think this is used anywhere, it - # certainly shouldn't be), just look that up on mapit and redirect - if ($area =~ /^\d+$/) { - my $council = mySociety::MaPit::call('area', $area); - $c->detach( 'redirect_index') if $council->{error}; - $c->stash->{body} = $council; - $c->detach( 'redirect_body' ); - } - # We must now have a string to check on mapit my $areas = mySociety::MaPit::call( 'areas', $area, type => $c->cobrand->area_types, @@ -296,15 +287,6 @@ sub body_check : Private { # Oslo/ kommunes sharing a name in Norway return if $c->cobrand->reports_body_check( $c, $q_body ); - # If we're passed an ID number (don't think this is used anywhere, it - # certainly shouldn't be), just look that up on MaPit and redirect - if ($q_body =~ /^\d+$/) { - my $area = mySociety::MaPit::call('area', $q_body); - $c->detach( 'redirect_index') if $area->{error}; - $c->stash->{body} = $area; - $c->detach( 'redirect_body' ); - } - # We must now have a string to check my @bodies = $c->model('DB::Body')->search( { name => { -like => "$q_body%" } } )->all; diff --git a/perllib/FixMyStreet/App/Controller/Rss.pm b/perllib/FixMyStreet/App/Controller/Rss.pm index 6047f063b..d708aa71c 100755 --- a/perllib/FixMyStreet/App/Controller/Rss.pm +++ b/perllib/FixMyStreet/App/Controller/Rss.pm @@ -6,6 +6,8 @@ use POSIX qw(strftime); use URI::Escape; use XML::RSS; +use FixMyStreet::App::Model::PhotoSet; + use mySociety::Gaze; use mySociety::Locale; use mySociety::MaPit; @@ -277,8 +279,13 @@ sub add_row : Private { $item{category} = ent($row->{category}) if $row->{category}; if ($c->cobrand->allow_photo_display($row) && $row->{photo}) { + # Bit yucky as we don't have full objects here + my $photoset = FixMyStreet::App::Model::PhotoSet->new({ db_data => $row->{photo} }); + my $first_fn = $photoset->get_id(0); + my ($hash, $format) = split /\./, $first_fn; + my $cachebust = substr($hash, 0, 8); my $key = $alert_type->item_table eq 'comment' ? 'c/' : ''; - $item{description} .= ent("\n<br><img src=\"". $base_url . "/photo/$key$row->{id}.jpeg\">"); + $item{description} .= ent("\n<br><img src=\"". $base_url . "/photo/$key$row->{id}.0.$format?$cachebust\">"); } if ( $row->{used_map} ) { |