Sha256: 3070438a1b897348cbdd485e343985fa4a03fe0bba0b137bd68187196f03abf8
Contents?: true
Size: 1.98 KB
Versions: 6
Compression:
Stored size: 1.98 KB
Contents
module Pageflow module SocialShareHelper 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 def social_share_page_url(page) "#{pretty_entry_url(page.chapter.entry)}?page=#{page.perma_id}" end 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 def social_share_page_description(page, entry) 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 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 def social_share_entry_image_tags(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 def social_share_normalize_protocol(url) url.gsub(/^(\/\/|https:\/\/)/, 'http://') end private def social_share_sanitize(text) strip_tags(text.gsub(/<br ?\/?>/, ' ').squish) end end end
Version data entries
6 entries across 6 versions & 1 rubygems