Sha256: 84bb1c27e3e38b60a3e19ea4e11f6b8a7cee84442b844e3138c76890bfa96156
Contents?: true
Size: 1.22 KB
Versions: 16
Compression:
Stored size: 1.22 KB
Contents
module Pageflow module SocialShareLinksHelper include SocialShareHelper PROVIDER_URL_TEMPLATES = { email: 'mailto:?body=%{url}', facebook: 'http://www.facebook.com/sharer/sharer.php?u=%{url}', google: 'https://plus.google.com/share?url=%{url}', linked_in: 'https://www.linkedin.com/shareArticle?mini=true&url=%{url}', telegram: 'tg://msg?text=%{url}', twitter: 'https://twitter.com/intent/tweet?url=%{url}', whats_app: 'WhatsApp://send?text=%{url}' }.freeze def social_share_link(provider, entry, &block) block ||= ->() {} page_share_link_url = social_share_link_url(provider, social_share_page_url(entry, 'permaId')) data_attributes = entry.share_url.present? ? {} : {share_page: page_share_link_url} link_to(social_share_link_url(provider, social_share_entry_url(entry)), target: '_blank', tabindex: '2', class: ['share', provider], data: data_attributes, &block) end private def social_share_link_url(provider, url) return nil if url.blank? encoded_url = ERB::Util.url_encode(url) PROVIDER_URL_TEMPLATES[provider] % {url: encoded_url} end end end
Version data entries
16 entries across 16 versions & 1 rubygems