[Bps-public-commit] rt-extension-announce branch, support-html-content-as-banner, repushed

Craig Kaiser craig at bestpractical.com
Wed Sep 4 17:24:13 EDT 2019


The branch support-html-content-as-banner was deleted and repushed:
       was f9d3cd0f0627a933dfd8460861a0d46b122dd0e7
       now 715ec751154fbafd215132e940b21e37dd17662f

1:  345ed41 = 1:  345ed41 Update Module::Install
2:  ee93d11 = 2:  ee93d11 Add configuration variable to allow HTML content as announce banner
3:  f9d3cd0 ! 3:  5741ee8 Allow the number of lines displayed in the RT announce banner to be configured
    @@ -56,40 +56,47 @@
     +
     +  my @lines;
     +  if ( $show_html ) {
    -+    for my $line ( split("\n", $dom->all_text ) ) {
    ++    for my $line ( $dom->find('*')->map('text')->each ) {
     +      # We do not care about strings with only white space
     +      next unless $line =~ /\S/;
     +
     +      # Find the HTML element matching our text, not just the text component
    -+      my $match = $dom->find('*')->grep(sub { $_->all_text =~ /$line/ })->first;
    -+      next unless $match;
    ++      my $matches = $dom->find('*')->grep(sub { $_->all_text =~ /$line/ });
    ++      unless ( $matches->size ) {
    ++        RT::Logger->error("Could not find HTML component matching text content: $line");
    ++        next;
    ++      }
    ++      foreach my $match ( $matches->each ) {
    ++        # We do not want to grab any parent elements
    ++        next if $match->children->size;
    ++        push @lines, $match->to_string;
     +
    -+      # We want the HTML string from the component not just the parsed text content
    -+      push @lines, $match->to_string;
    -+
    -+      # Remove this content from our DOM object in case there are duplicate text components
    -+      $dom = $match->strip;
    ++        # Remove the current node so that we do not end up with duplicates
    ++        $dom = $match->remove->root;
    ++        # No need to continue looking for matching elements
    ++        last;
    ++      }
     +    }
     +  } else {
     +    # Split just on line breaks
     +    @lines = split ( "\n", $content );
     +  }
     +  my $line_count_limit = RT::Config->Get('RTAnnounceLineCountLimit');
    -+
     +  if ( $line_count_limit && scalar @lines > $line_count_limit && $show_html ) {
    -+    my $dom_ellipsis = Mojo::DOM->new();
    ++    # This is our overflow content that will be cutoff in the scroll box
    ++    my $dom_cutoff = Mojo::DOM->new();
     +
     +    my $count = 0;
     +    for my $line ( @lines ) {
     +      if ( $count eq $line_count_limit ) {
     +        # Placeholder element to be replaced with overflow CSS div
    -+        $dom_ellipsis = $dom_ellipsis->append_content( '<p id="RTAnnounceOverflowStart">' );
    ++        $dom_cutoff = $dom_cutoff->append_content( '<p id="RTAnnounceOverflowStart">' );
     +      }
    -+      $dom_ellipsis = $dom_ellipsis->append_content( $line );
    ++      $dom_cutoff = $dom_cutoff->append_content( $line );
     +      $count = $count + 1;
     +    }
     +    # Wrap our content in a scrollable div since we have more lines than we want to display
    -+    $content = $dom_ellipsis->content;
    ++    $content = $dom_cutoff->content;
     +
     +    # Replace our placeholder element with the overflow div
     +    $content =~ s/\<p id="RTAnnounceOverflowStart"\>\<\/p\>/\<div class="RTAnnounceBannerOverflow overflow-ellipsis"\>/;
    @@ -142,3 +149,4 @@
     +.RTAnnounceScrollable {
     +  overflow: auto;
     +}
    +
-:  ------- > 4:  b9a8631 Add "AdvancedMode" config option to manually set banner overflow"
-:  ------- > 5:  715ec75 Hide banner scrollbar



More information about the Bps-public-commit mailing list