diff options
Diffstat (limited to 'perllib/FixMyStreet/App')
-rwxr-xr-x | perllib/FixMyStreet/App/Controller/Develop.pm | 10 | ||||
-rwxr-xr-x | perllib/FixMyStreet/App/View/EmailText.pm | 29 |
2 files changed, 38 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Develop.pm b/perllib/FixMyStreet/App/Controller/Develop.pm index d2457a3d7..6a1c10b22 100755 --- a/perllib/FixMyStreet/App/Controller/Develop.pm +++ b/perllib/FixMyStreet/App/Controller/Develop.pm @@ -142,6 +142,7 @@ sub email_previewer : Path('/_dev/email') : Args(1) { # Look through the Email::MIME email for the text/html part, and any inline # images. Turn the images into data: URIs. + my $text = ''; my $html = ''; my %images; $email->walk_parts(sub { @@ -151,6 +152,8 @@ sub email_previewer : Path('/_dev/email') : Args(1) { (my $cid = $part->header('Content-ID')) =~ s/[<>]//g; (my $ct = $part->content_type) =~ s/;.*//; $images{$cid} = "$ct;base64," . $part->body_raw; + } elsif ($part->content_type =~ m[text/plain]i) { + $text = $part->body_str; } elsif ($part->content_type =~ m[text/html]i) { $html = $part->body_str; } @@ -160,7 +163,12 @@ sub email_previewer : Path('/_dev/email') : Args(1) { $html =~ s/cid:([^"]*)/data:$images{$1}/g; } - $c->response->body($html); + if ($c->get_param('text')) { + $c->response->header(Content_type => 'text/plain'); + $c->response->body($text); + } else { + $c->response->body($html); + } } =item problem_confirm_previewer diff --git a/perllib/FixMyStreet/App/View/EmailText.pm b/perllib/FixMyStreet/App/View/EmailText.pm new file mode 100755 index 000000000..6b28ca13f --- /dev/null +++ b/perllib/FixMyStreet/App/View/EmailText.pm @@ -0,0 +1,29 @@ +package FixMyStreet::App::View::EmailText; +use base 'Catalyst::View::TT'; + +use strict; +use warnings; + +use FixMyStreet; +use FixMyStreet::Template; + +__PACKAGE__->config( + CLASS => 'FixMyStreet::Template', + TEMPLATE_EXTENSION => '.txt', + INCLUDE_PATH => [ FixMyStreet->path_to( 'templates', 'email', 'default' ) ], + render_die => 1, + disable_autoescape => 1, +); + +=head1 NAME + +FixMyStreet::App::View::EmailText - TT View for FixMyStreet::App + +=head1 DESCRIPTION + +A TT view for the text part of emails - so no HTML auto-escaping + +=cut + +1; + |