[Rt-commit] rt branch, html-templates, created. rt-3.9.4-483-gedc6d0a

Thomas Sibley trs at bestpractical.com
Wed Nov 17 16:03:54 EST 2010


The branch, html-templates has been created
        at  edc6d0a99a46a86d717ceed03f805864fcada7f1 (commit)

- Log -----------------------------------------------------------------
commit b75d87318960dffe7895871b155c711980bed64f
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Mar 25 16:42:59 2010 -0400

    Add a rough initial cut of HTML templates

diff --git a/etc/initialdata b/etc/initialdata
index 212e962..93107b9 100755
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -486,6 +486,131 @@ Hour:         { $SubscriptionObj->SubValue('Hour') }
 }
 }
 },
+# HTML version of the templates
+    {
+     Name        => 'Correspondence in HTML',                            # loc
+     Description => 'HTML correspondence template',         # loc
+     Content     => q[RT-Attach-Message: yes
+Content-Type: text/html
+
+{$Transaction->Content( Type => 'text/html')}
+],
+   },
+
+   {
+     Queue       => '0',
+     Name        => 'Admin Correspondence in HTML',                     # loc
+     Description => 'HTML admin correspondence template',    # loc
+     Content     => q[RT-Attach-Message: yes
+Content-Type: text/html
+
+{ my $c = $Transaction->Content(Type => 'text/html');
+  my $url = $RT::WebURL."Ticket/Display.html?id=".$Ticket->id;
+  if (substr($c,0,500) =~ qr/\Q$url\E/) {
+     $OUT = $c;
+  } else {
+    $OUT = <<EOF;
+Ticket URL: <a href="$url">$url</a>
+<br/>
+<br/>
+<br/>
+$c
+EOF
+
+  }
+}
+],
+   },
+   {  
+      Queue       => '0',
+      Name        => 'Admin Comment in HTML',                           # loc
+      Description => 'HTML admin comment template',          # loc
+      Content     => q[Subject: [Comment] {my $s=($Transaction->Subject||$Ticket->Subject); $s =~ s/\[Comment\]//g; $comment =~ s/^Re//i; $s;}
+RT-Attach-Message: yes
+Content-Type: text/html
+
+<p>This is a comment about <a href="{$RT::WebURL}?q={$Ticket->id}">ticket {$Ticket->id}</a>. It is not sent to the Requestor(s):</p>
+<br/>
+{$Transaction->Content(Type => 'text/html')}
+],
+   },
+   {  Queue       => '0',
+      Name        => 'Status Change in HTML',                                     # loc
+      Description => 'Ticket status changed',                             # loc
+      Content     => q[Subject: Status Changed to: {$Transaction->NewValue}
+RT-Attach-Message: yes
+Content-Type: text/html
+
+<a href="{$RT::WebURL}?q={$Ticket->id}">{$RT::WebURL}?q={$Ticket->id}</a>
+<br/>
+<br/>
+{$Transaction->Content(Type => 'text/html')}
+],
+   },
+   {
+     Queue       => '0',
+     Name        => 'Resolved in HTML',                 # loc
+     Description => 'HTML Ticket Resolved',          # loc
+     Content     => q[Subject: Resolved: {$Ticket->Subject}
+Content-Type: text/html
+
+<p>According to our records, your request has been resolved.</p>
+
+<p>If you have any further questions or concerns, please respond to this message.</p>
+],
+   },
+   {  Queue       => '0',
+      Name        => 'Autoreply in HTML',                                         # loc
+      Description => 'HTML Autoresponse template',                     # loc
+      Content     => q[Subject: AutoReply: {$Ticket->Subject}
+Content-Type: text/html
+
+
+<p>Greetings,</p>
+
+<p>This message has been automatically generated in response to the
+creation of a trouble ticket regarding <b>{$Ticket->Subject()}</b>,
+a summary of which appears below.</p>
+
+<p>There is no need to reply to this message right now.  Your ticket has been
+assigned an ID of [{$rtname} #{$Ticket->id()}].</p>
+
+<p>Please include the string <b>[{$rtname} #{$Ticket->id}]</b>
+in the subject line of all future correspondence about this issue. To do so,
+you may reply to this message.</p>
+
+
+<p>Thank you,<br/>
+{$Ticket->QueueObj->CorrespondAddress()}</p>
+
+<hr/>
+{$Transaction->Content(Type => 'text/html')}
+],
+   },
+   {  
+      Queue       => '0',
+      Name        => 'Transaction in HTML',                     # loc
+      Description => 'Default transaction template',    # loc
+      Content     => q[RT-Attach-Message: yes
+Content-Type: text/html
+
+<b>{$Transaction->CreatedAsString}: {$Transaction->CreatorObj->Name} updated ticket {$Ticket->id}.</b>
+<br>
+<table border="0">
+<tr><td align="right"><b>Transaction:</b></td><td>{$Transaction->Description}</td></tr>
+<tr><td align="right"><b>Queue:</b></td><td>{$Ticket->QueueObj->Name}</td></tr>
+<tr><td align="right"><b>Subject:</b></td><td>{$Transaction->Subject || $Ticket->Subject || "(No subject given)"} </td></tr>
+<tr><td align="right"><b>Owner:</b></td><td>{$Ticket->OwnerObj->Name}</td></tr>
+<tr><td align="right"><b>Requestors:</b></td><td>{$Ticket->RequestorAddresses}</td></tr>
+<tr><td align="right"><b>Status:</b></td><td>{$Ticket->Status}</td></tr>
+<tr><td align="right"><b>Ticket URL:</b></td><td>{$RT::WebURL}?q={$Ticket->id}</td></tr>
+</table>
+
+<br/>
+<br/>
+{$Transaction->Content( Type => 'text/html')}
+],
+   },
 );
 
 @Scrips = (

commit 1a9900c61c1f2879cff4585f1fcf783da244b436
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Mar 25 17:05:05 2010 -0400

    todo list

diff --git a/etc/initialdata b/etc/initialdata
index 93107b9..532f883 100755
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -487,6 +487,9 @@ Hour:         { $SubscriptionObj->SubValue('Hour') }
 }
 },
 # HTML version of the templates
+# needs the approval templates to be converted
+# possibly the error templates
+# probably not the Forward templates
     {
      Name        => 'Correspondence in HTML',                            # loc
      Description => 'HTML correspondence template',         # loc

commit ffe7f6d926d15c4b35486d01266ffe6979a79416
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Mar 25 21:04:25 2010 -0400

    mark this as todos

diff --git a/etc/initialdata b/etc/initialdata
index 532f883..a04ed19 100755
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -487,6 +487,7 @@ Hour:         { $SubscriptionObj->SubValue('Hour') }
 }
 },
 # HTML version of the templates
