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
- #custom_google_plus_button(options = (), &block) ⇒ Object
- #google_plus_profile_url(user_id = nil) ⇒ Object
- #plus_one_button(options = {}) ⇒ Object
Methods included from Base
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 ( = (), &block) defaults = { url: default_url, class: 'custom-google-plus-button', target: '_blank', label: "label" } settings = defaults.merge() 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 ( = {}) size = [:size] || nil annotation = [:annotation] || 'inline' width = [:width] || 300 class_list = [:class] || 'g-plusone' href = [:href] || request.url callback = [: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 content_tag :div, '', class: class_list, data: data_attr end |