<commit_before># Filters added to this controller will be run for all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
  # wait until we have multiple sites before we deal with changing the cache root
  #before_filter :set_cache_root
  helper_method :site
  
  def site
    # Redefine this method if you wish to fail on host without a site
    @site ||= Site.find_by_host(request.host) || Site.find(:first)
  end

  def render_liquid_template_for(template_type, assigns = {})
    headers["Content-Type"] ||= 'text/html; charset=utf-8'

    unless assigns['article']
      self.cached_references += assigns['articles']
      assigns['articles']     = assigns['articles'].collect { |a| a.to_liquid }
    end
    
    assigns.update 'site' => site.to_liquid
    render :text => site.templates.render_liquid_for(template_type, assigns, self)
  end
  
  #protected
  #  def set_cache_root
  #    self.class.page_cache_directory = File.join([RAILS_ROOT, (RAILS_ENV == 'test' ? 'tmp' : 'public'), 'cache', site.host].compact)
  #  end
end<commit_msg>set up before_filter to load @site<commit_after># Filters added to this controller will be run for all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
  # wait until we have multiple sites before we deal with changing the cache root
  before_filter :load_site
  #before_filter :set_cache_root
  helper_method :site
  attr_reader :site

  def render_liquid_template_for(template_type, assigns = {})
    headers["Content-Type"] ||= 'text/html; charset=utf-8'

    unless assigns['article']
      self.cached_references += assigns['articles']
      assigns['articles']     = assigns['articles'].collect { |a| a.to_liquid }
    end
    
    assigns.update 'site' => site.to_liquid
    render :text => site.templates.render_liquid_for(template_type, assigns, self)
  end
  
  protected
    def load_site
      # Redefine this method if you wish to fail on host without a site
      @site ||= Site.find_by_host(request.host) || Site.find(:first)
    end

  #  def set_cache_root
  #    self.class.page_cache_directory = File.join([RAILS_ROOT, (RAILS_ENV == 'test' ? 'tmp' : 'public'), 'cache', site.host].compact)
  #  end
end
{'fraction_non_alphanumeric': 0.10327455919395466, 'fraction_numerical': 0.0008396305625524769, 'mean_word_length': 4.006302521008403, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '4014747', 'n_tokens_mistral': 753, 'n_tokens_neox': 707, 'n_words': 214}