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
|
# File 'lib/tarteaucitron/view_helpers.rb', line 3
def tarteaucitron(options = {})
options = options.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,
}
script = "tarteaucitron.init(#{default.to_json});"
if options.has_key?("google_analytics")
script += "tarteaucitron.user.gajsUa = '#{options["google_analytics"]}';"
script += "tarteaucitron.user.gajsMore = function () {};"
script += "(tarteaucitron.job = tarteaucitron.job || []).push('gajs');"
end
if options.has_key?("facebook")
script += "(tarteaucitron.job = tarteaucitron.job || []).push('facebook');"
end
if options.has_key?("googleplus")
script += "(tarteaucitron.job = tarteaucitron.job || []).push('gplus');"
end
if options.has_key?("twitter")
script += "(tarteaucitron.job = tarteaucitron.job || []).push('twitter');"
end
result += content_tag("script", script.html_safe)
result.html_safe
end
end
|