Module: SocialButtons::Pinit

Includes:
Assistant
Defined in:
lib/social_buttons/view_helpers/pinit.rb

Defined Under Namespace

Classes: Scripter

Constant Summary collapse

PINIT_CREATE_BUTTON =
"http://pinterest.com/pin/create/button/"
PINIT_BUTTON_IMAGE =
"http://assets.pinterest.com/images/PinExt.png"
CLASS =
"pin-it-button"
TITLE =
"Pin It"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default_optionsObject



29
30
31
32
33
# File 'lib/social_buttons/view_helpers/pinit.rb', line 29

def default_options
  @default_options ||= {
    description: "Pin Me!"
  }.merge("count-layout" => "none")
end

Instance Method Details

#pinit_button(options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/social_buttons/view_helpers/pinit.rb', line 10

def pinit_button(options = {})
  clazz = SocialButtons::Pinit
  default_options = {url: request.url, media: request.url}
  params = clazz.default_options.merge(clazz.default_options).merge(options)
  params.merge!(:class => CLASS)

  query_string  = clazz.options_to_query_string(self, params)
  option_params = params.except(:url, :media, :description)
  pinit_link    = PINIT_CREATE_BUTTON + query_string

  html = "".html_safe
  html << link_to(pinit_link, option_params) do
    image_tag PINIT_BUTTON_IMAGE, border: ("0" || options[:border]), title: (TITLE || options[:title])
  end
  html << clazz::Scripter.new(self).script
  html
end