<commit_before>class SiteController < ApplicationController
  include Radiant::Pagination::Controller

  skip_before_filter :verify_authenticity_token
  no_login_required
  cattr_writer :cache_timeout

  def self.cache_timeout
    @@cache_timeout ||= 5.minutes
  end

  def show_page
    url = params[:url]
    if Array === url
      url = url.join('/')
    else
      url = url.to_s
    end
    if @page = find_page(url)
      batch_page_status_refresh if (url == "/" || url == "")
      process_page(@page)
      set_cache_control
      @performed_render ||= true
    else
      render :template => 'site/not_found', :status => 404
    end
  rescue Page::MissingRootPageError
    redirect_to welcome_url
  end

  private
    def batch_page_status_refresh
      @changed_pages = []
      @pages = Page.find(:all, :conditions => {:status_id => Status[:scheduled].id})
      @pages.each do |page|
        if page.published_at <= Time.now
           page.status_id = Status[:published].id
           page.save
           @changed_pages << page.id
        end
      end

      expires_in nil, :private=>true, "no-cache" => true if @changed_pages.length > 0
    end

    def set_cache_control
      if (request.head? || request.get?) && @page.cache? && live?
        expires_in self.class.cache_timeout, :public => true, :private => false
      else
        expires_in nil, :private => true, "no-cache" => true
        headers['ETag'] = ''
      end
    end
<commit_msg>Updated the site controller to respect `dev.cache`<commit_after>class SiteController < ApplicationController
  include Radiant::Pagination::Controller

  skip_before_filter :verify_authenticity_token
  no_login_required
  cattr_writer :cache_timeout

  def self.cache_timeout
    @@cache_timeout ||= 5.minutes
  end

  def show_page
    url = params[:url]
    if Array === url
      url = url.join('/')
    else
      url = url.to_s
    end
    if @page = find_page(url)
      batch_page_status_refresh if (url == "/" || url == "")
      process_page(@page)
      set_cache_control
      @performed_render ||= true
    else
      render :template => 'site/not_found', :status => 404
    end
  rescue Page::MissingRootPageError
    redirect_to welcome_url
  end

  private
    def batch_page_status_refresh
      @changed_pages = []
      @pages = Page.find(:all, :conditions => {:status_id => Status[:scheduled].id})
      @pages.each do |page|
        if page.published_at <= Time.now
           page.status_id = Status[:published].id
           page.save
           @changed_pages << page.id
        end
      end

      expires_in nil, :private=>true, "no-cache" => true if @changed_pages.length > 0
    end

    def set_cache_control
      if (request.head? || request.get?) && @page.cache? && (live? || @config['dev.cache?'])
        expires_in self.class.cache_timeout, :public => true, :private => false
      else
        expires_in nil, :private => true, "no-cache" => true
        headers['ETag'] = ''
      end
    end

{'fraction_non_alphanumeric': 0.11615487316421896, 'fraction_numerical': 0.0033377837116154874, 'mean_word_length': 2.659340659340659, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, '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': '1060436', 'n_tokens_mistral': 945, 'n_tokens_neox': 918, 'n_words': 217}