Module: Octopress::Social::GooglePlus

Extended by:
GooglePlus
Included in:
GooglePlus
Defined in:
lib/octopress-social/google-plus.rb

Defined Under Namespace

Classes: Tag

Constant Summary collapse

DEFAULTS =
{
  'size'                => 'medium',
  'count_bubble'        => false,
  'share_link_text'     => 'Google+',
  'share_link_title'    => 'Share on Google+',
  'profile_link_text'   => 'Follow on Google+',
  'profile_link_title'  => 'Follow on Google+',
  'width'               => ''
}
HEIGHT =
{
  'small' => 15,
  'medium' => 20,
  'large' => 24
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#config(site = nil) ⇒ Object

Returns the value of attribute config.



7
8
9
# File 'lib/octopress-social/google-plus.rb', line 7

def config
  @config
end

#urlObject

Returns the value of attribute url.



7
8
9
# File 'lib/octopress-social/google-plus.rb', line 7

def url
  @url
end

Instance Method Details

#count(type) ⇒ Object



59
60
61
62
63
64
65
# File 'lib/octopress-social/google-plus.rb', line 59

def count(type)
  if config["#{type}_count"]
    %Q{data-annotation="bubble"}
  else
    %Q{data-annotation="none"}
  end
end

#gplus_follow_button(*args) ⇒ Object



47
48
49
# File 'lib/octopress-social/google-plus.rb', line 47

def gplus_follow_button(*args)
  %Q{<div class="g-follow" #{count('follow')} #{height} data-href="//plus.google.com/u/0/#{config['userid']}" data-rel="author"></div>}
end

#gplus_one_button(site, item) ⇒ Object



39
40
41
# File 'lib/octopress-social/google-plus.rb', line 39

def gplus_one_button(site, item)
  %Q{<div class="g-plusone" data-href="#{Social.full_url(site, item)}" #{count('share')} #{width} #{size}></div>}
end


51
52
53
54
55
56
57
# File 'lib/octopress-social/google-plus.rb', line 51

def gplus_profile_link(*args)
  %Q{<a
    class="g-plus-profile-link"
    href="//plus.google.com/u/0/#{config['userid']}"
    title="#{config['profile_link_title']}"
    >#{config['profile_link_text']}</a>}
end

#gplus_script_tag(site, item) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/octopress-social/google-plus.rb', line 87

def gplus_script_tag(site, item)
  %Q{
    <script type="text/javascript">
      #{Octopress::Social::GooglePlus.lang(item)}
      (function() {
        var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
        po.src = 'https://apis.google.com/js/platform.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
      })();
    </script>
  }
end

#gplus_share_button(site, item) ⇒ Object



43
44
45
# File 'lib/octopress-social/google-plus.rb', line 43

def gplus_share_button(site, item)
  %Q{<div class="g-plus" data-action="share" data-href="#{Social.full_url(site, item)}" #{count('share')} #{width} #{size}></div>}
end


32
33
34
35
36
37
# File 'lib/octopress-social/google-plus.rb', line 32

def gplus_share_link(site, item)
  %Q{<a 
    class="g-plus-share-link"
    href="https://plus.google.com/share?url=#{Social.full_url(site, item)}"
    title="#{config['share_link_title']}">#{config['share_link_text']}</a>}
end

#heightObject



75
76
77
# File 'lib/octopress-social/google-plus.rb', line 75

def height
  %Q{data-height="#{HEIGHT[config['size']]}"}
end

#lang(item) ⇒ Object



79
80
81
82
83
84
85
# File 'lib/octopress-social/google-plus.rb', line 79

def lang(item)
  if item['lang']
    "window.___gcfg = {lang: '#{item['lang']}'};"
  else
    ''
  end
end

#sizeObject



71
72
73
# File 'lib/octopress-social/google-plus.rb', line 71

def size
  %Q{data-size="#{config['size']}"}
end

#widthObject



67
68
69
# File 'lib/octopress-social/google-plus.rb', line 67

def width
  %Q{data-width="#{config['width']}"}
end