Module: Tarteaucitron::ViewHelpers
- Defined in:
- lib/tarteaucitron/view_helpers.rb
Instance Method Summary collapse
- #cookie_manager_link(text = "Gestion des cookies") ⇒ Object
- #facebook(options = {}) ⇒ Object
- #googleplus(options = {}) ⇒ Object
- #tarteaucitron(options = {}) ⇒ Object
- #twitter(options = {}) ⇒ Object
Instance Method Details
#cookie_manager_link(text = "Gestion des cookies") ⇒ Object
84 85 86 87 88 |
# File 'lib/tarteaucitron/view_helpers.rb', line 84 def (text = "Gestion des cookies") content_tag(:a, h(text), href: "javascript:tarteaucitron.userInterface.openPanel();").html_safe end |
#facebook(options = {}) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/tarteaucitron/view_helpers.rb', line 51 def facebook( = {}) = {layout: "standard", action: "like", share: "true"} = .merge() content_tag(:div, '', class: "fb-like", data: ).html_safe end |
#googleplus(options = {}) ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/tarteaucitron/view_helpers.rb', line 60 def googleplus( = {}) = {size: "small", annotation: "inline", width: "300"} = .merge() content_tag(:div, '', class: "g-plusone", data: ).html_safe end |
#tarteaucitron(options = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/tarteaucitron/view_helpers.rb', line 3 def tarteaucitron( = {}) = .with_indifferent_access result = "" ip = request.remote_ip if ["EU", "--"].include?(GeoIP.new(Rails.root.join('db', 'GeoIP.dat')).country(ip).continent_code) result += content_tag("script", '', src: "/tarteaucitron/tarteaucitron.js", type: "text/javascript") default = { "hashtag"=> "#tarteaucitron", "highPrivacy"=> false, "orientation"=> "top", "adblocker"=> false, "showAlertSmall"=> true, "cookieslist"=> true, "removeCredit"=> false, } = default if ["options"] = default.merge(["options"].with_indifferent_access) end script = "tarteaucitron.init(#{init_options.to_json});" if ["google_analytics"] script += "tarteaucitron.user.gajsUa = '#{options["google_analytics"]}';" script += "tarteaucitron.user.gajsMore = function () {};" script += "(tarteaucitron.job = tarteaucitron.job || []).push('gajs');" end if ["facebook"] script += "(tarteaucitron.job = tarteaucitron.job || []).push('facebook');" end if ["googleplus"] script += "(tarteaucitron.job = tarteaucitron.job || []).push('gplus');" end if ["twitter"] script += "(tarteaucitron.job = tarteaucitron.job || []).push('twitter');" end result += content_tag("script", script.html_safe) result.html_safe end end |
#twitter(options = {}) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/tarteaucitron/view_helpers.rb', line 69 def twitter( = {}) result = "" = {via: "twitter_username", count: "vertical", dnt: "true"} = .merge() result += content_tag(:span, '', class: "tacTwitter").html_safe result += content_tag(:a,'', href: "https://twitter.com/share", class: "twitter-share-button", data: ).html_safe result.html_safe end |