Sha256: 907b4fc4b309011bd1adc0a7660ce644507bc50cee84dd24c3ebd37f5b5e440a
Contents?: true
Size: 1.87 KB
Versions: 2
Compression:
Stored size: 1.87 KB
Contents
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 def find_page(url) found = Page.find_by_path(url, live?) found if found and (found.published? or dev?) end def process_page(page) page.pagination_parameters = pagination_parameters 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
radiant-1.0.0.rc2 | app/controllers/site_controller.rb |
radiant-1.0.0.rc1 | app/controllers/site_controller.rb |