Sha256: 22a89f0509852f9b944f6382a31d8707b604e101d73c9fd632008711f609fe72

Contents?: true

Size: 1002 Bytes

Versions: 12

Compression:

Stored size: 1002 Bytes

Contents

# frozen_string_literal: true

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

  skip_before_action :verify_authenticity_token, raise: false

  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

12 entries across 12 versions & 6 rubygems

Version Path
comfortable_mexican_sofa-2.0.19 app/controllers/comfy/cms/assets_controller.rb
PixelForce_ETS-0.0.2 app/controllers/comfy/cms/assets_controller.rb
PixelForce_ETS-0.0.1 app/controllers/comfy/cms/assets_controller.rb
kcyEtsTest2-0.0.4 app/controllers/comfy/cms/assets_controller.rb
kcyEtsTest2-0.0.3 app/controllers/comfy/cms/assets_controller.rb
kcyEtsTest2-0.0.2 app/controllers/comfy/cms/assets_controller.rb
kcyEtsTest2-0.0.1 app/controllers/comfy/cms/assets_controller.rb
kcyEtsTest-0.0.1 app/controllers/comfy/cms/assets_controller.rb
kcyEtsTest-2.2.19 app/controllers/comfy/cms/assets_controller.rb
ComfortableMexicanSofa-2.0.18 app/controllers/comfy/cms/assets_controller.rb
kcy1-1.0 app/controllers/comfy/cms/assets_controller.rb
comfortable_mexican_sofa-2.0.18 app/controllers/comfy/cms/assets_controller.rb