Sha256: 690e2a03774580df4cf8fc68e4d53aeac7ab520ae14df3ebd984653373576638

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

class CmsLiteController < ApplicationController

  before_filter :login_required, :only => [:show_protected_page]

  def show_page
    render_content_page(CmsLite::PAGES_PATH)
  end
  
  def show_protected_page
    render_content_page(CmsLite::PROTECTED_PAGES_PATH)
  end
  
  def render_content_page(cms_lite_path, request_layout = '')
    path = File.join(RAILS_ROOT, CmsLite::CONTENT_PATH, cms_lite_path, I18n.locale.to_s, params[:content_key], params[:content_page].join('/'))
    format = params[:format] || 'htm'
    content_page = Dir.glob("/#{path}.#{format}").first
    content_page = Dir.glob("/#{path}").first  if content_page.nil?
    content_page = Dir.glob("/#{path}.*").first  if content_page.nil?
    raise CmsLite::Exceptions::MissingTemplateError, "Could not find template for: '#{path}'" if content_page.nil?
    respond_to do |format|
      format.html { render :file => content_page }
      format.js { render :file => content_page, :layout => false }
      format.xml { render :file => content_page, :layout => false }
    end
  rescue CmsLite::Exceptions::MissingTemplateError => ex
    
    render :file => "#{RAILS_ROOT}/public/404.html", :status => 404
  end
  
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
jbasdf-cms-lite-0.2.7 app/controllers/cms_lite_controller.rb
cms-lite-0.2.7 app/controllers/cms_lite_controller.rb