<commit_before>module LayoutHelper
  def search_result_description(result)
    truncate(strip_tags(result.description.content), :length => 160)
  rescue
    nil
  end

  def back_to_model_link
    last_etm_controller_name = Current.setting.last_etm_controller_name
    if last_etm_controller_name.blank?
      link_to t("Home"), root_path
    else
      link_to t("back to model"), :controller => last_etm_controller_name,
                                  :action => session[:last_etm_action_name]
    end
  end

  def current_tutorial_movie
    SidebarItem.find_by_key(params[:id]).andand.send("#{I18n.locale}_vimeo_id")
  end

  def country_option(code, opts = {})
    current = Current.setting.region == code
    selected = current ? "selected='true'" : nil
    %Q{<option value="#{code}" #{selected}>#{I18n.t(code)} #{"(test)" if opts[:test]}</option>}.html_safe
  end

  def percentage_bar(item)
    return if item.percentage_bar_query.blank?
    # need client for showing % bars
    if client ||= Api::Client.new
      client.api_session_id = Current.setting.api_session_id
    end
    val = client.simple_query(item.percentage_bar_query)
    # multiplied by 90 because of interface limits, there should be some space left for the value
    haml_tag :span, :class =>'bar',
                    :style => "width: #{(val * 90).round(2)}%",
                    :alt => I18n.t('sidebar_items.alt')
    haml_tag :span, :class =>'value',
                    :style => "left: #{(val * 90).round(2)}%" do<commit_msg>nicer country_option helper<commit_after>module LayoutHelper
  def search_result_description(result)
    truncate(strip_tags(result.description.content), :length => 160)
  rescue
    nil
  end

  def back_to_model_link
    last_etm_controller_name = Current.setting.last_etm_controller_name
    if last_etm_controller_name.blank?
      link_to t("Home"), root_path
    else
      link_to t("back to model"), :controller => last_etm_controller_name,
                                  :action => session[:last_etm_action_name]
    end
  end

  def current_tutorial_movie
    SidebarItem.find_by_key(params[:id]).andand.send("#{I18n.locale}_vimeo_id")
  end

  def country_option(code, opts = {})
    current = Current.setting.region == code
    selected = current ? "selected='true'" : nil
    label = I18n.t(code)
    label += ' (test)' if opts[:test]
    content_tag :option, label, :value => code, :selected => selected
  end

  def percentage_bar(item)
    return if item.percentage_bar_query.blank?
    # need client for showing % bars
    if client ||= Api::Client.new
      client.api_session_id = Current.setting.api_session_id
    end
    val = client.simple_query(item.percentage_bar_query)
    # multiplied by 90 because of interface limits, there should be some space left for the value
    haml_tag :span, :class =>'bar',
                    :style => "width: #{(val * 90).round(2)}%",
                    :alt => I18n.t('sidebar_items.alt')
    haml_tag :span, :class =>'value',
                    :style => "left: #{(val * 90).round(2)}%" do
{'fraction_non_alphanumeric': 0.12088628217660476, 'fraction_numerical': 0.011078527207559466, 'mean_word_length': 3.15426251691475, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1435221', 'n_tokens_mistral': 1011, 'n_tokens_neox': 959, 'n_words': 216}