[Rt-commit] rt branch 5.0/article-html-content created. rt-5.0.2-86-g65142d1da9

BPS Git Server git at git.bestpractical.com
Fri Feb 25 19:04:15 UTC 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/article-html-content has been created
        at  65142d1da912a09de8a009df1252a12064e5e2e3 (commit)

- Log -----------------------------------------------------------------
commit 65142d1da912a09de8a009df1252a12064e5e2e3
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat Feb 26 02:13:29 2022 +0800

    Add extra newlines to make boundaries of different article fields clear
    
    Previously if article name, summary, custom field Content and Extra Note
    are selected, it would be rendered like:
    
        #1: name
        --------
        this is summary
        Content:
        -------
        this is content
        Extra Note:
        ----------
        this is extra content
    
    This commit tweaks it to be:
    
        #1: name
        --------
        this is summary
    
        Content:
        --------
        this is content
    
        Extra Note:
        ----------
        this is extra content
    
    which is less confusing.

diff --git a/share/html/Articles/Article/Elements/Preformatted b/share/html/Articles/Article/Elements/Preformatted
index f48ea4f89e..8dddf591f3 100644
--- a/share/html/Articles/Article/Elements/Preformatted
+++ b/share/html/Articles/Article/Elements/Preformatted
@@ -50,7 +50,7 @@
 <%'-' x length("#".$Article->Id.": ".($Article->Name || loc('(no name)'))) %><% $newline |n %>\
 % }
 % if ( $include{Summary} && ($Article->Summary||'') =~ /\S/ ) {
-<% $Article->Summary %><% $newline |n %>\
+<% $Article->Summary %><% $newline |n %><% $newline |n %>\
 % }
 % while (my $cf = $cfs->Next) {
 %   next unless $include{"CF-Title-".$cf->Id} or $include{"CF-Value-".$cf->Id};
@@ -83,6 +83,7 @@
 %       }
 %     } 
 %   }
+<%  $newline |n %>\
 % }
 <%init>
 my $class = $Article->ClassObj;
diff --git a/t/web/ticket-create-utf8.t b/t/web/ticket-create-utf8.t
index 09051c194d..caf2827e0b 100644
--- a/t/web/ticket-create-utf8.t
+++ b/t/web/ticket-create-utf8.t
@@ -81,6 +81,6 @@ ok( $ret, $msg );
 
 ok $m->login(root => 'password'), "logged in";
 $m->goto_create_ticket('General');
-$m->scraped_id_is('Content', '#1: My Article<br />--------------<br />Content:<br />-------<br />My Article Test Content<br />');
+$m->scraped_id_is('Content', '#1: My Article<br />--------------<br />Content:<br />-------<br />My Article Test Content<br /><br />');
 
 done_testing;

commit d295ce61330ebe5c9b48451b5801edcd31d8f35f
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Feb 25 23:36:14 2022 +0800

    Format article HTML content correctly when EscapeHTML is disabled
    
    Articles can be inserted into tickets on ticket create/update. When
    multiple articles fields are selected(e.g. name, summary and various
    custom fields), previously these fields were separated using plain
    newlines("\n"), which is not correct for HTML(all fields would be put in
    the same row).
    
    As continuous whitespaces are treated as a single one in HTML, we need
    to use " " instead.

