Sha256: 327cb5d74dbd42105acf0864888d4890c96ca1d16aec117c6da4e21553937fd9

Contents?: true

Size: 905 Bytes

Versions: 2

Compression:

Stored size: 905 Bytes

Contents

class Cambium::PagesController < ApplicationController

  before_filter :set_page, :only => [:show]
  before_filter :set_home_page, :only => [:home]

  if Cambium.configuration.cache_pages
    caches_action :show, :cache_path => :page_cache_path.to_proc
    caches_action :home, :cache_path => :page_cache_path.to_proc
  end

  def show
    render :inline => @page.template.content, :layout => 'application'
  end

  def home
    if @page.nil?
      render 'home_missing'
    else
      render :inline => @page.template.content, :layout => 'application'
    end
  end

  protected

    def set_page
      @page = Cambium::Page.find_by_page_path(request.path)
    end

    def set_home_page
      @page = Cambium::Page.home
    end

    def q_to_s
      request.query_parameters.to_a.collect { |q| "_#{q[0]}_#{q[1]}"  }.join('')
    end

    def page_cache_path
      "_p#{@page.id}#{q_to_s}"
    end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cambium-1.3.2 app/controllers/cambium/pages_controller.rb
cambium-1.3.1 app/controllers/cambium/pages_controller.rb