<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.upcase, url, options[:active]),
      :class => 'topnav'
    )
    content_tag(:li,
      [menu_heading, options[:menu_items]].combine("\n"),
      :class => ['menu', (options[:active] && 'active')].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
  ##
  def menu(label, url, options={})
    active = options[:active] || (url_for(url) =~ /#{request.path}/i)
    selected_class = active ? (options[:selected_class] || 'current') : ''
    content_tag(:li,
      link_to(label.upcase, url, options),
      options.merge(
        { :class => [options[:class], selected_class].join(' ')})
    )
  end

  # returns :active option for menu() above
  def active_tab_for_nav(level_nav, action)
    level_nav == action ? {:active => true} : {:active => false}
  end

  def home_option
    menu(
      I18n.t(:menu_home),
      '/',
      {
        :active => @active_tab == :home,
        :id => 'menu_home'
      }
    )
  end

  def me_option
    top_menu(
      I18n.t(:menu_me),
      "/pages/my_work",
      :active => @active_tab == :me,
      :menu_items => menu_items('me'),
      :id => 'menu_me'
    )
  end

  def people_option
    top_menu(
      I18n.t(:menu_people),
      people_directory_url(:friends),
      :active => @active_tab == :people,
      :menu_items => menu_items('boxes', {
        :entities => current_user.friends.most_active,
        :heading  => I18n.t(:my_contacts),
        :see_all_url => people_directory_url(:friends),
        :submenu => 'people'
      }),
      :id => 'menu_people'
    )
  end

  def groups_option
    top_menu(
      I18n.t(:menu_groups),
      group_directory_url,
      :active => @active_tab == :groups,
      :menu_items => menu_items('boxes', {
        :entities => current_user.primary_groups.most_active,
        :heading => I18n.t(:my_groups),
        :see_all_url => group_directory_url(:action => 'my'),
        :submenu => 'groups'
      }),
      :id => 'menu_groups'
    )
  end

  def networks_option
    top_menu(
      I18n.t(:menu_networks),
      network_directory_url,
      :active => @active_tab == :networks,
      :menu_items => menu_items('boxes', {
        :entities => current_user.primary_networks.most_active,
        :heading => I18n.t(:my_networks),
        :see_all_url => network_directory_url(:action => 'my'),
        :submenu => 'networks'
      }),
      :id => 'menu_networks'
    )
  end

  def chat_option
    menu I18n.t(:menu_chat), '/chat', :active => @active_tab == :chat, :id => 'menu_chat'
  end

  def admin_option
    menu I18n.t(:menu_admin), '/admin', :active => @active_tab == :admin, :id => 'menu_admin'
  end

  ##
  ## MENUS
  ##

  def menu_home
    top_menu(
      'menu_home',
      I18n.t(:menu_home),
      '/',
      :active => @active_tab == :home<commit_msg>fix current global nav tab<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.upcase, 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
  ##
  def menu(label, url, options={})
    active = options[:active] || (url_for(url) =~ /#{request.path}/i)
    selected_class = active ? (options[:selected_class] || 'current') : ''
    content_tag(:li,
      link_to(label.upcase, url, options),
      options.merge(
        { :class => [options[:class], selected_class].join(' ')})
    )
  end

  # returns :active option for menu() above
  def active_tab_for_nav(level_nav, action)
    level_nav == action ? {:active => true} : {:active => false}
  end

  def home_option
    top_menu(
      I18n.t(:menu_home),
      '/',
      {
        :active => @active_tab == :home,
        :id => 'menu_home'
      }
    )
  end

  def me_option
    top_menu(
      I18n.t(:menu_me),
      "/pages/my_work",
      :active => @active_tab == :me,
      :menu_items => menu_items('me'),
      :id => 'menu_me'
    )
  end

  def people_option
    top_menu(
      I18n.t(:menu_people),
      people_directory_url(:friends),
      :active => @active_tab == :people,
      :menu_items => menu_items('boxes', {
        :entities => current_user.friends.most_active,
        :heading  => I18n.t(:my_contacts),
        :see_all_url => people_directory_url(:friends),
        :submenu => 'people'
      }),
      :id => 'menu_people'
    )
  end

  def groups_option
    top_menu(
      I18n.t(:menu_groups),
      group_directory_url,
      :active => @active_tab == :groups,
      :menu_items => menu_items('boxes', {
        :entities => current_user.primary_groups.most_active,
        :heading => I18n.t(:my_groups),
        :see_all_url => group_directory_url(:action => 'my'),
        :submenu => 'groups'
      }),
      :id => 'menu_groups'
    )
  end

  def networks_option
    top_menu(
      I18n.t(:menu_networks),
      network_directory_url,
      :active => @active_tab == :networks,
      :menu_items => menu_items('boxes', {
        :entities => current_user.primary_networks.most_active,
        :heading => I18n.t(:my_networks),
        :see_all_url => network_directory_url(:action => 'my'),
        :submenu => 'networks'
      }),
      :id => 'menu_networks'
    )
  end

  def chat_option
    menu I18n.t(:menu_chat), '/chat', :active => @active_tab == :chat, :id => 'menu_chat'
  end

  def admin_option
    top_menu I18n.t(:menu_admin), '/admin', :active => @active_tab == :admin, :id => 'menu_admin'
  end

  ##
  ## MENUS
  ##

  def menu_home
    top_menu(
      'menu_home',
      I18n.t(:menu_home),
      '/',
      :active => @active_tab == :home
{'fraction_non_alphanumeric': 0.16320136713187125, 'fraction_numerical': 0.006266021076616349, 'mean_word_length': 2.733652312599681, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 91, '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': '7217434', 'n_tokens_mistral': 2479, 'n_tokens_neox': 2420, 'n_words': 457}