Sha256: c87906ede42ffe96c042519a73f0c4fc0fb9c63572075864018f08c4c66a823f
Contents?: true
Size: 1.53 KB
Versions: 4
Compression:
Stored size: 1.53 KB
Contents
class CmsContentController < ApplicationController before_filter :load_cms_site before_filter :load_cms_page, :only => :render_html before_filter :load_cms_layout, :only => [:render_css, :render_js] caches_page :render_css, :render_js, :if => Proc.new { |c| ComfortableMexicanSofa.config.enable_caching } def render_html(status = 200) layout = @cms_page.cms_layout.app_layout.blank?? false : @cms_page.cms_layout.app_layout render :inline => @cms_page.content, :layout => layout, :status => status end def render_css render :text => @cms_layout.css, :content_type => 'text/css' end def render_js render :text => @cms_layout.js, :content_type => 'text/javascript' end protected def load_cms_site @cms_site = CmsSite.find_by_hostname!(ComfortableMexicanSofa.config.override_host || request.host.downcase) rescue ActiveRecord::RecordNotFound render :text => 'Site Not Found', :status => 404 end def load_cms_page @cms_page = CmsPage.published.load_for_full_path!(@cms_site, "/#{params[:cms_path]}") return redirect_to(@cms_page.target_page.full_path) if @cms_page.target_page rescue ActiveRecord::RecordNotFound if @cms_page = CmsPage.published.load_for_full_path(@cms_site, '/404') render_html(404) else render :text => 'Page Not Found', :status => 404 end end def load_cms_layout @cms_layout = CmsLayout.load_for_slug!(@cms_site, params[:id]) rescue ActiveRecord::RecordNotFound render :nothing => true, :status => 404 end end
Version data entries
4 entries across 4 versions & 1 rubygems