<commit_before>module ControllerExtension::CurrentSite

  def self.included(base)
    base.class_eval do
      # make current_site available to the views
      helper_method :current_site
    end
  end

  public

  # returns the (cache) of the current site.
  def current_site
    if !@current_site_disabled
      @current_site ||= begin
        host = request.host.sub(/^staging\./, '')
        site = Site.for_domain(host).find(:first)
        site ||= Site.default
        site ||= Site.new(:domain => host)
        Site.current = site
        # ^^ not so nice, but required for now. used by i18n and
        # by acts_as_site_limited
      end
    else
      Site.new()
    end
  end

  # used for testing
  def disable_current_site
    @current_site_disabled = true
  end

  # used for testing
  def enable_current_site
    @current_site = nil
    @current_site_disabled = false
  end

end
<commit_msg>add a site name for non-site usage for custom translations<commit_after>module ControllerExtension::CurrentSite

  def self.included(base)
    base.class_eval do
      # make current_site available to the views
      helper_method :current_site
    end
  end

  public

  # returns the (cache) of the current site.
  def current_site
    if !@current_site_disabled
      @current_site ||= begin
        host = request.host.sub(/^staging\./, '')
        site = Site.for_domain(host).find(:first)
        site ||= Site.default
        site ||= Site.new(:domain => host, :name => 'custom')
        Site.current = site
        # ^^ not so nice, but required for now. used by i18n and
        # by acts_as_site_limited
      end
    else
      Site.new()
    end
  end

  # used for testing
  def disable_current_site
    @current_site_disabled = true
  end

  # used for testing
  def enable_current_site
    @current_site = nil
    @current_site_disabled = false
  end

end

{'fraction_non_alphanumeric': 0.0825346112886049, 'fraction_numerical': 0.002129925452609159, 'mean_word_length': 2.5187265917602994, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '4038150', 'n_tokens_mistral': 581, 'n_tokens_neox': 565, 'n_words': 167}