<commit_before>module ViewerHelper

  def viewer_service
    @viewer_service ||= "#{current_site.title.gsub(/\ /, '')}Viewer".constantize.new(current_site)
  end

  def meta_tag(content)
    content_tag(
      :meta,
      nil,
      :name => 'description',
      :content => content
    ) unless content.blank?
  end

  def viewer_partial(name)
    render :partial => "viewer/#{current_site.slug}/#{name}"
  end

  def viewer_collection(collection, partial)
    render(
      :partial => "viewer/#{current_site.slug}/#{partial}",
      :collection => collection
    )
  end

  def viewer_main_nav(options = {})
    content_tag(:nav, :class => options[:nav_class]) do
      content_tag(:ul, :class => options[:ul_class]) do
        o = ''
        site_nav_pages.each do |page|
          path = is_home_page?(page) ? viewer_home : viewer_page(page.slug)
          active = (request.path.split('/').last == path.split('/').last)
          o += content_tag(
            :li,
            link_to(
              page.slug.gsub(/\_/, ' ').titleize,
              path,
              :class => "#{page.slug} #{'active' if active}"
            ),
            :class => page.slug
          )
        end
        o.html_safe
      end
    end
  end

  def viewer_menu(slug)
    menu = current_site.menus.find_by_slug(slug)
    if menu.nil?
      nil
    else
      content_tag(:nav) do
        content_tag(:ul) do
          o = ''
          menu.items.roots.each do |root|
            o += content_tag(:li) do
              o2 = link_to(
                root.title,
                root.page_id.blank? ? root.url : viewer_page(root.url)
              )
              nodes = root.subtree.arrange_serializable(:order => :position)
              if nodes.first["children"].size > 0
                o2 += viewer_submenu_collection(nodes.first["children"])
              end
              o2.html_safe
            end
          end
          o.html_safe
        end
      end
    end
  end

  def viewer_submenu_collection(items)
    content_tag(:ul) do
      o2 = ''
      items.each { |item| o2 += viewer_submenu_item(item) }
      o2.html_safe
    end
  end

  def viewer_submenu_item(item)
    item = OpenStruct.new(item)
    content_tag(:li) do
      o = link_to(
        item.title,
        item.page_id.blank? ? item.url : viewer_page(item.url)
      )
      if item.children.size > 0
        o += content_tag(:ul, viewer_submenu_collection(item.children))
      end
      o.html_safe
    end
  end

  def viewer_page_title(title, options = {})
    content_tag(:header, options[:header]) do
      content_tag(:h1) do
        content_tag(:span, title)
      end
    end
  end

  def viewer_image_path(filename)
    image_path "viewer/#{current_site.slug}/#{filename}"
  end

  def viewer_image(filename, options = {})
    image_tag "viewer/#{current_site.slug}/#{filename}", options
  end

  def main_header_image
    viewer_image('header.jpg')
  end

  def viewer_logo_image
    viewer_image('logo.png')
  end

  def slug_title(slug)
    slug.gsub(/\_/, ' ').humanize.titleize
  end

end
<commit_msg>add options to nav for viewer menu<commit_after>module ViewerHelper

  def viewer_service
    @viewer_service ||= "#{current_site.title.gsub(/\ /, '')}Viewer".constantize.new(current_site)
  end

  def meta_tag(content)
    content_tag(
      :meta,
      nil,
      :name => 'description',
      :content => content
    ) unless content.blank?
  end

  def viewer_partial(name)
    render :partial => "viewer/#{current_site.slug}/#{name}"
  end

  def viewer_collection(collection, partial)
    render(
      :partial => "viewer/#{current_site.slug}/#{partial}",
      :collection => collection
    )
  end

  def viewer_main_nav(options = {})
    content_tag(:nav, :class => options[:nav_class]) do
      content_tag(:ul, :class => options[:ul_class]) do
        o = ''
        site_nav_pages.each do |page|
          path = is_home_page?(page) ? viewer_home : viewer_page(page.slug)
          active = (request.path.split('/').last == path.split('/').last)
          o += content_tag(
            :li,
            link_to(
              page.slug.gsub(/\_/, ' ').titleize,
              path,
              :class => "#{page.slug} #{'active' if active}"
            ),
            :class => page.slug
          )
        end
        o.html_safe
      end
    end
  end

  def viewer_menu(slug, options = {})
    menu = current_site.menus.find_by_slug(slug)
    if menu.nil?
      nil
    else
      content_tag(:nav, options[:nav_html]) do
        content_tag(:ul) do
          o = ''
          menu.items.roots.each do |root|
            o += content_tag(:li) do
              o2 = link_to(
                root.title,
                root.page_id.blank? ? root.url : viewer_page(root.url)
              )
              nodes = root.subtree.arrange_serializable(:order => :position)
              if nodes.first["children"].size > 0
                o2 += viewer_submenu_collection(nodes.first["children"])
              end
              o2.html_safe
            end
          end
          o.html_safe
        end
      end
    end
  end

  def viewer_submenu_collection(items)
    content_tag(:ul) do
      o2 = ''
      items.each { |item| o2 += viewer_submenu_item(item) }
      o2.html_safe
    end
  end

  def viewer_submenu_item(item)
    item = OpenStruct.new(item)
    content_tag(:li) do
      o = link_to(
        item.title,
        item.page_id.blank? ? item.url : viewer_page(item.url)
      )
      if item.children.size > 0
        o += content_tag(:ul, viewer_submenu_collection(item.children))
      end
      o.html_safe
    end
  end

  def viewer_page_title(title, options = {})
    content_tag(:header, options[:header]) do
      content_tag(:h1) do
        content_tag(:span, title)
      end
    end
  end

  def viewer_image_path(filename)
    image_path "viewer/#{current_site.slug}/#{filename}"
  end

  def viewer_image(filename, options = {})
    image_tag "viewer/#{current_site.slug}/#{filename}", options
  end

  def main_header_image
    viewer_image('header.jpg')
  end

  def viewer_logo_image
    viewer_image('logo.png')
  end

  def slug_title(slug)
    slug.gsub(/\_/, ' ').humanize.titleize
  end

end

{'fraction_non_alphanumeric': 0.12337766383592373, 'fraction_numerical': 0.0028841531805800353, 'mean_word_length': 2.0433934666016578, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '490669', 'n_tokens_mistral': 2073, 'n_tokens_neox': 2030, 'n_words': 388}