+# TODO
 # needs the approval templates to be converted
 # possibly the error templates
 # probably not the Forward templates

commit 57cb0673f20efd65e875ba4a9f283d35d718808d
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Mar 25 21:07:35 2010 -0400

    More todos

diff --git a/etc/initialdata b/etc/initialdata
index a04ed19..21fdde2 100755
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -491,6 +491,8 @@ Hour:         { $SubscriptionObj->SubValue('Hour') }
 # needs the approval templates to be converted
 # possibly the error templates
 # probably not the Forward templates
+# needs an upgrade step
+# needs docs on how to swap your scrips to use the new templates
     {
      Name        => 'Correspondence in HTML',                            # loc
      Description => 'HTML correspondence template',         # loc

commit 441672862c1e851f79df737d96ba263da8adc9c1
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Fri Apr 2 14:01:55 2010 -0400

    fix link in Transaction in HTML template

diff --git a/etc/initialdata b/etc/initialdata
index 21fdde2..ba77d84 100755
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -609,7 +609,7 @@ Content-Type: text/html
 <tr><td align="right"><b>Owner:</b></td><td>{$Ticket->OwnerObj->Name}</td></tr>
 <tr><td align="right"><b>Requestors:</b></td><td>{$Ticket->RequestorAddresses}</td></tr>
 <tr><td align="right"><b>Status:</b></td><td>{$Ticket->Status}</td></tr>
-<tr><td align="right"><b>Ticket URL:</b></td><td>{$RT::WebURL}?q={$Ticket->id}</td></tr>
+<tr><td align="right"><b>Ticket URL:</b></td><td>{$RT::WebURL}Ticket/Display.html?id={$Ticket->id}</td></tr>
 </table>
 
 <br/>

commit affc7b3ca6ed2bcd40202f44160a436b20fa077b
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Fri Apr 2 14:05:24 2010 -0400

    quick test replacement using WithLinks::AndTables because it displays tables better

diff --git a/lib/RT/Template_Overlay.pm b/lib/RT/Template_Overlay.pm
index 133f9e5..4d94d40 100755
--- a/lib/RT/Template_Overlay.pm
+++ b/lib/RT/Template_Overlay.pm
@@ -564,20 +564,15 @@ sub _DowngradeFromHTML {
     $orig_entity->head->mime_attr( "Content-Type.charset" => 'utf-8' );
     $orig_entity->make_multipart('alternative', Force => 1);
 
-    require HTML::FormatText;
-    require HTML::TreeBuilder;
+    require HTML::FormatText::WithLinks::AndTables;
     require Encode;
-    # need to decode_utf8, see the doc of MIMEObj method
-    my $tree = HTML::TreeBuilder->new_from_content(
-        Encode::decode_utf8($new_entity->bodyhandle->as_string)
-    );
     $new_entity->bodyhandle(MIME::Body::InCore->new(
-        \(scalar HTML::FormatText->new(
-            leftmargin  => 0,
-            rightmargin => 78,
-        )->format( $tree ))
+        \( HTML::FormatText::WithLinks::AndTables->convert(
+                # need to decode_utf8, see the doc of MIMEObj method
+                Encode::decode_utf8($new_entity->bodyhandle->as_string),
+                { no_rowspacing => 1 }
+         ))
     ));
-    $tree->delete;
 
     $orig_entity->add_part($new_entity, 0); # plain comes before html
     $self->{MIMEObj} = $orig_entity;
diff --git a/lib/RT/Transaction_Overlay.pm b/lib/RT/Transaction_Overlay.pm
index e03f133..b19c9c2 100755
--- a/lib/RT/Transaction_Overlay.pm
+++ b/lib/RT/Transaction_Overlay.pm
@@ -80,8 +80,7 @@ use RT::Attachments;
 use RT::Scrips;
 use RT::Ruleset;
 
-use HTML::FormatText;
-use HTML::TreeBuilder;
+use HTML::FormatText::WithLinks::AndTables;
 
 
 =head2 Create
@@ -328,12 +327,7 @@ sub Content {
             $content =~ s/<p>--\s+<br \/>.*?$//s if $args{'Quote'};
 
             if ($args{Type} ne 'text/html') {
-                my $tree = HTML::TreeBuilder->new_from_content( $content );
-                $content = HTML::FormatText->new(
-                    leftmargin  => 0,
-                    rightmargin => 78,
-                )->format( $tree);
-                $tree->delete;
+                $content = HTML::FormatText::WithLinks::AndTables->convert($content, { no_rowspacing => 1 });
             }
         }
         else {

commit a935794ac162d809d583a0664bded7a3d56b8038
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 92d3022..d533f40 100755
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -1839,6 +1839,29 @@ sub _RecordSendEmailFailure {
     }
 }
 
+=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        => '',
+        }
+    );
+}
+
 RT::Base->_ImportOverlays();
 
 1;
