<commit_before>package EnsEMBL::Web::Tools::OpenSearchDescription;

use strict;

sub create {
  ### This is to try and stop search engines killing e! - it gets created each
  ### time on server startup and gets placed in the first directory in the htdocs
  ### tree.
  ### Returns: none
  my $sd = shift;
  my $root = $SiteDefs::ENSEMBL_HTDOCS_DIRS[0];
  my $template = sprintf '<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription
      xmlns="http://a9.com/-/spec/opensearch/1.1/">
 <ShortName>%s (%%s)</ShortName>
 <Description>Search %s - %%s</Description>
 <InputEncoding>UTF-8</InputEncoding>
 <Tags>Ensembl genome browser %s %%s</Tags>
 <Image width="16" height="16" type="image/png">%s%%s</Image>
 <Url type="text/html"
      template="%s/%%s/psychic?q={searchTerms};site=%%s"/>
</OpenSearchDescription>
', 
  $sd->ENSEMBL_SITE_NAME_SHORT,
  $sd->ENSEMBL_SITE_NAME,
  $sd->ENSEMBL_SITE_NAME,
  $sd->ENSEMBL_BASE_URL.$sd->ENSEMBL_IMAGE_ROOT,
  $sd->ENSEMBL_BASE_URL;

  open O,">$root/opensearchdescription.xml";
  printf O $template, 'All', 'All species', 'All species', $sd->ENSEMBL_STYLE->{'SITE_ICON'}, 'common', 'ensembl_all';
  close O;
  foreach( @{$sd->ENSEMBL_SPECIES} ) {
    my $sn = substr( $sd->other_species($_,'SPECIES_BIO_SHORT'),0,5);
    my $cn = $sd->other_species($_,'SPECIES_COMMON_NAME');
    my $bn = $sd->other_species($_,'SPECIES_BIO_NAME');
    open O,">$root/opensearch_$_.xml";
    printf O $template, $sn, "$cn - $bn", "$cn $bn", $sd->ENSEMBL_STYLE->{'SITE_ICON'}, $_, 'ensembl';
    close O;
  }
}

1;<commit_msg>moved opensearch to write to subdirectory<commit_after>package EnsEMBL::Web::Tools::OpenSearchDescription;

use strict;

sub create {
  ### This is to try and stop search engines killing e! - it gets created each
  ### time on server startup and gets placed in the first directory in the htdocs
  ### tree.
  ### Returns: none
  my $sd = shift;
  my $root = $SiteDefs::ENSEMBL_HTDOCS_DIRS[0];
  my $template = sprintf '<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription
      xmlns="http://a9.com/-/spec/opensearch/1.1/">
 <ShortName>%s (%%s)</ShortName>
 <Description>Search %s - %%s</Description>
 <InputEncoding>UTF-8</InputEncoding>
 <Tags>Ensembl genome browser %s %%s</Tags>
 <Image width="16" height="16" type="image/png">%s%%s</Image>
 <Url type="text/html"
      template="%s/%%s/psychic?q={searchTerms};site=%%s"/>
</OpenSearchDescription>
', 
  $sd->ENSEMBL_SITE_NAME_SHORT,
  $sd->ENSEMBL_SITE_NAME,
  $sd->ENSEMBL_SITE_NAME,
  $sd->ENSEMBL_BASE_URL.$sd->ENSEMBL_IMAGE_ROOT,
  $sd->ENSEMBL_BASE_URL;

  unless( -e "$root/opensearch" ) {
    mkdir "$root/opensearch";
  }
  open O,">$root/opensearch/all.xml";
  printf O $template, 'All', 'All species', 'All species', $sd->ENSEMBL_STYLE->{'SITE_ICON'}, 'common', 'ensembl_all';
  close O;
  foreach( @{$sd->ENSEMBL_SPECIES} ) {
    my $sn = substr( $sd->other_species($_,'SPECIES_BIO_SHORT'),0,5);
    my $cn = $sd->other_species($_,'SPECIES_COMMON_NAME');
    my $bn = $sd->other_species($_,'SPECIES_BIO_NAME');
    open O,">$root/opensearch/$_.xml";
    printf O $template, $sn, "$cn - $bn", "$cn $bn", $sd->ENSEMBL_STYLE->{'SITE_ICON'}, $_, 'ensembl';
    close O;
  }
}

1;
{'fraction_non_alphanumeric': 0.19258335930196324, 'fraction_numerical': 0.009348706762231224, 'mean_word_length': 4.783783783783784, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 2, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '248906', 'n_tokens_mistral': 1271, 'n_tokens_neox': 1220, 'n_words': 243}