Module: Workarea::Storefront::DisplayContent

Instance Method Summary collapse

Instance Method Details

#browser_titleObject



7
8
9
10
11
12
13
# File 'app/view_models/workarea/storefront/display_content.rb', line 7

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

#contentObject



37
38
39
# File 'app/view_models/workarea/storefront/display_content.rb', line 37

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

#content_blocksObject



41
42
43
# File 'app/view_models/workarea/storefront/display_content.rb', line 41

def content_blocks
  content_blocks_for(:default)
end

#content_blocks_for(area) ⇒ Object



45
46
47
48
49
# File 'app/view_models/workarea/storefront/display_content.rb', line 45

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

#meta_descriptionObject



15
16
17
18
19
20
21
22
# File 'app/view_models/workarea/storefront/display_content.rb', line 15

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

#open_graph_assetObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/view_models/workarea/storefront/display_content.rb', line 24

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