[Rt-commit] rt branch, 3.8-plain-text-mono, updated. 3cac06ebddc41e2eb82698ea1252b2c354b7557e

sunnavy at bestpractical.com sunnavy at bestpractical.com
Thu Sep 10 11:19:31 EDT 2009


The branch, 3.8-plain-text-mono has been updated
       via  3cac06ebddc41e2eb82698ea1252b2c354b7557e (commit)
      from  084a6d3a87c06e9ec75ff642ac15568cacd41f73 (commit)

Summary of changes:
 etc/RT_Config.pm.in                                |   29 ++++++++++++++++++++
 lib/RT/Config.pm                                   |   11 +++++++
 share/html/NoAuth/css/web2/ticket.css              |    4 +++
 share/html/Ticket/Elements/ShowMessageStanza       |    7 +++--
 .../Ticket/Elements/ShowTransactionAttachments     |    2 +-
 5 files changed, 49 insertions(+), 4 deletions(-)

- Log -----------------------------------------------------------------
commit 3cac06ebddc41e2eb82698ea1252b2c354b7557e
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Sep 10 23:15:46 2009 +0800

    add PlainTextWhiteSpace option

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 1bfd0dc..c226908 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1131,6 +1131,7 @@ use a monospaced font, no matter what the value of C<$PlainTextMono> is.
 
 Set($PlainTextPre, 0);
 
+
 =item C<$PlainTextMono>
 
 To display plaintext attachments,
@@ -1140,6 +1141,34 @@ Set C<$PlainTextMono> to 1 to use monospaced font,  0 to not to.
 
 Set($PlainTextMono, 0);
 
+=item C<$PlainTextWhiteSpace>
+
+Decorate plain text displays by white-space css property.
+Possible values are: 
+
+normal:
+    Sequences of whitespace will collapse into a single whitespace.
+    Text will wrap when necessary.
+nowrap:
+    Sequences of whitespace will collapse into a single whitespace.
+    Text will never wrap to the next line.
+    The text continues on the same line until a <br /> tag is encountered
+pre:
+    Whitespace is preserved by the browser.
+    Text will only wrap on line breaks Acts like the <pre> tag in HTML
+pre-line:
+    Sequences of whitespace will collapse into a single whitespace.
+    Text will wrap when necessary, and on line breaks
+pre-wrap:
+    Whitespace is preserved by the browser.
+    Text will wrap when necessary, and on line breaks 
+
+Set value to '' to not use this.
+
+=cut
+
+Set($PlainTextWhiteSpace, '');
+
 
 =item C<$ShowUnreadMessageNotifications>
 
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 9bd118c..baa1ee4 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -312,6 +312,17 @@ our %META = (
             Description => 'Use monospaced font to display plain text attachments', #loc
         },
     },
+    PlainTextWhiteSpace => {
+        Section         => 'Ticket display',
+        Overridable     => 1,
+        SortOrder       => 4,
+        Widget          => '/Widgets/Form/Select',
+        WidgetArguments => {
+            Description => 'CSS rule white-space',    #loc
+            Values => [ 'normal', 'nowrap', 'pre', 'pre-line', 'pre-wrap', '' ]
+              Hints => "ie6 doesn't support white-space well, so don't use this if you use ie6"    #loc
+        },
+    },
 
     # User overridable locale options
     DateTimeFormat => {
diff --git a/share/html/NoAuth/css/web2/ticket.css b/share/html/NoAuth/css/web2/ticket.css
index f47c3ec..3ea6be6 100644
--- a/share/html/NoAuth/css/web2/ticket.css
+++ b/share/html/NoAuth/css/web2/ticket.css
@@ -122,6 +122,10 @@ div.mono {
  font-family: monospace;
 }
 
+.plain-text-white-space {
+ white-space: <%RT->Config->Get('PlainTextWhiteSpace', $RT::CurrentUser)%>;
+}
+
 .ticket-transaction .messagebody {
  font-size: 1em;
  padding-left: 1em;
diff --git a/share/html/Ticket/Elements/ShowMessageStanza b/share/html/Ticket/Elements/ShowMessageStanza
index 6adee1c..6132423 100755
--- a/share/html/Ticket/Elements/ShowMessageStanza
+++ b/share/html/Ticket/Elements/ShowMessageStanza
@@ -47,7 +47,7 @@
 %# END BPS TAGGED BLOCK }}}
 <%perl>
 if ( ref $Message ) {
-    $m->out('<pre>') if $plain_text_pre && !$Depth;
+    $m->out('<pre>') if $plain_text_pre && !$Depth && !$plain_text_white_space;
     $m->out( qq{<div class="message-stanza-depth-$Depth">} );
 
     my @stack;
@@ -80,13 +80,14 @@ if ( ref $Message ) {
     }
 
     $m->out('</div>');
-    $m->out('</pre>') if $plain_text_pre && !$Depth;
+    $m->out('</pre>') if $plain_text_pre && !$Depth && !$plain_text_white_space;
 } else {
       $print_content->( \$Message );
 }
 </%perl>
 <%INIT>
 my $plain_text_pre = RT->Config->Get('PlainTextPre', $session{'CurrentUser'});
+my $plain_text_white_space = RT->Config->Get('PlainTextWhiteSpace', $session{'CurrentUser'});
 
 my $ticket = $Transaction ? $Transaction->TicketObj : undef;
 
@@ -96,7 +97,7 @@ my $print_content = sub {
 
     $m->callback( content => $ref, %ARGS );
     $m->comp('/Elements/MakeClicky', content => $ref, ticket => $ticket, %ARGS);
-    unless ( $plain_text_pre ) {
+    unless ( $plain_text_pre || $plain_text_white_space ) {
         $$ref =~ s{(?=\r*\n)}{<br />}g if defined $$ref;
     }
     $m->out( $$ref );
diff --git a/share/html/Ticket/Elements/ShowTransactionAttachments b/share/html/Ticket/Elements/ShowTransactionAttachments
index fe77b08..07b6453 100644
--- a/share/html/Ticket/Elements/ShowTransactionAttachments
+++ b/share/html/Ticket/Elements/ShowTransactionAttachments
@@ -76,7 +76,7 @@ foreach my $message ( grep $_->__Value('Parent') == $Parent, @$Attachments ) {
 % if ( scalar ( grep $_->__Value('Parent') == $message->id, @$Attachments ) ) {
 <div class="messageattachments">
 % } else {
-<div class="messagebody<% RT->Config->Get('PlainTextMono', $session{'CurrentUser'}) ? ' mono' : ''%>">
+<div class="messagebody<% RT->Config->Get('PlainTextMono', $session{'CurrentUser'}) ? ' mono' : ''%><% RT->Config->Get('PlainTextWhiteSpace', $session{'CurrentUser'}) ? ' plain-text-white-space' : ''%>">
 % }
 <%PERL>
 

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


More information about the Rt-commit mailing list