diff --git a/share/html/Articles/Article/Elements/Preformatted b/share/html/Articles/Article/Elements/Preformatted
index 8166ca5652..f48ea4f89e 100644
--- a/share/html/Articles/Article/Elements/Preformatted
+++ b/share/html/Articles/Article/Elements/Preformatted
@@ -46,11 +46,11 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 % if ($include{Name}) {
-#<%$Article->Id%>: <%$Article->Name || loc('(no name)')%>
-<%'-' x length("#".$Article->Id.": ".($Article->Name || loc('(no name)'))) %>
+#<%$Article->Id%>: <%$Article->Name || loc('(no name)')%><% $newline |n %>\
+<%'-' x length("#".$Article->Id.": ".($Article->Name || loc('(no name)'))) %><% $newline |n %>\
 % }
 % if ( $include{Summary} && ($Article->Summary||'') =~ /\S/ ) {
-<% $Article->Summary %>
+<% $Article->Summary %><% $newline |n %>\
 % }
 % while (my $cf = $cfs->Next) {
 %   next unless $include{"CF-Title-".$cf->Id} or $include{"CF-Value-".$cf->Id};
@@ -58,26 +58,28 @@
 %   if ($values->Count == 1) {
 %     my $value = $values->First; 
 %     if ($include{"CF-Title-".$cf->Id}) {
-<%      $cf->Name%>:
-<%      '-' x length($cf->Name) %>
+<%      $cf->Name%>:<% $newline |n %>\
+<%      '-' x length($cf->Name) %><% $newline |n %>\
 %     }
 %     if ($value && $include{"CF-Value-".$cf->Id}) {
-<%      $get_content->( $value ) %>
+<%      $get_content->( $value ) %>\
 %     }
+<%    $newline |n %>\
 %   } else {
 %     my $val = $values->Next;
 %     if ($include{"CF-Title-".$cf->Id}) {
 <%      $cf->Name%>: \
 %     }
 %     if ($val && $include{"CF-Value-".$cf->Id}) {
-<%      $get_content->( $val ) %>
+<%      $get_content->( $val ) %>\
 %     }
+<%    $newline |n %>\
 %     while ($val = $values->Next) { 
 %       if ($include{"CF-Title-".$cf->Id}) {
-<%        ' ' x length($cf->Name)%>  \
+<%        $space x length($cf->Name) |n %>  \
 %       }
 %       if ($include{"CF-Value-".$cf->Id}) {
-<%        $get_content->( $val ) %>
+<%        $get_content->( $val ) %><% $newline |n %>\
 %       }
 %     } 
 %   }
@@ -113,6 +115,10 @@ my $get_content = sub {
     return $content;
 };
 
+# Use HTML version of newline and space if possible, to not collapse content.
+my $richtext = RT->Config->Get( 'MessageBoxRichText', $session{'CurrentUser'} ) ? 1        : 0;
+my $newline  = $richtext && !$include{'EscapeHTML'}                             ? '<br />' : "\n";
+my $space    = $richtext && !$include{'EscapeHTML'}                             ? ' ' : ' ';
 </%init>
 <%args>
 $Article
diff --git a/t/web/ticket-create-utf8.t b/t/web/ticket-create-utf8.t
index e1ce7ed0ee..09051c194d 100644
--- a/t/web/ticket-create-utf8.t
+++ b/t/web/ticket-create-utf8.t
@@ -81,6 +81,6 @@ ok( $ret, $msg );
 
 ok $m->login(root => 'password'), "logged in";
 $m->goto_create_ticket('General');
-$m->scraped_id_is('Content', '#1: My Article <br />-------------- <br />Content: <br />------- <br />My Article Test Content <br />');
+$m->scraped_id_is('Content', '#1: My Article<br />--------------<br />Content:<br />-------<br />My Article Test Content<br />');
 
 done_testing;

commit d452d4be019e0a4ec756afb51b8beb5a478732cc
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Feb 25 05:24:00 2022 +0800

    Use HTML content for articles by default
    
    Since it's the default behavior and content is scrubbed, remove the
    paranoid "potentially unsafe" warning.

diff --git a/docs/UPGRADING-5.0 b/docs/UPGRADING-5.0
index fbe8e017c0..1a91064273 100644
--- a/docs/UPGRADING-5.0
+++ b/docs/UPGRADING-5.0
@@ -438,4 +438,16 @@ it will order by EmailAddress.
 
 =back
 
+=head1 UPGRADING FROM 5.0.2 AND EARLIER
+
+=over 4
+
+=item *
+
+RT now supports C<HTML> type for custom fields, so if you have custom fields
+containing C<HTML>(e.g. C<Content> for articles), you can switch type to
+C<HTML> to use CKEditor for editing.
+
+=back
+
 =cut
diff --git a/etc/initialdata b/etc/initialdata
index b7daaf4239..35aad1df89 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -932,6 +932,12 @@ Hour:         { $SubscriptionObj->SubValue('Hour') }
     {
         Name              => 'General',
         Description       => 'The default class',
+        Attributes        => [
+            {
+                Name    => 'Skip-EscapeHTML',
+                Content => 1,
+            },
+        ],
     },
 );
 
