Sha256: cc6de451adb012d491ed0a907125b0d51fa9617d196e63fc27713b9c14c96baf

Contents?: true

Size: 1.03 KB

Versions: 7

Compression:

Stored size: 1.03 KB

Contents

module Lookbook
  class ApplicationController < ActionController::Base
    content_security_policy false, if: -> { Rails.env.development? }
    protect_from_forgery with: :exception

    helper Lookbook::ApplicationHelper
    helper Lookbook::OutputHelper
    helper Lookbook::ComponentHelper

    before_action :generate_theme_overrides

    def self.controller_path
      "lookbook"
    end

    def index
      landing = Lookbook.pages.find(&:landing) || Lookbook.pages.first
      if landing.present?
        redirect_to lookbook_page_path(landing.lookup_path)
      else
        render "lookbook/index"
      end
    end

    protected

    def generate_theme_overrides
      @theme_overrides ||= Lookbook.theme.to_css
    end

    def feature_enabled?(feature)
      Lookbook::Features.enabled?(feature)
    end

    def render_in_layout(path, layout: nil, **locals)
      @error = locals[:error]
      render path, layout: layout.presence || (params[:lookbook_embed] ? "lookbook/basic" : "lookbook/application"), locals: locals
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lookbook-1.0.4 app/controllers/lookbook/application_controller.rb
lookbook-1.0.3 app/controllers/lookbook/application_controller.rb
lookbook-1.0.2 app/controllers/lookbook/application_controller.rb
lookbook-1.0.1 app/controllers/lookbook/application_controller.rb
lookbook-1.0.0 app/controllers/lookbook/application_controller.rb
lookbook-1.0.0.rc.3 app/controllers/lookbook/application_controller.rb
lookbook-1.0.0.rc.2 app/controllers/lookbook/application_controller.rb