[Rt-commit] rt branch, history-folding, updated. rt-3.9.5-433-gef58923

Jesse Vincent jesse at bestpractical.com
Wed Nov 24 15:56:48 EST 2010


The branch, history-folding has been updated
       via  ef58923f8d438c61ee6a791b66bd503f52ab150b (commit)
       via  bc47b211c17fbaf224e00c1075c25bae572ff531 (commit)
       via  ce611dc00d157f6f78876ab671a34be542abd1a6 (commit)
      from  564fcaafd88119f44b720ec2a6c6a35db66174f1 (commit)

Summary of changes:
 share/html/NoAuth/css/aileron/ticket.css           |    5 -
 share/html/NoAuth/css/ballard/ticket.css           |    6 -
 share/html/NoAuth/css/base/ticket.css              |   12 +++
 share/html/NoAuth/css/web2/ticket.css              |    6 -
 share/html/Ticket/Elements/FoldStanzaJS            |   11 +--
 share/html/Ticket/Elements/ShowHTMLMessageStanza   |   57 -----------
 share/html/Ticket/Elements/ShowMessageStanza       |  105 +++++++++++++-------
 .../Ticket/Elements/ShowTransactionAttachments     |   10 +-
 8 files changed, 87 insertions(+), 125 deletions(-)
 delete mode 100644 share/html/Ticket/Elements/ShowHTMLMessageStanza

- Log -----------------------------------------------------------------
commit ce611dc00d157f6f78876ab671a34be542abd1a6
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Wed Nov 24 13:14:55 2010 -0500

    refactor to remove <%PERL> blocks

