[Rt-commit] rt branch, 3.8-html-templates, updated. rt-3.8.7-278-g3dafdf9
Thomas Sibley
trs at bestpractical.com
Tue Nov 16 17:57:14 EST 2010
The branch, 3.8-html-templates has been updated
via 3dafdf90d1a87bd14d3b109e44d89e6bd0f485c8 (commit)
from 9492120561823d19b8e5fc32997fe893ebe38d50 (commit)
Summary of changes:
lib/RT/Interface/Email.pm | 23 +++++++++++++++++++++++
lib/RT/Template_Overlay.pm | 3 +--
lib/RT/Transaction_Overlay.pm | 2 +-
3 files changed, 25 insertions(+), 3 deletions(-)
- Log -----------------------------------------------------------------
commit 3dafdf90d1a87bd14d3b109e44d89e6bd0f485c8
Author: Thomas Sibley <trs at bestpractical.com>
Date: Tue Nov 16 17:57:09 2010 -0500
Factor out our HTML to text conversion routine
diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index 6df907c..297dffe 100755
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -1787,6 +1787,29 @@ sub IsCorrectAction {
return ( 1, @actions );
}
+=head2 ConvertHTMLToText HTML
+
+Takes HTML and converts it to plain text. Appropriate for generating a plain
+text part from an HTML part of an email.
+
+=cut
+
+sub ConvertHTMLToText {
+ my $html = shift;
+
+ require HTML::FormatText::WithLinks::AndTables;
+ return HTML::FormatText::WithLinks::AndTables->convert(
+ $html => {
+ leftmargin => 0,
+ rightmargin => 78,
+ no_rowspacing => 1,
+ before_link => '',
+ after_link => ' (%1)',
+ footnote => '',
+ }
+ );
+}
+
eval "require RT::Interface::Email_Vendor";
die $@ if ( $@ && $@ !~ qr{^Can't locate RT/Interface/Email_Vendor.pm} );
eval "require RT::Interface::Email_Local";
diff --git a/lib/RT/Template_Overlay.pm b/lib/RT/Template_Overlay.pm
index ec181cf..101cfa3 100755
--- a/lib/RT/Template_Overlay.pm
+++ b/lib/RT/Template_Overlay.pm
@@ -440,9 +440,8 @@ sub _DowngradeFromHTML {
$orig_entity->head->mime_attr( "Content-Type.charset" => 'utf-8' );
$orig_entity->make_multipart('alternative', Force => 1);
- require HTML::FormatText::WithLinks::AndTables;
$new_entity->bodyhandle(MIME::Body::InCore->new(
- \( HTML::FormatText::WithLinks::AndTables->convert($new_entity->bodyhandle->as_string, { no_rowspacing => 1 }) )
+ \(RT::Interface::Email::ConvertHTMLToText($new_entity->bodyhandle->as_string))
));
$orig_entity->add_part($new_entity, 0); # plain comes before html
diff --git a/lib/RT/Transaction_Overlay.pm b/lib/RT/Transaction_Overlay.pm
index 146ba40..f3750a1 100755
--- a/lib/RT/Transaction_Overlay.pm
+++ b/lib/RT/Transaction_Overlay.pm
@@ -312,7 +312,7 @@ sub Content {
$content =~ s/<p>--\s+<br \/>.*?$//s if $args{'Quote'};
if ($args{Type} ne 'text/html') {
- $content = HTML::FormatText::WithLinks::AndTables->convert($content, { no_rowspacing => 1 });
+ $content = RT::Interface::Email::ConvertHTMLToText($content);
}
}
else {
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list