Module: Octopress::Social::GooglePlus
Defined Under Namespace
Classes: Tag
Constant Summary collapse
- DEFAULTS =
{ 'size' => 'medium', 'count_bubble' => false, 'share_link_text' => 'Google+', 'profile_link_text' => 'Follow on Google+', 'width' => '' }
- HEIGHT =
{ 'small' => 15, 'medium' => 20, 'large' => 24 }
Instance Method Summary collapse
- #config(site = nil) ⇒ Object
- #count(type) ⇒ Object
- #gplus_follow_button(*args) ⇒ Object
- #gplus_one_button(site, item) ⇒ Object
- #gplus_profile_link(*args) ⇒ Object
- #gplus_script_tag(site, item) ⇒ Object
- #gplus_share_button(site, item) ⇒ Object
- #gplus_share_link(site, item) ⇒ Object
- #height ⇒ Object
- #lang(item) ⇒ Object
- #size ⇒ Object
- #width ⇒ Object
Instance Method Details
#config(site = nil) ⇒ Object
20 21 22 |
# File 'lib/octopress-social/google-plus.rb', line 20 def config(site=nil) @config ||= DEFAULTS.merge(site['gplus'] || {}) end |
#count(type) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/octopress-social/google-plus.rb', line 44 def count(type) if config["#{type}_count"] %Q{data-annotation="bubble"} else %Q{data-annotation="none"} end end |
#gplus_follow_button(*args) ⇒ Object
36 37 38 |
# File 'lib/octopress-social/google-plus.rb', line 36 def (*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
28 29 30 |
# File 'lib/octopress-social/google-plus.rb', line 28 def (site, item) %Q{<div class="g-plusone" data-href="#{Social.full_url(site, item)}" #{count('share')} #{width} #{size}></div>} end |
#gplus_profile_link(*args) ⇒ Object
40 41 42 |
# File 'lib/octopress-social/google-plus.rb', line 40 def gplus_profile_link(*args) %Q{<a class="g-plus-profile-link" href="//plus.google.com/u/0/#{config['userid']}">#{config['profile_link_text']}</a>} end |
#gplus_script_tag(site, item) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/octopress-social/google-plus.rb', line 72 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
32 33 34 |
# File 'lib/octopress-social/google-plus.rb', line 32 def (site, item) %Q{<div class="g-plus" data-action="share" data-href="#{Social.full_url(site, item)}" #{count('share')} #{width} #{size}></div>} end |
#gplus_share_link(site, item) ⇒ Object
24 25 26 |
# File 'lib/octopress-social/google-plus.rb', line 24 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)}" target="_blank">#{config['share_link_text']}</a>} end |
#height ⇒ Object
60 61 62 |
# File 'lib/octopress-social/google-plus.rb', line 60 def height %Q{data-height="#{HEIGHT[config['size']]}"} end |
#lang(item) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/octopress-social/google-plus.rb', line 64 def lang(item) if item['lang'] "window.___gcfg = {lang: '#{item['lang']}'};" else '' end end |
#size ⇒ Object
56 57 58 |
# File 'lib/octopress-social/google-plus.rb', line 56 def size %Q{data-size="#{config['size']}"} end |
#width ⇒ Object
52 53 54 |
# File 'lib/octopress-social/google-plus.rb', line 52 def width %Q{data-width="#{config['width']}"} end |