@@ -940,7 +946,7 @@ Hour:         { $SubscriptionObj->SubValue('Hour') }
         Name              => 'Content',
         Description       => 'Content',
         LookupType        => 'RT::Class-RT::Article',
-        Type              => 'Text',
+        Type              => 'HTML',
         MaxValues         => 1,
     },
 );
diff --git a/share/html/Admin/Articles/Classes/Modify.html b/share/html/Admin/Articles/Classes/Modify.html
index 75956e5f06..a5eab03678 100644
--- a/share/html/Admin/Articles/Classes/Modify.html
+++ b/share/html/Admin/Articles/Classes/Modify.html
@@ -137,7 +137,7 @@
     <div class="value col-9">
       <div class="custom-control custom-checkbox">
         <input type="checkbox" class="custom-control-input checkbox" id="Include-EscapeHTML" name="Include-EscapeHTML" value="1" <% $include{EscapeHTML} %>>
-        <label class="custom-control-label" for="Include-EscapeHTML"><&|/l&>Escape HTML (Unchecking this box is potentially unsafe)</&></label>
+        <label class="custom-control-label" for="Include-EscapeHTML"><&|/l&>Escape HTML</&></label>
       </div>
     </div>
   </div>
@@ -270,7 +270,7 @@ if ((defined $Enabled && $Enabled == 1) or (not defined $Enabled and $Create)) {
     $Disabled = 1;
 }
 
-my %include = (Name => 1, Summary => 1, EscapeHTML => 1);
+my %include = (Name => 1, Summary => 1, EscapeHTML => 0);
 $include{LinkToTicket} = 1 if RT->Config->Get('LinkArticlesOnInclude');
 
 my $subject_cfs = [];
diff --git a/share/html/Articles/Article/Elements/Preformatted b/share/html/Articles/Article/Elements/Preformatted
index 22eaba10a7..8166ca5652 100644
--- a/share/html/Articles/Article/Elements/Preformatted
+++ b/share/html/Articles/Article/Elements/Preformatted
@@ -84,7 +84,7 @@
 % }
 <%init>
 my $class = $Article->ClassObj;
-my %include = (Name => 1, Summary => 1, EscapeHTML => 1);
+my %include = (Name => 1, Summary => 1, EscapeHTML => 0);
 my $cfs = $class->ArticleCustomFields;
 while ( my $cf = $cfs->Next ) {
     $include{"CF-Title-" . $cf->Id} = 1;
diff --git a/t/api/initialdata-roundtrip.t b/t/api/initialdata-roundtrip.t
index e55223acc7..aa33e50541 100644
--- a/t/api/initialdata-roundtrip.t
+++ b/t/api/initialdata-roundtrip.t
@@ -923,7 +923,7 @@ my @tests = (
             my $content = RT::CustomField->new(RT->SystemUser);
             $content->LoadByCols(
                 Name => "Content",
-                Type => "Text",
+                Type => "HTML",
                 LookupType => RT::Article->CustomFieldLookupType,
             );
             ok($content->Id, "loaded builtin Content CF");
diff --git a/t/rest2/article-customfields.t b/t/rest2/article-customfields.t
index 03d90d11ea..83360d80fc 100644
--- a/t/rest2/article-customfields.t
+++ b/t/rest2/article-customfields.t
@@ -134,7 +134,7 @@ my $no_article_cf_values = bag(
                 LookupType => RT::Article->CustomFieldLookupType,
                 MaxValues  => 1,
                 Name       => 'Content',
-                Type       => 'Text',
+                Type       => 'HTML',
             }
         ),
         'single cf'

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list