Sha256: 5439e8dba2948e8fa944eab8d422e37a8770be342b25e61ef7a5d86b3c1840b2

Contents?: true

Size: 1.27 KB

Versions: 12

Compression:

Stored size: 1.27 KB

Contents

class SiteController < ApplicationController
  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)
      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 set_cache_control
      if (request.head? || request.get?) && @page.cache?
        expires_in self.class.cache_timeout, :public => true, :private => false
      else
        expires_in nil, :private => true, "no-cache" => true
        headers['ETag'] = ''
      end
    end
    
    def find_page(url)
      found = Page.find_by_url(url, live?)
      found if found and (found.published? or dev?)
    end

    def process_page(page)
      page.process(request, response)
    end

    def dev?
      if dev_host = @config['dev.host']
        request.host == dev_host
      else
        request.host =~ /^dev\./
      end
    end
    
    def live?
      not dev?
    end

end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
radiantcms-couchrest_model-0.2.4 app/controllers/site_controller.rb
radiantcms-couchrest_model-0.2.2 app/controllers/site_controller.rb
radiantcms-couchrest_model-0.2.1 app/controllers/site_controller.rb
radiantcms-couchrest_model-0.2 app/controllers/site_controller.rb
radiantcms-couchrest_model-0.1.9 app/controllers/site_controller.rb
radiantcms-couchrest_model-0.1.8 app/controllers/site_controller.rb
radiantcms-couchrest_model-0.1.7 app/controllers/site_controller.rb
radiantcms-couchrest_model-0.1.6 app/controllers/site_controller.rb
radiantcms-couchrest_model-0.1.5 app/controllers/site_controller.rb
radiant-0.8.2 app/controllers/site_controller.rb
radiant-0.8.1 app/controllers/site_controller.rb
radiant-0.8.0 app/controllers/site_controller.rb