<commit_before># coding: utf-8
class ApplicationController < ActionController::Base
  AVAILABLE_LOCALES = ['pt']

  include Concerns::ExceptionHandler
  include Concerns::MenuHandler
  include Concerns::SocialHelpersHandler
  include Concerns::AnalyticsHelpersHandler
  include Pundit

  layout 'catarse_bootstrap'
  protect_from_forgery

  before_filter :configure_permitted_parameters, if: :devise_controller?

  helper_method :referal_link, :render_projects, :should_show_beta_banner?, :render_feeds

  before_filter :set_locale

  before_action :referal_it!

  before_action :force_www

  def referal_link
    session[:referal_link]
  end

  def render_projects collection, ref, locals = {}
    render_to_string partial: 'projects/card', collection: collection, locals: {ref: ref}.merge!(locals)
  end

  def render_feeds collection, locals = {}
    render_to_string partial: 'users/feeds/feed', collection: collection, locals: locals
  end

  def should_show_beta_banner?
    current_user.nil? || current_user.projects.empty?
  end

  def should_show_beta_banner?
    current_user.nil? || current_user.projects.empty?
  end

  private
  def force_www
    if request.subdomain.blank? && Rails.env.production?
      return redirect_to url_for(params.merge(subdomain: 'www'))
    end
  end

  def referal_it!
    session[:referal_link] = params[:ref] if params[:ref].present?
  end

  def detect_old_browsers
    return redirect_to page_path("bad_browser") if (!browser.modern? || browser.ie9?) && controller_name != 'pages'
  end

  def set_locale
    return redirect_to url_for(locale: I18n.default_locale, only_path: true) unless is_locale_available?
    I18n.locale = params[:locale] || I18n.default_locale
  end

  def is_locale_available?
    params[:locale].blank? || AVAILABLE_LOCALES.include?(params[:locale])
  end

  def after_sign_in_path_for(resource_or_scope)
    (session.delete(:return_to) || root_path)
  end<commit_msg>Converts params[:locale] to string to work with specs where it comes as symbol sometimes<commit_after># coding: utf-8
class ApplicationController < ActionController::Base
  AVAILABLE_LOCALES = ['pt']

  include Concerns::ExceptionHandler
  include Concerns::MenuHandler
  include Concerns::SocialHelpersHandler
  include Concerns::AnalyticsHelpersHandler
  include Pundit

  layout 'catarse_bootstrap'
  protect_from_forgery

  before_filter :configure_permitted_parameters, if: :devise_controller?

  helper_method :referal_link, :render_projects, :should_show_beta_banner?, :render_feeds

  before_filter :set_locale

  before_action :referal_it!

  before_action :force_www

  def referal_link
    session[:referal_link]
  end

  def render_projects collection, ref, locals = {}
    render_to_string partial: 'projects/card', collection: collection, locals: {ref: ref}.merge!(locals)
  end

  def render_feeds collection, locals = {}
    render_to_string partial: 'users/feeds/feed', collection: collection, locals: locals
  end

  def should_show_beta_banner?
    current_user.nil? || current_user.projects.empty?
  end

  def should_show_beta_banner?
    current_user.nil? || current_user.projects.empty?
  end

  private
  def force_www
    if request.subdomain.blank? && Rails.env.production?
      return redirect_to url_for(params.merge(subdomain: 'www'))
    end
  end

  def referal_it!
    session[:referal_link] = params[:ref] if params[:ref].present?
  end

  def detect_old_browsers
    return redirect_to page_path("bad_browser") if (!browser.modern? || browser.ie9?) && controller_name != 'pages'
  end

  def set_locale
    return redirect_to url_for(locale: I18n.default_locale, only_path: true) unless is_locale_available?
    I18n.locale = params[:locale] || I18n.default_locale
  end

  def is_locale_available?
    params[:locale].blank? || AVAILABLE_LOCALES.include?(params[:locale].to_s)
  end

  def after_sign_in_path_for(resource_or_scope)
    (session.delete(:return_to) || root_path)
  end
{'fraction_non_alphanumeric': 0.09247094492167761, 'fraction_numerical': 0.00404244567963618, 'mean_word_length': 5.062787136294028, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7307936', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1249, 'n_words': 272}