recaptcha 4.2.0 → 4.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/recaptcha/client_helper.rb +24 -17
- data/lib/recaptcha/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91a422cb91f169dd8b16d4c2aaabaf8d8501dc2f
|
4
|
+
data.tar.gz: 11a287fd4d8ef0274af222feef7c77bfbb6f2c38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 480304f23c3411ad9386b7eb7e99846b26ccc4667d8bec27ebdf02bbd7b398736939996118d0ed0b37753af6b1c75a77c4fd4bfa61b3b1c9a9207bd399cc4087
|
7
|
+
data.tar.gz: 3ff8277354b3b38306d80ba10f39b91bc7036eef99f8478f106656f53a97f5d5d9d29daf309b2cbb8306542d0a24ba6671e9d50bc848402075a7acdae2c18090
|
@@ -10,10 +10,12 @@ module Recaptcha
|
|
10
10
|
raise(RecaptchaError, "SSL is now always true. Please remove 'ssl' from your calls to recaptcha_tags.")
|
11
11
|
end
|
12
12
|
|
13
|
+
noscript = options.delete(:noscript)
|
14
|
+
|
13
15
|
html, tag_attributes, fallback_uri = Recaptcha::ClientHelper.recaptcha_components(options)
|
14
16
|
html << %(<div #{tag_attributes}></div>\n)
|
15
17
|
|
16
|
-
if
|
18
|
+
if noscript != false
|
17
19
|
html << <<-HTML
|
18
20
|
<noscript>
|
19
21
|
<div>
|
@@ -45,32 +47,37 @@ module Recaptcha
|
|
45
47
|
|
46
48
|
# Invisible reCAPTCHA implementation
|
47
49
|
def invisible_recaptcha_tags(options = {})
|
50
|
+
text = options.delete(:text)
|
48
51
|
html, tag_attributes = Recaptcha::ClientHelper.recaptcha_components(options)
|
49
|
-
|
52
|
+
|
53
|
+
html << %(<button type="submit" #{tag_attributes}>#{text}</button>\n)
|
50
54
|
html.respond_to?(:html_safe) ? html.html_safe : html
|
51
55
|
end
|
52
56
|
|
53
57
|
def self.recaptcha_components(options = {})
|
54
|
-
site_key = options
|
55
|
-
|
56
|
-
|
58
|
+
site_key = options.delete(:site_key) || Recaptcha.configuration.site_key!
|
59
|
+
html = ""
|
60
|
+
attributes = {
|
61
|
+
class: ["g-recaptcha", options.delete(:class)].join(" ")
|
62
|
+
}
|
57
63
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
64
|
+
hl = options.delete(:hl)
|
65
|
+
script_url = Recaptcha.configuration.api_server_url
|
66
|
+
script_url += "?hl=#{hl}" unless hl.to_s == ""
|
67
|
+
html << %(<script src="#{script_url}" async defer></script>\n) unless options.delete(:script) == false
|
68
|
+
fallback_uri = "#{script_url.chomp('.js')}/fallback?k=#{site_key}"
|
63
69
|
|
64
|
-
|
65
|
-
|
66
|
-
|
70
|
+
# Pull out reCaptcha specific data attributes.
|
71
|
+
[:badge, :theme, :type, :callback, :expired_callback, :size].each do |data_attribute|
|
72
|
+
if value = options.delete(data_attribute)
|
73
|
+
attributes["data-#{data_attribute}"] = value
|
74
|
+
end
|
67
75
|
end
|
68
|
-
tag_attributes << %( class="g-recaptcha #{options[:class]}")
|
69
76
|
|
70
|
-
|
71
|
-
html << %(<script src="#{script_url}" async defer></script>\n) if options.fetch(:script, true)
|
77
|
+
attributes["data-sitekey"] = site_key
|
72
78
|
|
73
|
-
|
79
|
+
# Append whatever that's left of options to be attributes on the tag.
|
80
|
+
tag_attributes = attributes.merge(options).map { |k, v| %(#{k}="#{v}") }.join(" ")
|
74
81
|
|
75
82
|
[html, tag_attributes, fallback_uri]
|
76
83
|
end
|
data/lib/recaptcha/version.rb
CHANGED