diff --git a/share/html/Ticket/Elements/ShowHTMLMessageStanza b/share/html/Ticket/Elements/ShowHTMLMessageStanza
index 1824343..0682b3d 100644
--- a/share/html/Ticket/Elements/ShowHTMLMessageStanza
+++ b/share/html/Ticket/Elements/ShowHTMLMessageStanza
@@ -1,4 +1,13 @@
-<%perl>
+<%INIT>
+my $ticket = $Transaction ? $Transaction->TicketObj : undef;
+
+my $print_content = sub {
+    my $ref = shift;
+    return unless defined $$ref && length $$ref;
+
+    $m->callback( content => $ref, %ARGS );
+    $m->out( $$ref );
+};
 if ( ref $Message ) {
     $m->comp('FoldStanzaJS', Depth => $Depth);
     my @stack;
@@ -38,17 +47,6 @@ if ( ref $Message ) {
 } else {
     $print_content->( \$Message );
 }
-</%perl>
-<%INIT>
-my $ticket = $Transaction ? $Transaction->TicketObj : undef;
-
-my $print_content = sub {
-    my $ref = shift;
-    return unless defined $$ref && length $$ref;
-
-    $m->callback( content => $ref, %ARGS );
-    $m->out( $$ref );
-};
 </%INIT>
 <%ARGS>
 $Message => undef
diff --git a/share/html/Ticket/Elements/ShowMessageStanza b/share/html/Ticket/Elements/ShowMessageStanza
index 967c019..5aeb34d 100755
--- a/share/html/Ticket/Elements/ShowMessageStanza
+++ b/share/html/Ticket/Elements/ShowMessageStanza
@@ -45,7 +45,23 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<%perl>
+<%INIT>
+my $plain_text_pre = RT->Config->Get('PlainTextPre', $session{'CurrentUser'});
+my $plain_text_mono = RT->Config->Get('PlainTextMono', $session{'CurrentUser'});
+
+my $ticket = $Transaction ? $Transaction->TicketObj : undef;
+
+my $print_content = sub {
+    my $ref = shift;
+    return unless defined $$ref && length $$ref;
+
+    $m->callback( content => $ref, %ARGS );
+    $m->comp('/Elements/MakeClicky', content => $ref, ticket => $ticket, %ARGS);
+    unless ( $plain_text_pre || $plain_text_mono ) {
+        $$ref =~ s{(\r?\n)}{<br />}g if defined $$ref;
+    }
+    $m->out( $$ref );
+};
 if ( ref $Message ) {
     $m->out('<pre>') if $plain_text_pre && !$Depth && !$plain_text_mono;
     $m->comp('FoldStanzaJS', Depth => $Depth);
@@ -88,24 +104,6 @@ if ( ref $Message ) {
 } else {
       $print_content->( \$Message );
 }
-</%perl>
-<%INIT>
-my $plain_text_pre = RT->Config->Get('PlainTextPre', $session{'CurrentUser'});
-my $plain_text_mono = RT->Config->Get('PlainTextMono', $session{'CurrentUser'});
-
-my $ticket = $Transaction ? $Transaction->TicketObj : undef;
-
-my $print_content = sub {
-    my $ref = shift;
-    return unless defined $$ref && length $$ref;
-
-    $m->callback( content => $ref, %ARGS );
-    $m->comp('/Elements/MakeClicky', content => $ref, ticket => $ticket, %ARGS);
-    unless ( $plain_text_pre || $plain_text_mono ) {
-        $$ref =~ s{(\r?\n)}{<br />}g if defined $$ref;
-    }
-    $m->out( $$ref );
-};
 </%INIT>
 <%ARGS>
 $Message => undef

commit bc47b211c17fbaf224e00c1075c25bae572ff531
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Wed Nov 24 14:01:56 2010 -0500

    Unified plain and HTML message display codepaths. Cleaned up extra
    whitepsace before message stanzas in plain messages

diff --git a/share/html/Ticket/Elements/FoldStanzaJS b/share/html/Ticket/Elements/FoldStanzaJS
index 50b5b63..1855487 100644
--- a/share/html/Ticket/Elements/FoldStanzaJS
+++ b/share/html/Ticket/Elements/FoldStanzaJS
@@ -1,12 +1,3 @@
-% if ($Depth == 1 ) {
 <div
     class="message-stanza-folder"
-    onclick="fold_message_stanza(this, '<%loc('Show quoted text')%>', '<%loc('Hide quoted text')%>');"><%loc('Show quoted text')%></div>
-% }
-<div class="message-stanza<%($plain_text_mono ? " plain-text-white-space" : "")%>" <%($Depth == 1)? 'style="display: none;" ' : ''|n%>>
-<%ARGS>
-$Depth => 0
-</%ARGS>
-<%init>
-my $plain_text_mono = RT->Config->Get('PlainTextMono', $session{'CurrentUser'});
-</%init>
+    onclick="fold_message_stanza(this, '<%loc('Show quoted text')%>', '<%loc('Hide quoted text')%>');"><%loc('Show quoted text')%></div>\
diff --git a/share/html/Ticket/Elements/ShowHTMLMessageStanza b/share/html/Ticket/Elements/ShowHTMLMessageStanza
deleted file mode 100644
index 0682b3d..0000000
--- a/share/html/Ticket/Elements/ShowHTMLMessageStanza
+++ /dev/null
@@ -1,55 +0,0 @@
-<%INIT>
-my $ticket = $Transaction ? $Transaction->TicketObj : undef;
-
-my $print_content = sub {
-    my $ref = shift;
-    return unless defined $$ref && length $$ref;
-
-    $m->callback( content => $ref, %ARGS );
-    $m->out( $$ref );
-};
-if ( ref $Message ) {
-    $m->comp('FoldStanzaJS', Depth => $Depth);
-    my @stack;
-    my $para = '';
-    my $i = 0;
-
-    AGAIN: foreach ( ; $i < @$Message; $i++ ) {
-        my $stanza = $Message->[$i];
-        if ( ref $stanza eq "HASH" ) {
-            if ( $stanza->{raw} =~ /----- Original Message -----/ ) {
-                $Message->[$i+1] = [ splice @$Message, $i+1 ] if $Message->[$i+1];
-            }
-            $para .= (defined $stanza->{raw} ? $stanza->{raw} : '');
-        }
-        next unless ref $stanza eq "ARRAY";
-
-        $print_content->( \$para ); $para = '';
-
-        $Depth++;
-        push @stack, [$Message, $i+1];
-        ($Message, $i) = ($stanza, -1);
-
-        $m->comp('FoldStanzaJS', Depth => $Depth);
-    }
-    if ( length $para ) {
-        $print_content->( \$para ); $para = '';
-    }
-
-    if ( @stack ) {
-        ($Message, $i) = @{ pop @stack };
-        $Depth--;
-        $m->out('</div>');
-        goto AGAIN;
-    }
-
-    $m->out('</span>');
-} else {
-    $print_content->( \$Message );
-}
-</%INIT>
-<%ARGS>
-$Message => undef
-$Depth => 0
-$Transaction => undef
-</%ARGS>
diff --git a/share/html/Ticket/Elements/ShowMessageStanza b/share/html/Ticket/Elements/ShowMessageStanza
index 5aeb34d..c494019 100755
--- a/share/html/Ticket/Elements/ShowMessageStanza
+++ b/share/html/Ticket/Elements/ShowMessageStanza
@@ -46,8 +46,11 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 <%INIT>
-my $plain_text_pre = RT->Config->Get('PlainTextPre', $session{'CurrentUser'});
-my $plain_text_mono = RT->Config->Get('PlainTextMono', $session{'CurrentUser'});
+my $plain_text_pre
+    = RT->Config->Get( 'PlainTextPre', $session{'CurrentUser'} );
+my $plain_text_mono
+    = RT->Config->Get( 'PlainTextMono', $session{'CurrentUser'} );
+my $Depth = 0;
 
 my $ticket = $Transaction ? $Transaction->TicketObj : undef;
 
@@ -56,57 +59,83 @@ my $print_content = sub {
     return unless defined $$ref && length $$ref;
 
     $m->callback( content => $ref, %ARGS );
-    $m->comp('/Elements/MakeClicky', content => $ref, ticket => $ticket, %ARGS);
-    unless ( $plain_text_pre || $plain_text_mono ) {
-        $$ref =~ s{(\r?\n)}{<br />}g if defined $$ref;
+    if ( $ContentType eq 'text/plain' ) {
+        $m->comp( '/Elements/MakeClicky',
+                  content => $ref,
+                  ticket  => $ticket,
+                  %ARGS
+                );
+        unless ( $plain_text_pre || $plain_text_mono ) {
+            $$ref =~ s{(\r?\n)}{<br />}g if defined $$ref;
+        }
     }
-    $m->out( $$ref );
+    $m->out($$ref);
 };
 if ( ref $Message ) {
-    $m->out('<pre>') if $plain_text_pre && !$Depth && !$plain_text_mono;
-    $m->comp('FoldStanzaJS', Depth => $Depth);
+    $m->out('<pre>')
+        if (    $ContentType eq 'text/plain'
+             && $plain_text_pre
+             && !$Depth
+             && !$plain_text_mono );
+    $m->out(   '<div class="message-stanza'
+             . ( $plain_text_mono ? ' plain-text-white-space' : '' ) . '"'
+             . '>' );
 
     my @stack;
     my $para = '';
-    my $i = 0;
+    my $i    = 0;
 
-    AGAIN: foreach ( ; $i < @$Message; $i++ ) {
+AGAIN: foreach ( ; $i < @$Message; $i++ ) {
         my $stanza = $Message->[$i];
         if ( ref $stanza eq "HASH" ) {
-            if ( $stanza->{text} && $stanza->{text} =~ /----- Original Message -----/ ) {
-                $Message->[$i+1] = [ splice @$Message, $i+1 ] if $Message->[$i+1];
+            if (    $stanza->{raw}
+                 && $stanza->{raw} =~ /----- Original Message -----/ )
+            {
+                $Message->[ $i + 1 ] = [ splice @$Message, $i + 1 ]
+                    if $Message->[ $i + 1 ];
             }
-            $para .= ( defined $stanza->{raw} ? $stanza->{raw} : '') ."\n";
+            $para .= ( defined $stanza->{raw} ? $stanza->{raw} : '' ) . "\n";
         }
         next unless ref $stanza eq "ARRAY";
 
-        $print_content->( \$para ); $para = '';
+        $print_content->( \$para );
+        $para = '';
 
         $Depth++;
-        push @stack, [$Message, $i+1];
-        ($Message, $i) = ($stanza, -1);
+        push @stack, [ $Message, $i + 1 ];
+        ( $Message, $i ) = ( $stanza, -1 );
 
-        $m->comp('FoldStanzaJS', Depth => $Depth);
+        if ( $Depth == 1 ) {
+            $m->comp('FoldStanzaJS');
+        }
+        $m->out(   '<div class="message-stanza"'
+                 . ( $Depth == 1 ? ' style="display: none;" ' : '' )
+                 . '>' );
     }
     if ( length $para ) {
-        $print_content->( \$para ); $para = '';
+        $print_content->( \$para );
+        $para = '';
     }
 
-    if ( @stack ) {
-        ($Message, $i) = @{ pop @stack };
+    if (@stack) {
+        ( $Message, $i ) = @{ pop @stack };
         $Depth--;
         $m->out('</div>');
         goto AGAIN;
     }
 
     $m->out('</div>');
-    $m->out('</pre>') if $plain_text_pre && !$Depth && !$plain_text_mono;
+    $m->out('</pre>')
+        if (    $ContentType eq 'text/plain'
+             && $plain_text_pre
+             && !$Depth
+             && !$plain_text_mono );
 } else {
-      $print_content->( \$Message );
+    $print_content->( \$Message );
 }
 </%INIT>
 <%ARGS>
 $Message => undef
-$Depth => 0
 $Transaction => undef
+$ContentType => 'text/plain'
 </%ARGS>
diff --git a/share/html/Ticket/Elements/ShowTransactionAttachments b/share/html/Ticket/Elements/ShowTransactionAttachments
index 3c084f9..a2f5c61 100644
--- a/share/html/Ticket/Elements/ShowTransactionAttachments
+++ b/share/html/Ticket/Elements/ShowTransactionAttachments
@@ -216,10 +216,10 @@ my $render_attachment = sub {
                 $content = HTML::Quoted->extract( $content );
 
                 $m->comp(
-                    'ShowHTMLMessageStanza',
-                    Depth       => 0,
+                    'ShowMessageStanza',
                     Message     => $content,
-                    Transaction => $Transaction
+                    Transaction => $Transaction,
+                    ContentType => 'text/html'
                 );
             }
 
@@ -236,9 +236,9 @@ my $render_attachment = sub {
 
                 $m->comp(
                     'ShowMessageStanza',
-                    Depth       => 0,
                     Message     => $content,
-                    Transaction => $Transaction
+                    Transaction => $Transaction,
+                    ContentType => 'text/plain'
                 );
             }
         }

commit ef58923f8d438c61ee6a791b66bd503f52ab150b
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Wed Nov 24 15:51:29 2010 -0500

    Clean up newlines right around stanza breaks

diff --git a/share/html/NoAuth/css/aileron/ticket.css b/share/html/NoAuth/css/aileron/ticket.css
index 46e53f0..4678129 100644
--- a/share/html/NoAuth/css/aileron/ticket.css
+++ b/share/html/NoAuth/css/aileron/ticket.css
@@ -114,14 +114,9 @@ div#ticket-history span.time-taken {
 div#ticket-history div.content {
  padding-right: 1em;
  padding-bottom: 0.7em;
- font-size: 1.1em;
  margin-left: 1.5em;
 }
 
-.plain-text-white-space {
- white-space: pre-wrap;
- font-family: monospace;
-}
 
 .ticket-transaction .messagebody {
  font-size: 1em;
diff --git a/share/html/NoAuth/css/ballard/ticket.css b/share/html/NoAuth/css/ballard/ticket.css
index abd93e3..06cb487 100644
--- a/share/html/NoAuth/css/ballard/ticket.css
+++ b/share/html/NoAuth/css/ballard/ticket.css
@@ -114,15 +114,9 @@ div#ticket-history span.time-taken {
 div#ticket-history div.content {
  padding-right: 1em;
  padding-bottom: 0.7em;
- font-size: 1.1em;
  margin-left: 1.5em;
 }
 
-.plain-text-white-space {
- white-space: pre-wrap;
- font-family: monospace;
-}
-
 .ticket-transaction .messagebody {
  font-size: 1em;
  padding-left: 1em;
diff --git a/share/html/NoAuth/css/base/ticket.css b/share/html/NoAuth/css/base/ticket.css
index ec9bf35..714ded5 100644
--- a/share/html/NoAuth/css/base/ticket.css
+++ b/share/html/NoAuth/css/base/ticket.css
@@ -132,3 +132,15 @@
 .more-about-requestor-tickets .ui-tabs-panel a {
     color: black !important;
 }
+
+
+.plain-text-white-space {
+ white-space: pre-wrap;
+ font-family: monospace;
+}
+
+.plain-text-white-space br {
+    display: none;
+}
+
+
diff --git a/share/html/NoAuth/css/web2/ticket.css b/share/html/NoAuth/css/web2/ticket.css
index abd93e3..06cb487 100644
--- a/share/html/NoAuth/css/web2/ticket.css
+++ b/share/html/NoAuth/css/web2/ticket.css
@@ -114,15 +114,9 @@ div#ticket-history span.time-taken {
 div#ticket-history div.content {
  padding-right: 1em;
  padding-bottom: 0.7em;
- font-size: 1.1em;
  margin-left: 1.5em;
 }
 
-.plain-text-white-space {
- white-space: pre-wrap;
- font-family: monospace;
-}
-
 .ticket-transaction .messagebody {
  font-size: 1em;
  padding-left: 1em;
diff --git a/share/html/Ticket/Elements/ShowMessageStanza b/share/html/Ticket/Elements/ShowMessageStanza
index c494019..e17db1d 100755
--- a/share/html/Ticket/Elements/ShowMessageStanza
+++ b/share/html/Ticket/Elements/ShowMessageStanza
@@ -65,12 +65,18 @@ my $print_content = sub {
                   ticket  => $ticket,
                   %ARGS
                 );
-        unless ( $plain_text_pre || $plain_text_mono ) {
-            $$ref =~ s{(\r?\n)}{<br />}g if defined $$ref;
+
+        if ( defined $$ref && !$plain_text_pre && !$plain_text_mono ) {
+            $$ref =~ s{(\r?\n)}{<br />}g;
+        }
+    } else {
+        if ( defined $$ref ) {
+            $$ref =~ s/^[\r\n]+//g;
         }
     }
     $m->out($$ref);
 };
+
 if ( ref $Message ) {
     $m->out('<pre>')
         if (    $ContentType eq 'text/plain'
@@ -94,7 +100,7 @@ AGAIN: foreach ( ; $i < @$Message; $i++ ) {
                 $Message->[ $i + 1 ] = [ splice @$Message, $i + 1 ]
                     if $Message->[ $i + 1 ];
             }
-            $para .= ( defined $stanza->{raw} ? $stanza->{raw} : '' ) . "\n";
+            $para .= ( defined $stanza->{raw} ? $stanza->{raw} : '' );
         }
         next unless ref $stanza eq "ARRAY";
 

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


More information about the Rt-commit mailing list