<commit_before>#
# Helper methods for drawing the top navigation menus
#
# Available to all views
#
module MenuHelper

  def top_menu(label, url, options={})
    id = options.delete(:id)
    menu_heading = content_tag(:span,
      link_to_active(label.capitalize, url, options[:active]),
      :class => 'topnav'
    )
    content_tag(:li,
      [menu_heading, options[:menu_items]].combine("\n"),
      :class => ['menu', (options[:active] && 'current')].combine,
      :id => id
    )
  end

  def navbar_menu(id, label, url, options={})
    menu_heading = content_tag(:span,
      link_to_active(label, url, options[:active]),
      :class => 'navbar_item'
    )
    content_tag(:li,
      [menu_heading, options[:menu_items]].combine("\n"),
      :class => ['navbar_menu', (options[:active] && 'active')].combine,
      :id => id
    )
  end

  def menu_items(partial, locals={})
    render :partial => 'layouts/menu/'+partial, :locals => locals
  end

  ## *NEWUI
  ##
  ## MENUS
  ##
  ## use url as a path or as an array of paths, if you provide an array of paths
  ## the first item will be the destination url, the rest are used to highlight the
  ## tab if is needed
  def menu(label, url, options={})
    active = options.delete(:active) if options.has_key?(:active)
 
    ### PLEASE if you change this make sure it doesn't break menus elsewhere, for example:
    ### people directory, group directory, group pages, etc.
    if url.is_a?(String) or url.is_a?(Hash)
      active = url_for(url) =~ /#{Regexp.escape(request.path)}/i if active.nil?
    elsif url.is_a?(Array)
      active = !url.select { |path| url_for(path).match(/^#{Regexp.escape(request.path)}$/i) ? true : false }.empty? if !active
      url = url.first
    else
      active = false if active.nil?
    end<commit_msg>fixes #1701<commit_after>#
# Helper methods for drawing the top navigation menus
#
# Available to all views
#
module MenuHelper

  def top_menu(label, url, options={})
    id = options.delete(:id)
    menu_heading = content_tag(:span,
      link_to_active(label.capitalize, url, options[:active]),
      :class => 'topnav'
    )
    content_tag(:li,
      [menu_heading, options[:menu_items]].combine("\n"),
      :class => ['menu', (options[:active] && 'current')].combine,
      :id => id
    )
  end

  def navbar_menu(id, label, url, options={})
    menu_heading = content_tag(:span,
      link_to_active(label, url, options[:active]),
      :class => 'navbar_item'
    )
    content_tag(:li,
      [menu_heading, options[:menu_items]].combine("\n"),
      :class => ['navbar_menu', (options[:active] && 'active')].combine,
      :id => id
    )
  end

  def menu_items(partial, locals={})
    render :partial => 'layouts/menu/'+partial, :locals => locals
  end

  ## *NEWUI
  ##
  ## MENUS
  ##
  ## use url as a path or as an array of paths, if you provide an array of paths
  ## the first item will be the destination url, the rest are used to highlight the
  ## tab if is needed
  def menu(label, url, options={})
    active = options.delete(:active) if options.has_key?(:active)
 
    ### PLEASE if you change this make sure it doesn't break menus elsewhere, for example:
    ### people directory, group directory, group pages, etc.
    if url.is_a?(String) or url.is_a?(Hash)
      active = url_for(url) =~ /^#{Regexp.escape(request.path)}$/i if active.nil?
    elsif url.is_a?(Array)
      active = !url.select { |path| url_for(path).match(/^#{Regexp.escape(request.path)}$/i) ? true : false }.empty? if !active
      url = url.first
    else
      active = false if active.nil?
    end
{'fraction_non_alphanumeric': 0.15052865887590428, 'fraction_numerical': 0.0011129660545353367, 'mean_word_length': 3.2797619047619047, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '2613106', 'n_tokens_mistral': 1190, 'n_tokens_neox': 1173, 'n_words': 330}