diff options
Diffstat (limited to 'perllib/FixMyStreet/App')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Contact.pm | 20 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Photo.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 11 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Model/PhotoSet.pm | 14 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/View/Email.pm | 7 |
6 files changed, 35 insertions, 19 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 93e8f4b22..44a653d62 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -8,7 +8,6 @@ use Path::Class; use POSIX qw(strftime strcoll); use Digest::SHA qw(sha1_hex); use mySociety::EmailUtil qw(is_valid_email); -use if !$ENV{TRAVIS}, 'Image::Magick'; use DateTime::Format::Strptime; use List::Util 'first'; diff --git a/perllib/FixMyStreet/App/Controller/Contact.pm b/perllib/FixMyStreet/App/Controller/Contact.pm index e20011471..5527256a6 100644 --- a/perllib/FixMyStreet/App/Controller/Contact.pm +++ b/perllib/FixMyStreet/App/Controller/Contact.pm @@ -168,26 +168,22 @@ sub prepare_params_for_email : Private { if ( $c->stash->{update} ) { - my $problem_url = $base_url . '/report/' . $c->stash->{update}->problem_id + $c->stash->{problem_url} = $base_url . '/report/' . $c->stash->{update}->problem_id . '#update_' . $c->stash->{update}->id; - my $admin_url = " - $admin_url" . '/update_edit/' . $c->stash->{update}->id - if $admin_url; - $c->stash->{message} .= sprintf( - " \n\n[ Complaint about update %d on report %d - %s%s ]", + $c->stash->{admin_url} = $admin_url . '/update_edit/' . $c->stash->{update}->id; + $c->stash->{complaint} = sprintf( + "Complaint about update %d on report %d", $c->stash->{update}->id, $c->stash->{update}->problem_id, - $problem_url, $admin_url ); } elsif ( $c->stash->{problem} ) { - my $problem_url = $base_url . '/report/' . $c->stash->{problem}->id; - $admin_url = " - $admin_url" . '/report_edit/' . $c->stash->{problem}->id - if $admin_url; - $c->stash->{message} .= sprintf( - " \n\n[ Complaint about report %d - %s%s ]", + $c->stash->{problem_url} = $base_url . '/report/' . $c->stash->{problem}->id; + $c->stash->{admin_url} = $admin_url . '/report_edit/' . $c->stash->{problem}->id; + $c->stash->{complaint} = sprintf( + "Complaint about report %d", $c->stash->{problem}->id, - $problem_url, $admin_url ); # flag this so it's automatically listed in the admin interface diff --git a/perllib/FixMyStreet/App/Controller/Photo.pm b/perllib/FixMyStreet/App/Controller/Photo.pm index 2734491fa..2302322bf 100644 --- a/perllib/FixMyStreet/App/Controller/Photo.pm +++ b/perllib/FixMyStreet/App/Controller/Photo.pm @@ -8,7 +8,6 @@ use JSON::MaybeXS; use File::Path; use File::Slurp; use FixMyStreet::App::Model::PhotoSet; -use if !$ENV{TRAVIS}, 'Image::Magick'; =head1 NAME diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 89df4a52d..6ac3c8ea1 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -278,6 +278,17 @@ sub delete :Local :Args(1) { return $c->res->redirect($uri); } +sub map : Path('') : Args(2) { + my ( $self, $c, $id, $map ) = @_; + + $c->detach( '/page_error_404_not_found', [] ) unless $map eq 'map'; + $c->forward( 'load_problem_or_display_error', [ $id ] ); + + my $image = $c->stash->{problem}->static_map; + $c->res->content_type($image->{content_type}); + $c->res->body($image->{data}); +} + __PACKAGE__->meta->make_immutable; 1; diff --git a/perllib/FixMyStreet/App/Model/PhotoSet.pm b/perllib/FixMyStreet/App/Model/PhotoSet.pm index 1c8a86e3a..487786a3b 100644 --- a/perllib/FixMyStreet/App/Model/PhotoSet.pm +++ b/perllib/FixMyStreet/App/Model/PhotoSet.pm @@ -4,7 +4,13 @@ package FixMyStreet::App::Model::PhotoSet; use Moose; use Path::Tiny 'path'; -use if !$ENV{TRAVIS}, 'Image::Magick'; + +my $IM = eval { + require Image::Magick; + Image::Magick->import; + 1; +}; + use Scalar::Util 'openhandle', 'blessed'; use Digest::SHA qw(sha1_hex); use Image::Size; @@ -318,7 +324,7 @@ sub rotate_image { sub _rotate_image { my ($photo, $direction) = @_; - return $photo unless $Image::Magick::VERSION; + return $photo unless $IM; my $image = Image::Magick->new; $image->BlobToImage($photo); my $err = $image->Rotate($direction); @@ -332,7 +338,7 @@ sub _rotate_image { # Shrinks a picture to the specified size, but keeping in proportion. sub _shrink { my ($photo, $size) = @_; - return $photo unless $Image::Magick::VERSION; + return $photo unless $IM; my $image = Image::Magick->new; $image->BlobToImage($photo); my $err = $image->Scale(geometry => "$size>"); @@ -346,7 +352,7 @@ sub _shrink { # Shrinks a picture to 90x60, cropping so that it is exactly that. sub _crop { my ($photo) = @_; - return $photo unless $Image::Magick::VERSION; + return $photo unless $IM; my $image = Image::Magick->new; $image->BlobToImage($photo); my $err = $image->Resize( geometry => "90x60^" ); diff --git a/perllib/FixMyStreet/App/View/Email.pm b/perllib/FixMyStreet/App/View/Email.pm index 86d5c1d60..6073ee814 100644 --- a/perllib/FixMyStreet/App/View/Email.pm +++ b/perllib/FixMyStreet/App/View/Email.pm @@ -14,7 +14,7 @@ __PACKAGE__->config( ], ENCODING => 'utf8', render_die => 1, - expose_methods => ['loc'], + expose_methods => ['loc', 'file_exists'], ); =head1 NAME @@ -40,5 +40,10 @@ sub loc { return _(@args); } +sub file_exists { + my ( $self, $c, @args ) = @_; + -e FixMyStreet->path_to(@args); +} + 1; |