Module: Pageflow::SocialShareHelper
- Defined in:
- app/helpers/pageflow/social_share_helper.rb
Instance Method Summary collapse
- #social_share_entry_description(entry) ⇒ Object
- #social_share_entry_image_tags(entry) ⇒ Object
- #social_share_meta_tags_for(target) ⇒ Object
- #social_share_normalize_protocol(url) ⇒ Object
- #social_share_page_description(page, entry) ⇒ Object
- #social_share_page_title(page) ⇒ Object
- #social_share_page_url(page) ⇒ Object
Instance Method Details
#social_share_entry_description(entry) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'app/helpers/pageflow/social_share_helper.rb', line 32 def (entry) return (entry.summary) if entry.summary.present? entry.pages.each do |page| return (page.configuration['text']) if page.configuration['text'].present? end '' end |
#social_share_entry_image_tags(entry) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/helpers/pageflow/social_share_helper.rb', line 41 def (entry) image_urls = [] if entry.share_image_id.present? image_urls << ImageFile.find(entry.share_image_id).thumbnail_url(:medium) else entry.pages.each do |page| if image_urls.size >= 4 break else image_urls << page.thumbnail_url(:medium) image_urls.uniq! end end end render 'pageflow/social_share/image_tags', :image_urls => image_urls end |
#social_share_meta_tags_for(target) ⇒ Object
3 4 5 6 7 8 9 |
# File 'app/helpers/pageflow/social_share_helper.rb', line 3 def (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
60 61 62 |
# File 'app/helpers/pageflow/social_share_helper.rb', line 60 def (url) url.gsub(/^(\/\/|https:\/\/)/, 'http://') end |
#social_share_page_description(page, entry) ⇒ Object
26 27 28 29 30 |
# File 'app/helpers/pageflow/social_share_helper.rb', line 26 def (page, entry) return (page.configuration['text']) if page.configuration['text'].present? return (page.configuration['description']) if page.configuration['description'].present? (entry) end |
#social_share_page_title(page) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'app/helpers/pageflow/social_share_helper.rb', line 15 def (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(page) ⇒ Object
11 12 13 |
# File 'app/helpers/pageflow/social_share_helper.rb', line 11 def (page) "#{pretty_entry_url(page.chapter.entry)}?page=#{page.perma_id}" end |