<commit_before>module SeitenHelper

  # TODO: Move logic into Seiten::PageLink class
  def link_to_seiten_page(title, slug, options={})
    if !!(slug.to_s.match(/^https?:\/\/.+/))
      link_to title, slug
    else
      link_to title, seiten_page_path(page: slug)
    end
  end

  # TODO: Move logic into Seiten::Navigation class
  def seiten_navigation(*nav)
    options = nav.extract_options!

    navigation = nav.first || current_navigation

    output  ||= ""
    parent_id = options[:parent_id] || nil
    deep      = options[:deep] || 2

    if deep > 0
      navigation.pages.where(parent_id: parent_id).each do |page|
        status = page.active?(current_page) ? "active" : "inactive"
        output += "<li class='#{status}'>#{link_to_seiten_page(page.title, page.slug)}"
        unless page.children.blank?
          output += seiten_navigation(navigation, parent_id: page.id, deep: deep-1)
        end
        output += "</li>"
      end
      output = "<ul>#{output}</ul>"
    end
    raw output
  end

  # TODO: Move logic into Seiten::Breadcrumb class
  def seiten_breadcrumb(options={})
    link_separator = options[:link_separator] || ">"

    if current_page
      output = content_tag(:ul, class: "breadcrumb") do
        Seiten::BreadcrumbBuilder.call(current_page).reverse.collect { |page|
          content_tag :li do
            raw "#{link_separator} #{link_to_seiten_page(page.title, page.slug)}"
          end
        }.join().html_safe
      end
      output
    end
  end
end
<commit_msg>use url_for instead of named route and add expanded and current classes to navigation helper<commit_after>module SeitenHelper

  # TODO: Move logic into Seiten::PageLink class
  def link_to_seiten_page(title, slug, options={})
    if !!(slug.to_s.match(/^https?:\/\/.+/))
      link_to title, slug
    else
      link_to title, url_for(page: slug)
    end
  end

  # TODO: Move logic into Seiten::Navigation class
  def seiten_navigation(*nav)
    options = nav.extract_options!

    navigation = nav.first || current_navigation

    output  ||= ""
    parent_id = options[:parent_id] || nil
    deep      = options[:deep] || 2

    if deep > 0
      navigation.pages.where(parent_id: parent_id).each do |page|
        output += "<li class='#{seiten_navigation_page_class(page)}'>#{link_to_seiten_page(page.title, page.slug)}"
        unless page.children.blank?
          output += seiten_navigation(navigation, parent_id: page.id, deep: deep-1)
        end
        output += "</li>"
      end
      output = "<ul>#{output}</ul>"
    end
    raw output
  end

  # TODO: Move logic into Seiten::Breadcrumb class
  def seiten_breadcrumb(options={})
    link_separator = options[:link_separator] || ">"

    if current_page
      output = content_tag(:ul, class: "breadcrumb") do
        Seiten::BreadcrumbBuilder.call(current_page).reverse.collect { |page|
          content_tag :li do
            raw "#{link_separator} #{link_to_seiten_page(page.title, page.slug)}"
          end
        }.join().html_safe
      end
      output
    end
  end

  def seiten_navigation_page_class(page)
    classes = ""
    if page.active?(current_page)
      classes << ' active'
      classes << (page == current_page ? ' current' : ' expanded')
    else
      classes << ' inactive'
    end
    classes.strip
  end
end

{'fraction_non_alphanumeric': 0.12360902255639097, 'fraction_numerical': 0.0018045112781954887, 'mean_word_length': 2.8229885057471265, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, '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': '897129', 'n_tokens_mistral': 1072, 'n_tokens_neox': 1049, 'n_words': 248}