<commit_before>xml.instruct! :xml, :version => '1.0', :encoding => 'UTF-8'

xml.urlset  :xmlns => 'http://www.sitemaps.org/schemas/sitemap/0.9',
            'xmlns:xhtml' => "http://www.w3.org/1999/xhtml" do
  @cms_site.pages.published.each do |site_page|
    ([site_page] + site_page.mirrors).each do |page|
      next unless page.is_published?
      xml.url do
        xml.loc ['http://', page.site.hostname, page_path(page)].join
        tree_priority = [1 - (0.1 * ( ( [page.full_path.split("/").count, 1].max - 1 ) ) ), 0.1].max
        revs = page.revisions.size
        priority_modifier = case page.revisions.size
                          when 0
                            -0.2
                          when 1,2,3
                            -0.1
                          when 3,4,5,6,7,8
                            0
                          else
                            0.1
                        end
        priority = (tree_priority + priority_modifier).round(1)
        priority = 1.0 if priority > 1.0
        xml.priority priority
        xml.lastmod page.updated_at.strftime('%Y-%m-%d')

        # render xhtml alternate links to mirror pages
        page.mirrors.each do |mirror_page|
          next unless mirror_page.is_published?
          xml.tag!('xhtml:link', {
              :rel => 'alternate',
              :hreflang => mirror_page.site.locale.to_s,
              :href => ['http://', mirror_page.site.hostname, page_path(mirror_page)].join
          })
        end
      end
    end
  end
end<commit_msg>add alternate link to self to fufill multilingual sitemap specifications<commit_after>xml.instruct! :xml, :version => '1.0', :encoding => 'UTF-8'

xml.urlset  :xmlns => 'http://www.sitemaps.org/schemas/sitemap/0.9',
            'xmlns:xhtml' => "http://www.w3.org/1999/xhtml" do
  @cms_site.pages.published.each do |site_page|
    ([site_page] + site_page.mirrors).each do |page|
      next unless page.is_published?
      xml.url do
        xml.loc ['http://', page.site.hostname, page_path(page)].join
        tree_priority = [1 - (0.1 * ( ( [page.full_path.split("/").count, 1].max - 1 ) ) ), 0.1].max
        priority_modifier = case page.revisions.size
                          when 0
                            -0.2
                          when 1,2,3
                            -0.1
                          when 3,4,5,6,7,8
                            0
                          else
                            0.1
                        end
        priority = (tree_priority + priority_modifier).round(1)
        priority = 1.0 if priority > 1.0
        xml.priority priority
        xml.lastmod page.updated_at.strftime('%Y-%m-%d')

        unless page.mirrors.empty?
          # render xhtml alternate links to mirror pages
          ([page] + page.mirrors).each do |mirror_page|
            next unless mirror_page.is_published?
            xml.tag!('xhtml:link', {
                :rel => 'alternate',
                :hreflang => mirror_page.site.locale.to_s,
                :href => ['http://', mirror_page.site.hostname, page_path(mirror_page)].join
            })
          end
        end

      end
    end
  end
end
{'fraction_non_alphanumeric': 0.12707875745214936, 'fraction_numerical': 0.02447442736115469, 'mean_word_length': 1.4466615502686109, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 20}, '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': '363916', 'n_tokens_mistral': 1015, 'n_tokens_neox': 964, 'n_words': 192}