Sha256: 28ac731efa0604b3ae75bbbbdaf9fb12fd32e6b079272947681d938b7ca86b12
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
class Cms::ContentController < Cms::BaseController # Respond with HTML by default so that requests with 'Accept: */*' get a web page (e.g. Facebook) respond_to :html, :json # Authentication module must have #authenticate method include ComfortableMexicanSofa.config.public_auth.to_s.constantize before_action :load_fixtures before_action :authenticate, :only => :show rescue_from ActiveRecord::RecordNotFound, :with => :page_not_found def show @cms_page = @cms_site.pages.published.find_by_full_path!("/#{params[:cms_path]}") if @cms_page.target_page.present? redirect_to @cms_page.target_page.url else respond_with(@cms_page) do |format| format.html { render_html } end end end def render_sitemap render end protected def render_html(status = 200) if @cms_layout = @cms_page.layout app_layout = (@cms_layout.app_layout.blank? || request.xhr?) ? false : @cms_layout.app_layout render :inline => @cms_page.content, :layout => app_layout, :status => status, :content_type => 'text/html' else render :text => I18n.t('cms.content.layout_not_found'), :status => 404 end end def load_fixtures return unless ComfortableMexicanSofa.config.enable_fixtures ComfortableMexicanSofa::Fixture::Importer.new(@cms_site.identifier).import! end def page_not_found @cms_page = @cms_site.pages.published.find_by_full_path!('/404') respond_with @cms_page do |format| format.html { render_html(404) } end rescue ActiveRecord::RecordNotFound raise ActionController::RoutingError.new("Page Not Found at: \"#{params[:cms_path]}\"") end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
comfortable_mexican_sofa-1.11.2 | app/controllers/cms/content_controller.rb |