Sha256: d4d5e82432a2f55dea2a83b1271ecbc839447d8c67ef0242c2c59261f84e5a4f

Contents?: true

Size: 957 Bytes

Versions: 10

Compression:

Stored size: 957 Bytes

Contents

class Comfy::Cms::AssetsController < Comfy::Cms::BaseController

  skip_before_action :verify_authenticity_token

  before_action :load_cms_layout,
                :use_null_session

  after_action :set_cache_control_header

  def render_css
    render body: @cms_layout.css, content_type: "text/css"
  end

  def render_js
    render body: @cms_layout.js, content_type: "application/javascript"
  end

protected

  def load_cms_layout
    @cms_layout = @cms_site.layouts.find_by_identifier!(params[:identifier])
  rescue ActiveRecord::RecordNotFound
    render body: nil, status: 404
  end

  # null_session avoids cookies and flash updates
  def use_null_session
    ActionController::RequestForgeryProtection::ProtectionMethods::NullSession.new(self)
      .handle_unverified_request
  end

  def set_cache_control_header
    if params[:cache_buster].present?
      response.headers["Cache-Control"] = "public, max-age=#{1.year.to_i}"
    end
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-2.0.12 app/controllers/comfy/cms/assets_controller.rb
comfortable_mexican_sofa-2.0.11 app/controllers/comfy/cms/assets_controller.rb
comfortable_mexican_sofa-2.0.10 app/controllers/comfy/cms/assets_controller.rb
comfortable_mexican_sofa-2.0.9 app/controllers/comfy/cms/assets_controller.rb
comfortable_mexican_sofa-2.0.8 app/controllers/comfy/cms/assets_controller.rb
comfortable_mexican_sofa-2.0.7 app/controllers/comfy/cms/assets_controller.rb
comfortable_mexican_sofa-2.0.6 app/controllers/comfy/cms/assets_controller.rb
comfortable_mexican_sofa-2.0.5 app/controllers/comfy/cms/assets_controller.rb
comfortable_mexican_sofa-2.0.4 app/controllers/comfy/cms/assets_controller.rb
comfortable_mexican_sofa-2.0.3 app/controllers/comfy/cms/assets_controller.rb