Sha256: 17202e9db6fc0bd78e2bd26493bca17d2527a6573dc09038e5f221f76daba55b

Contents?: true

Size: 1.45 KB

Versions: 28

Compression:

Stored size: 1.45 KB

Contents

module Workarea
  module Storefront
    module DisplayContent
      delegate :css, :javascript, :head_content,
        to: :content, allow_nil: true

      def browser_title
        if content && content.browser_title.present?
          content.browser_title
        elsif model.respond_to?(:name)
          name
        end
      end

      def meta_description
        return content.meta_description unless content.meta_description.blank?

        t(
          'workarea.storefront.layouts.default_meta_description',
          site_name: Workarea.config.site_name
        )
      end

      def open_graph_asset
        @open_graph_asset ||=
          if content.open_graph_asset_id.present?
            Content::Asset.find(content.open_graph_asset_id)
          elsif (og_default = Content::Asset.open_graph_default).present?
            og_default
          else
            Content::Asset.open_graph_placeholder
          end
      rescue Mongoid::Errors::DocumentNotFound
        @open_graph_asset = Content::Asset.open_graph_placeholder
      end

      def content
        @content ||= Content.for(content_lookup)
      end

      def content_blocks
        content_blocks_for(:default)
      end

      def content_blocks_for(area)
        return [] unless content.present?
        blocks = content.blocks_for(area).select(&:active?)
        ContentBlockViewModel.wrap(blocks, options)
      end

      private

      def content_lookup
        model
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-storefront-3.5.27 app/view_models/workarea/storefront/display_content.rb
workarea-storefront-3.5.26 app/view_models/workarea/storefront/display_content.rb
workarea-storefront-3.5.25 app/view_models/workarea/storefront/display_content.rb
workarea-storefront-3.5.23 app/view_models/workarea/storefront/display_content.rb
workarea-storefront-3.5.22 app/view_models/workarea/storefront/display_content.rb
workarea-storefront-3.5.21 app/view_models/workarea/storefront/display_content.rb
workarea-storefront-3.5.20 app/view_models/workarea/storefront/display_content.rb
workarea-storefront-3.5.19 app/view_models/workarea/storefront/display_content.rb
workarea-storefront-3.5.18 app/view_models/workarea/storefront/display_content.rb
workarea-storefront-3.5.17 app/view_models/workarea/storefront/display_content.rb
workarea-storefront-3.5.16 app/view_models/workarea/storefront/display_content.rb
workarea-storefront-3.5.15 app/view_models/workarea/storefront/display_content.rb
workarea-storefront-3.5.14 app/view_models/workarea/storefront/display_content.rb
workarea-storefront-3.5.13 app/view_models/workarea/storefront/display_content.rb
workarea-storefront-3.5.12 app/view_models/workarea/storefront/display_content.rb
workarea-storefront-3.5.11 app/view_models/workarea/storefront/display_content.rb
workarea-storefront-3.5.10 app/view_models/workarea/storefront/display_content.rb
workarea-storefront-3.5.9 app/view_models/workarea/storefront/display_content.rb
workarea-storefront-3.5.8 app/view_models/workarea/storefront/display_content.rb
workarea-storefront-3.5.7 app/view_models/workarea/storefront/display_content.rb