<commit_before>package EnsEMBL::Web::Document::Panel::AjaxMenu;

use strict;
use Data::Dumper qw(Dumper);
use CGI qw(escapeHTML);

use base qw(EnsEMBL::Web::Document::Panel);

sub _start {
  my $self = shift;
}

sub _end   { 
  my $self = shift;
}

sub add_entry {
  my( $self, $hashref ) = @_;
  $self->{'entries'} ||= [];
  push @{$self->{'entries'}}, {
    'code'     => $hashref->{'code'}     || 'entry_'.($self->{'counter'}++),
    'type'     => $hashref->{'type'}     || '',
    'label'    => $hashref->{'label'}    || '',
    'link'     => $hashref->{'link'}     || undef,
    'priority' => $hashref->{'priority'} || 100,
    'extra'    => $hashref->{'extra'}    || {}
  };
}

sub content {
  my $self = shift;
  $self->print('
<tbody class="real">');
  $self->printf('
  <tr>
    <th class="caption" colspan="2">%s</th>
  </tr>', escapeHTML($self->{'caption'}) );
  foreach my $entry ( sort { $b->{'priority'} <=> $a->{'priority'} || $a->{'label'} cmp $b->{'label'} } @{$self->{'entries'}||[]} ) {
    my $txt = escapeHTML( $entry->{'label'} );
    if( $entry->{'link'} ) {
      $txt = sprintf( '<a href="%s"%s>%s</a>',
        escapeHTML($entry->{'link'}),
	$entry->{'extra'}{'external'} ? ' rel="external"' : '',
	$txt
      );
    }
    if( $entry->{'type'} ) {
      $self->printf( '
  <tr>
    <th>%s</th>
    <td>%s</td>
  </tr>', escapeHTML($entry->{'type'}), $txt );
    } else {
      $self->printf( '
  <tr>
    <td colspan="2">%s</td>
  </tr>', $txt );
    }
  }
  $self->print('
</tbody>');
}

sub render {
  my( $self, $first ) = @_;
  $self->content();<commit_msg>abs_url option allows no reformating at all of URLs passed to the menu<commit_after>package EnsEMBL::Web::Document::Panel::AjaxMenu;

use strict;
use Data::Dumper qw(Dumper);
use CGI qw(escapeHTML);

use base qw(EnsEMBL::Web::Document::Panel);

sub _start {
  my $self = shift;
}

sub _end   { 
  my $self = shift;
}

sub add_entry {
  my( $self, $hashref ) = @_;
  $self->{'entries'} ||= [];
  push @{$self->{'entries'}}, {
    'code'     => $hashref->{'code'}     || 'entry_'.($self->{'counter'}++),
    'type'     => $hashref->{'type'}     || '',
    'label'    => $hashref->{'label'}    || '',
    'link'     => $hashref->{'link'}     || undef,
    'priority' => $hashref->{'priority'} || 100,
    'extra'    => $hashref->{'extra'}    || {}
  };
}

sub content {
  my $self = shift;
  $self->print('
<tbody class="real">');
  $self->printf('
  <tr>
    <th class="caption" colspan="2">%s</th>
  </tr>', escapeHTML($self->{'caption'}) );
  foreach my $entry ( sort { $b->{'priority'} <=> $a->{'priority'} || $a->{'label'} cmp $b->{'label'} } @{$self->{'entries'}||[]} ) {
    my $txt = escapeHTML( $entry->{'label'} );
    if( $entry->{'link'} ) {
      if ($entry->{'extra'}{'abs_url'}) {
	$txt = $entry->{'link'};
      }
      else {
	$txt = sprintf( '<a href="%s"%s>%s</a>',
          escapeHTML($entry->{'link'}),
	  $entry->{'extra'}{'external'} ? ' rel="external"' : '',
	  $txt
        );
      }
    }
    if( $entry->{'type'} ) {
      $self->printf( '
  <tr>
    <th>%s</th>
    <td>%s</td>
  </tr>', escapeHTML($entry->{'type'}), $txt );
    } else {
      $self->printf( '
  <tr>
    <td colspan="2">%s</td>
  </tr>', $txt );
    }
  }
  $self->print('
</tbody>');
}

sub render {
  my( $self, $first ) = @_;
  $self->content();
{'fraction_non_alphanumeric': 0.2848994296007205, 'fraction_numerical': 0.003002101471029721, 'mean_word_length': 2.9525504151838673, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 109, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3129713', 'n_tokens_mistral': 1318, 'n_tokens_neox': 1312, 'n_words': 234}