Module: SocialButtons::Helper

Defined in:
lib/social_buttons/helper.rb

Instance Method Summary collapse

Instance Method Details

#fb_like_button(options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/social_buttons/helper.rb', line 16

def fb_like_button(options={})
  href = options[:url] || request.url
  params = options.slice(:layout, :send, :width, :height, :show_faces, :action, :colorscheme, :font, :appId)
  params.reverse_merge!({:href => href,
                         :layout => 'button_count',
                         :send => false,
                         :width => 450,
                         :height => 21,
                         :show_faces => false,
                         :action => 'like', 
                         :colorscheme => 'light',
                         :font => 'verdana'
                        })

  style = "border:none; overflow:hidden; width:#{params[:width]}px; height:#{params[:height]}px;"

   :iframe, '', :src => "//www.facebook.com/plugins/like.php?#{params.to_query}",
                           :scrolling => 'no',
                           :frameborder => 0,
                           :allowTransparency => true,
                           :style => style,
                           :class => 'fb-like-btn'
end

#google_plus_button(options = {}) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/social_buttons/helper.rb', line 52

def google_plus_button(options={})
  href = options[:url] || request.url
  options = Hash[options.map {|k, v| ["data-#{k}", v] }]
  options.merge!({:class => 'g-plusone', 'data-href' => href})

   :div, '', options
end

#pin_it_button(options = {}) ⇒ Object

Pinterest button pinterest.com/about/goodies/



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

def pin_it_button(options={})
  params = options.slice(:url, :media, :description)
  params[:url] ||= request.url
  img = tag :img, :src => "//assets.pinterest.com/images/PinExt.png", :title => "Pin It", :border => "0" 
   :a, img, "href" => "http://pinterest.com/pin/create/button/?#{params.to_query}", 
                            "class" => "pin-it-button",
                            "count-layout" => "none"
end

#twitter_share_button(options = {}) ⇒ Object

Twitter button twitter.com/about/resources/buttons Options: url, via, lang, size, related, hashtags, count



43
44
45
46
47
48
# File 'lib/social_buttons/helper.rb', line 43

def twitter_share_button(options={})
  options = Hash[options.map {|k, v| ["data-#{k}", v] }]
  options.merge!({:href => 'https://twitter.com/share', :class => 'twitter-share-button'})

   :a, 'Tweet', options
end