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



53
54
55
56
# File 'app/helpers/spotlight/meta_helper.rb', line 53

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

#add_document_meta_content(document) ⇒ Object



76
77
78
79
# File 'app/helpers/spotlight/meta_helper.rb', line 76

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

#add_exhibit_meta_contentObject



4
5
6
7
# File 'app/helpers/spotlight/meta_helper.rb', line 4

def add_exhibit_meta_content
  exhibit_twitter_card_content
  exhibit_opengraph_content
end

#add_page_meta_content(page) ⇒ Object



30
31
32
33
# File 'app/helpers/spotlight/meta_helper.rb', line 30

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

#browse_opengraph_content(browse) ⇒ Object



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

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



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

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



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

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



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

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



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

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



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

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



18
19
20
# File 'app/helpers/spotlight/meta_helper.rb', line 18

def meta_image
  current_exhibit.thumbnail.iiif_url
end

#page_opengraph_content(page) ⇒ Object



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

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



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

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