Module: Pageflow::SocialShareHelper
Instance Method Summary
collapse
#find_file_in_entry
#page_css_class, #page_default_content, #page_has_content, #page_header, #page_media_breakpoints, #page_navigation_css_class, #page_print_image, #page_text, #page_thumbnail_file, #page_thumbnail_image_class, #page_thumbnail_url, #render_page_template, #shadow_div
#entry_css_class, #entry_file_rights, #entry_global_links, #entry_header_css_class, #entry_mobile_navigation_pages, #entry_privacy_link_url, #entry_stylesheet_link_tag, #entry_summary, #entry_theme_stylesheet_link_tag, #pretty_entry_title, #pretty_entry_url
Instance Method Details
#social_share_entry_description(entry) ⇒ Object
47
48
49
50
51
52
53
54
|
# File 'app/helpers/pageflow/social_share_helper.rb', line 47
def social_share_entry_description(entry)
return social_share_sanitize(entry.summary) if entry.summary.present?
entry.pages.each do |page|
return social_share_sanitize(page.configuration['text']) if page.configuration['text'].present?
end
''
end
|
#social_share_entry_image_tags(entry) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'app/helpers/pageflow/social_share_helper.rb', line 56
def social_share_entry_image_tags(entry)
share_images = []
image_file = find_file_in_entry(ImageFile, entry.share_image_id, entry)
if image_file
image_url = image_file.thumbnail_url(:medium)
share_images.push(image_url: image_url, width: image_file.width, height: image_file.height)
else
entry.pages.each do |page|
break if share_images.size >= 4
thumbnail_file = page_thumbnail_file(page)
next unless thumbnail_file.present?
image_url = thumbnail_file.thumbnail_url(:medium)
thumbnail_width = 1200
thumbnail_height = 630
if thumbnail_file.file.methods.include?(:width)
thumbnail_width = thumbnail_file.file.width
thumbnail_height = thumbnail_file.file.height
end
share_images.push(image_url: image_url,
width: thumbnail_width,
height: thumbnail_height)
share_images.uniq!
end
end
render 'pageflow/social_share/image_tags', share_images: share_images
end
|
#social_share_entry_url(entry) ⇒ Object
15
16
17
|
# File 'app/helpers/pageflow/social_share_helper.rb', line 15
def social_share_entry_url(entry)
entry.share_url.presence || pretty_entry_url(entry)
end
|
7
8
9
10
11
12
13
|
# File 'app/helpers/pageflow/social_share_helper.rb', line 7
def social_share_meta_tags_for(target)
if target.is_a?(Page)
render('pageflow/social_share/page_meta_tags', entry: @entry, page: @entry.share_target)
else
render('pageflow/social_share/entry_meta_tags', entry: target)
end
end
|
#social_share_normalize_protocol(url) ⇒ Object
85
86
87
|
# File 'app/helpers/pageflow/social_share_helper.rb', line 85
def social_share_normalize_protocol(url)
url.gsub(%r{^//}, 'https://')
end
|
#social_share_page_description(entry, page) ⇒ Object
41
42
43
44
45
|
# File 'app/helpers/pageflow/social_share_helper.rb', line 41
def social_share_page_description(entry, page)
return social_share_sanitize(page.configuration['text']) if page.configuration['text'].present?
return social_share_sanitize(page.configuration['description']) if page.configuration['description'].present?
social_share_entry_description(entry)
end
|
#social_share_page_title(page) ⇒ Object
30
31
32
33
34
35
36
37
38
39
|
# File 'app/helpers/pageflow/social_share_helper.rb', line 30
def social_share_page_title(page)
entry = page.chapter.entry
title = ["#{entry.title}:"]
title << page.title
title << '-' if entry.site.cname_domain.present?
title << entry.site.cname_domain
title.join(' ')
end
|
#social_share_page_url(entry, page_or_perma_id) ⇒ Object
19
20
21
22
23
24
25
26
27
28
|
# File 'app/helpers/pageflow/social_share_helper.rb', line 19
def social_share_page_url(entry, page_or_perma_id)
perma_id =
if page_or_perma_id.respond_to?(:perma_id)
page_or_perma_id.perma_id
else
page_or_perma_id
end
pretty_entry_url(entry, page: perma_id)
end
|