Sha256: 964dc3d756c462a66eeab1f253c03e75aaca801d12792eee357dd6ece45e98dd

Contents?: true

Size: 1.21 KB

Versions: 8

Compression:

Stored size: 1.21 KB

Contents

module Lookbook
  class ApplicationController < ActionController::Base
    if respond_to?(:content_security_policy)
      content_security_policy false, if: -> { Rails.env.development? }
    end

    protect_from_forgery with: :exception

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

    before_action :generate_theme_overrides
    before_action :assign_collections

    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 assign_collections
      @previews = Preview.all
      @pages = Page.all
    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

8 entries across 8 versions & 1 rubygems

Version Path
lookbook-1.2.1 app/controllers/lookbook/application_controller.rb
lookbook-1.2.0 app/controllers/lookbook/application_controller.rb
lookbook-1.1.1 app/controllers/lookbook/application_controller.rb
lookbook-1.1.0 app/controllers/lookbook/application_controller.rb
lookbook-1.0.8 app/controllers/lookbook/application_controller.rb
lookbook-1.0.7 app/controllers/lookbook/application_controller.rb
lookbook-1.0.6 app/controllers/lookbook/application_controller.rb
lookbook-1.0.5 app/controllers/lookbook/application_controller.rb