recaptcha 4.0.1 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cbf7a55507ca69720d10cdeead8aff77badad7b0
4
- data.tar.gz: 318b80638a10bcdc1186fd7244cc4418bbf54268
3
+ metadata.gz: 275c68afb011d4d29e5ca658017371b578826960
4
+ data.tar.gz: 0fea70c747d90519985fc733a9423e35fad8bdea
5
5
  SHA512:
6
- metadata.gz: ceb8f6095d38fd5b4b8095375b8f524545a54ea78d7d0c0c930e7ecad2da302926d48b39a3fe512dcee262822bb9e1f552f7b01cc5e3eeb6b885e76f17229723
7
- data.tar.gz: d2bd33484cace209b33229bf58db95bd3237717814952e98e39f0f8bbc32b9f85d8fa01b0c3aca037e5db337a7a1c2784754148012169502370b1eb1ebad9ddc
6
+ metadata.gz: 199a230be03b890f2c937f5edd53760e510c087faed04cb86de8a191fe3bccabfd95434193ec5cf23c350d90c3d62f949d59de2388661fd746ceada639b8aaf8
7
+ data.tar.gz: c6059bc4929ba3f85cd667efd2a29b08bf2602b409118d8fba8a6635d9988a9f934254f968fed641c29b422911f81ce813663e9e6d4ee4cf5b02f4695898a4f0
@@ -10,26 +10,8 @@ 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
- site_key = options[:site_key] || Recaptcha.configuration.site_key!
14
-
15
- script_url = Recaptcha.configuration.api_server_url
16
- script_url += "?hl=#{options[:hl]}" unless options[:hl].to_s == ""
17
- fallback_uri = "#{script_url.chomp('.js')}/fallback?k=#{site_key}"
18
-
19
- data_attributes = [:badge, :theme, :type, :callback, :expired_callback, :size]
20
- data_attributes = options.each_with_object({}) do |(k, v), a|
21
- a[k] = v if data_attributes.include?(k)
22
- end
23
- data_attributes[:sitekey] = site_key
24
- tag_attributes = data_attributes.map { |k, v| %(data-#{k.to_s.tr('_', '-')}="#{v}") }.join(" ")
25
-
26
- if id = options[:id]
27
- tag_attributes << %( id="#{id}")
28
- end
29
-
30
- html = ""
31
- html << %(<script src="#{script_url}" async defer></script>\n) if options.fetch(:script, true)
32
- html << %(<div class="g-recaptcha" #{tag_attributes}></div>\n)
13
+ html, tag_attributes, fallback_uri = Recaptcha::ClientHelper.recaptcha_components(options)
14
+ html << %(<div #{tag_attributes}></div>\n)
33
15
 
34
16
  if options[:noscript] != false
35
17
  html << <<-HTML
@@ -60,5 +42,37 @@ module Recaptcha
60
42
 
61
43
  html.respond_to?(:html_safe) ? html.html_safe : html
62
44
  end
45
+
46
+ # Invisible reCAPTCHA implementation
47
+ def invisible_recaptcha_tags(options = {})
48
+ html, tag_attributes = Recaptcha::ClientHelper.recaptcha_components(options)
49
+ html << %(<button type="submit" #{tag_attributes}>#{options[:text]}</button>\n)
50
+ html.respond_to?(:html_safe) ? html.html_safe : html
51
+ end
52
+
53
+ def self.recaptcha_components(options = {})
54
+ site_key = options[:site_key] || Recaptcha.configuration.site_key!
55
+ script_url = Recaptcha.configuration.api_server_url
56
+ script_url += "?hl=#{options[:hl]}" unless options[:hl].to_s == ""
57
+
58
+ data_attributes = [:badge, :theme, :type, :callback, :expired_callback, :size]
59
+ data_attributes = options.each_with_object({}) do |(k, v), a|
60
+ a[k] = v if data_attributes.include?(k)
61
+ end
62
+ data_attributes[:sitekey] = site_key
63
+
64
+ tag_attributes = data_attributes.map { |k, v| %(data-#{k.to_s.tr('_', '-')}="#{v}") }.join(" ")
65
+ if id = options[:id]
66
+ tag_attributes << %( id="#{id}")
67
+ end
68
+ tag_attributes << %( class="g-recaptcha #{options[:class]}")
69
+
70
+ html = ""
71
+ html << %(<script src="#{script_url}" async defer></script>\n) if options.fetch(:script, true)
72
+
73
+ fallback_uri = "#{script_url.chomp('.js')}/fallback?k=#{site_key}"
74
+
75
+ [html, tag_attributes, fallback_uri]
76
+ end
63
77
  end
64
78
  end
@@ -1,3 +1,3 @@
1
1
  module Recaptcha
2
- VERSION = "4.0.1".freeze
2
+ VERSION = "4.1.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recaptcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason L Perry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-21 00:00:00.000000000 Z
11
+ date: 2017-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json