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_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
|
# File 'app/helpers/pageflow/social_share_helper.rb', line 56
def social_share_entry_image_tags(entry)
image_urls = []
image_file = find_file_in_entry(ImageFile, entry.share_image_id)
if image_file
image_urls << image_file.thumbnail_url(:medium)
else
entry.pages.each do |page|
if image_urls.size >= 4
break
else
image_urls << page_thumbnail_url(page, :medium)
image_urls.uniq!
end
end
end
render 'pageflow/social_share/image_tags', image_urls: image_urls
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: @entry)
end
end
|
#social_share_normalize_protocol(url) ⇒ Object
76
77
78
|
# File 'app/helpers/pageflow/social_share_helper.rb', line 76
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.theming.cname_domain.present?
title << entry.theming.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
|