Sha256: 5ed7b90df772c5272a8a4f799bc58600f522b73fc94230f6bdd954517928cf44
Contents?: true
Size: 1.97 KB
Versions: 1
Compression:
Stored size: 1.97 KB
Contents
require_dependency 'radiant/pagination/link_renderer' require_dependency 'radiant/pagination/controller' class SiteController < ApplicationController include Radiant::Pagination::Controller skip_before_filter :verify_authenticity_token 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 self.response_body = response.body 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_url(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 = Radiant::Config['dev.host'] request.host == dev_host else request.host =~ /^dev\./ end end def live? not dev? end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
radiant-rails3-0.1 | app/controllers/site_controller.rb |