Module: SocialShare::Helper

Defined in:
lib/social_share/helper.rb

Constant Summary collapse

SERVICES =
[:facebook, :twitter, :google_plus, :pinterest, :reddit, :tumblr, :stumbleupon, :email]

Instance Method Summary collapse

Instance Method Details

#email_share(title, url) ⇒ Object



15
16
17
# File 'lib/social_share/helper.rb', line 15

def email_share(title, url)
  link_to(tag(:span, class: 'ss-icon-envelope-o'), "mailto:?to=&body=#{url},&subject=#{title}", class: 'ss-button ss-email-share-button', title: 'Share to Email')
end

#facebook_share(title, url) ⇒ Object



19
20
21
# File 'lib/social_share/helper.rb', line 19

def facebook_share(title, url)
  link_to(tag(:span, class: 'ss-icon-facebook'), "http://www.facebook.com/sharer/sharer.php?u=#{url}&title=#{title}", class: 'ss-button ss-facebook-share-button', title: 'Share to Facebook')
end

#google_plus_share(title, url) ⇒ Object



23
24
25
# File 'lib/social_share/helper.rb', line 23

def google_plus_share(title, url)
  link_to(tag(:span, class: 'ss-icon-google-plus'), "http://plus.google.com/share?url=#{url}", class: 'ss-button ss-google-plus-share-button', title: 'Share to Google Plus')
end

#pinterest_share(title, url, image) ⇒ Object



27
28
29
# File 'lib/social_share/helper.rb', line 27

def pinterest_share(title, url, image)
  link_to(tag(:span, class: 'ss-icon-pinterest'), "http://pinterest.com/pin/create/button/?url=#{url}&description=#{title}&media=#{image}", class: 'ss-button ss-pinterest-share-button', title: 'Share to Pinterest')
end

#reddit_share(title, url) ⇒ Object



31
32
33
# File 'lib/social_share/helper.rb', line 31

def reddit_share(title, url)
  link_to(tag(:span, class: 'ss-icon-reddit'), "http://www.reddit.com/submit?url=#{url}&title=#{title}", class: 'ss-button ss-reddit-share-button', title: 'Share to reddit')
end

#social_share(title, url, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/social_share/helper.rb', line 5

def social_share(title, url, options = {})
  services = options[:services] || [:facebook, :twitter]
  content = generate_buttons(services, title, url, image: options[:image])
  more_services = options[:more_services] || SERVICES - services
  if more_services.present?
    content += generate_more_buttons(more_services, title, url, image: options[:image])
  end
  (:div, content.html_safe, class: 'social-share')
end

#stumbleupon_share(title, url) ⇒ Object



35
36
37
# File 'lib/social_share/helper.rb', line 35

def stumbleupon_share(title, url)
  link_to(tag(:span, class: 'ss-icon-stumbleupon'), "http://www.stumbleupon.com/submit?url=#{url}&title=#{title}", class: 'ss-button ss-stumbleupon-share-button', title: 'Share to StumbleUpon')
end

#tumblr_share(title, url) ⇒ Object



43
44
45
# File 'lib/social_share/helper.rb', line 43

def tumblr_share(title, url)
  link_to(tag(:span, class: 'ss-icon-tumblr'), "http://www.tumblr.com/share?v=3&u=#{url}&t=#{title}", class: 'ss-button ss-tumblr-share-button', title: 'Share to Tumblr')
end

#twitter_share(title, url) ⇒ Object



39
40
41
# File 'lib/social_share/helper.rb', line 39

def twitter_share(title, url)
  link_to(tag(:span, class: 'ss-icon-twitter'), "http://twitter.com/share?text=#{title}", class: 'ss-button ss-twitter-share-button', title: 'Share to Twitter')
end