diff --git a/lib/RT/Template_Overlay.pm b/lib/RT/Template_Overlay.pm
index 4d94d40..74a754b 100755
--- a/lib/RT/Template_Overlay.pm
+++ b/lib/RT/Template_Overlay.pm
@@ -567,11 +567,8 @@ sub _DowngradeFromHTML {
     require HTML::FormatText::WithLinks::AndTables;
     require Encode;
     $new_entity->bodyhandle(MIME::Body::InCore->new(
-        \( HTML::FormatText::WithLinks::AndTables->convert(
-                # need to decode_utf8, see the doc of MIMEObj method
-                Encode::decode_utf8($new_entity->bodyhandle->as_string),
-                { no_rowspacing => 1 }
-         ))
+        # need to decode_utf8, see the doc of MIMEObj method
+        \(RT::Interface::Email::ConvertHTMLToText(Encode::decode_utf8($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 b19c9c2..1539705 100755
--- a/lib/RT/Transaction_Overlay.pm
+++ b/lib/RT/Transaction_Overlay.pm
@@ -327,7 +327,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 {

commit edc6d0a99a46a86d717ceed03f805864fcada7f1
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Tue Nov 16 18:20:03 2010 -0500

    Update the HTML template links to use RT->Config and Ticket/Display.html

diff --git a/etc/initialdata b/etc/initialdata
index ba77d84..95bf4a1 100755
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -511,7 +511,7 @@ Content-Type: text/html
 Content-Type: text/html
 
 { my $c = $Transaction->Content(Type => 'text/html');
-  my $url = $RT::WebURL."Ticket/Display.html?id=".$Ticket->id;
+  my $url = RT->Config->Get('WebURL')."Ticket/Display.html?id=".$Ticket->id;
   if (substr($c,0,500) =~ qr/\Q$url\E/) {
      $OUT = $c;
   } else {
@@ -535,7 +535,7 @@ EOF
 RT-Attach-Message: yes
 Content-Type: text/html
 
-<p>This is a comment about <a href="{$RT::WebURL}?q={$Ticket->id}">ticket {$Ticket->id}</a>. It is not sent to the Requestor(s):</p>
+<p>This is a comment about <a href="{RT->Config->Get('WebURL')}Ticket/Display.html?id={$Ticket->id}">ticket {$Ticket->id}</a>. It is not sent to the Requestor(s):</p>
 <br/>
 {$Transaction->Content(Type => 'text/html')}
 ],
@@ -547,7 +547,7 @@ Content-Type: text/html
 RT-Attach-Message: yes
 Content-Type: text/html
 
-<a href="{$RT::WebURL}?q={$Ticket->id}">{$RT::WebURL}?q={$Ticket->id}</a>
+<a href="{RT->Config->Get('WebURL')}Ticket/Display.html?id={$Ticket->id}">{RT->Config->Get('WebURL')}Ticket/Display.html?id={$Ticket->id}</a>
 <br/>
 <br/>
 {$Transaction->Content(Type => 'text/html')}
@@ -609,7 +609,7 @@ Content-Type: text/html
 <tr><td align="right"><b>Owner:</b></td><td>{$Ticket->OwnerObj->Name}</td></tr>
 <tr><td align="right"><b>Requestors:</b></td><td>{$Ticket->RequestorAddresses}</td></tr>
 <tr><td align="right"><b>Status:</b></td><td>{$Ticket->Status}</td></tr>
-<tr><td align="right"><b>Ticket URL:</b></td><td>{$RT::WebURL}Ticket/Display.html?id={$Ticket->id}</td></tr>
+<tr><td align="right"><b>Ticket URL:</b></td><td><a href="{RT->Config->Get('WebURL')}Ticket/Display.html?id={$Ticket->id}">{RT->Config->Get('WebURL')}Ticket/Display.html?id={$Ticket->id}</a></td></tr>
 </table>
 
 <br/>

-----------------------------------------------------------------------


More information about the Rt-commit mailing list