Module: Spotlight::MetaHelper

Included in:
ApplicationHelper
Defined in:
app/helpers/spotlight/meta_helper.rb

Overview

HTML <meta> tag helpers

Instance Method Summary collapse

Instance Method Details

#add_browse_meta_content(browse) ⇒ Object



55
56
57
58
# File 'app/helpers/spotlight/meta_helper.rb', line 55

def add_browse_meta_content(browse)
  browse_twitter_card_content(browse)
  browse_opengraph_content(browse)
end

#add_document_meta_content(document) ⇒ Object



78
79
80
81
# File 'app/helpers/spotlight/meta_helper.rb', line 78

def add_document_meta_content(document)
  document_twitter_card_content(document)
  document_opengraph_content(document)
end

#add_exhibit_meta_contentObject



6
7
8
9
# File 'app/helpers/spotlight/meta_helper.rb', line 6

def add_exhibit_meta_content
  exhibit_twitter_card_content
  exhibit_opengraph_content
end

#add_page_meta_content(page) ⇒ Object



32
33
34
35
# File 'app/helpers/spotlight/meta_helper.rb', line 32

def add_page_meta_content(page)
  page_twitter_card_content(page)
  page_opengraph_content(page)
end

#browse_opengraph_content(browse) ⇒ Object



67
68
69
70
71
72
73
74
75
76
# File 'app/helpers/spotlight/meta_helper.rb', line 67

def browse_opengraph_content(browse)
  opengraph do |graph|
    graph.type 'article'
    graph.site_name application_name
    graph.title browse.title
    graph.send('og:image', browse.thumbnail.iiif_url) if browse.thumbnail
    graph.send('article:published_time', browse.created_at.iso8601)
    graph.send('article:modified_time', browse.updated_at.iso8601)
  end
end

#browse_twitter_card_content(browse) ⇒ Object



60
61
62
63
64
65
# File 'app/helpers/spotlight/meta_helper.rb', line 60

def browse_twitter_card_content(browse)
  twitter_card('summary_large_image') do |card|
    card.title browse.title
    card.image browse.thumbnail.iiif_url if browse.thumbnail
  end
end

#document_opengraph_content(document) ⇒ Object



92
93
94
95
96
97
98
99
100
# File 'app/helpers/spotlight/meta_helper.rb', line 92

def document_opengraph_content(document)
  presenter = show_presenter(document)

  opengraph do |graph|
    graph.site_name application_name
    graph.title presenter.heading
    graph.send('og:image', document.first(blacklight_config.index.thumbnail_field))
  end
end

#document_twitter_card_content(document) ⇒ Object



83
84
85
86
87
88
89
90
# File 'app/helpers/spotlight/meta_helper.rb', line 83

def document_twitter_card_content(document)
  presenter = show_presenter(document)

  twitter_card('summary_large_image') do |card|
    card.title presenter.heading
    card.image document.first(blacklight_config.index.thumbnail_field)
  end
end

#exhibit_opengraph_contentObject



24
25
26
27
28
29
30
# File 'app/helpers/spotlight/meta_helper.rb', line 24

def exhibit_opengraph_content
  opengraph do |graph|
    graph.title current_exhibit.title
    graph.image meta_image if current_exhibit.thumbnail
    graph.site_name site_title
  end
end

#exhibit_twitter_card_contentObject



11
12
13
14
15
16
17
18
# File 'app/helpers/spotlight/meta_helper.rb', line 11

def exhibit_twitter_card_content
  twitter_card('summary') do |card|
    card.url exhibit_root_url(current_exhibit)
    card.title current_exhibit.title
    card.description current_exhibit.subtitle
    card.image meta_image if current_exhibit.thumbnail
  end
end

#meta_imageObject



20
21
22
# File 'app/helpers/spotlight/meta_helper.rb', line 20

def meta_image
  current_exhibit.thumbnail.iiif_url
end

#page_opengraph_content(page) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'app/helpers/spotlight/meta_helper.rb', line 44

def page_opengraph_content(page)
  opengraph do |graph|
    graph.type 'article'
    graph.site_name application_name
    graph.title page.title
    graph.send('og:image', page.thumbnail.iiif_url) if page.thumbnail
    graph.send('article:published_time', page.created_at.iso8601)
    graph.send('article:modified_time', page.updated_at.iso8601)
  end
end

#page_twitter_card_content(page) ⇒ Object



37
38
39
40
41
42
# File 'app/helpers/spotlight/meta_helper.rb', line 37

def page_twitter_card_content(page)
  twitter_card('summary_large_image') do |card|
    card.title page.title
    card.image page.thumbnail.iiif_url if page.thumbnail
  end
end