Module: Flakey::GooglePlus

Includes:
Base
Defined in:
lib/flakey/google_plus.rb

Constant Summary collapse

BASE_URL =
"https://plus.google.com"

Instance Method Summary collapse

Methods included from Base

#default_url

Instance Method Details

#custom_google_plus_button(options = (), &block) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/flakey/google_plus.rb', line 30

def custom_google_plus_button(options = (), &block)
  defaults = {
    url: default_url,
    class: 'custom-google-plus-button',
    target: '_blank',
    label: "label"
  }
  settings = defaults.merge(options)
  label = settings.delete(:label)
  url = "#{BASE_URL}/share?url=#{CGI.escape(settings[:url])}"
  settings.delete(:url)

  if block_given?
    link_to(url, settings, &block)
  else
    link_to label, url, settings
  end
end

#google_plus_profile_url(user_id = nil) ⇒ Object



25
26
27
28
# File 'lib/flakey/google_plus.rb', line 25

def google_plus_profile_url(user_id = nil)
  user_id = user_id || Flakey.configuration.google_plus_user_id
  BASE_URL + "/#{user_id}"
end

#plus_one_button(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/flakey/google_plus.rb', line 8

def plus_one_button(options = {})
  size = options[:size] || nil
  annotation = options[:annotation] || 'inline'
  width = options[:width] || 300
  class_list = options[:class] || 'g-plusone'
  href = options[:href] || request.url
  callback = options[:callback] || nil

  data_attr = { annotation: annotation, href: href }
  # Width only applies to the 'inline' annotation type.
  data_attr.merge!(width: width) if annotation == 'inline'
  data_attr.merge!(size: size) if size
  data_attr.merge!(callback: callback) if callback

   :div, '', class: class_list, data: data_attr
end