rails_cloudflare_turnstile 0.4.3 → 0.4.4

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
  SHA256:
3
- metadata.gz: 5c907239010ac14752bc04f8b7b7b22f6b11f9606009758c44cc7f5b25e4134e
4
- data.tar.gz: 30dc06b0e97199525d8c97c79dcad44af87769379fb269d80998d4a3b88ebe95
3
+ metadata.gz: b7659efa813de9ccb8abc20baf2a954c21a3f7d191d16260d26d796a9283ff29
4
+ data.tar.gz: 2c0000a022e6c692fb512f65208dae866527d3c44f9d5857d7263512aa4db759
5
5
  SHA512:
6
- metadata.gz: 15b5211b61fd94efc13f2839e21c79eb03c67194690399f89828b358eb0866a8a2803b5776e05f0da774fac7f99abf92ed1120d4b44a911fb590b9e4a29808d1
7
- data.tar.gz: ae5ae61b6310cc161bab6abcf1a4d89e0340e441ae2b406ac3c169ff3a29d76f1103461582328f1196df1628527f16bbf48253bb9ab78da499550b0c8b4abe4a
6
+ metadata.gz: cd34e7728bd2fd245169ccef95017a482215d5a2284ab0b49c5b2e4f48b0332fb9f12a663efb7f0da665a481121953b40bccbf7a8d72eb27c8a37ec4afa15c8a
7
+ data.tar.gz: 7d19ba263bdd0c017a05ad29a65819ab479312317aa8c727a5ee179607b45155ab7e2885cdce389d701ace526cf6ebbc3eee4a13244bef49c0d21085353aa78e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ChangeLog
2
2
  =========
3
+
4
+ 0.4.4
5
+ ----------
6
+ - Fixes bug where dynamic theme/size override via `data` attributes resulted in duplicate `data-theme` and `data-size` attributes. Now when you pass `data: {theme: "dark", size: "compact"}` to the `cloudflare_turnstile` helper, it overrides the global configuration on a per-instance basis and only outputs each attribute once. (thanks to @matt17r and @Gambitboy)
7
+
3
8
  0.4.3
4
9
  -----
5
10
  - Add support for Rails 8.1
data/README.md CHANGED
@@ -47,5 +47,26 @@ a `rescue_from` block.
47
47
  By default, in development and test mode, a special mock view will be inserted if real credentials are not present. To
48
48
  disable this, set the `mock_enabled` property of the configuration to false.
49
49
 
50
+ ## Customizing theme and size
51
+
52
+ The widget theme and size can be configured globally and overridden per instance:
53
+
54
+ **Global configuration** (set in initializer):
55
+ ```ruby
56
+ RailsCloudflareTurnstile.configure do |c|
57
+ c.size = :normal # :normal (default), :compact, or :flexible
58
+ c.theme = :dark # :auto (default), :light, or :dark
59
+ end
60
+ ```
61
+
62
+ **Per-instance override** (in your view):
63
+ ```erb
64
+ <%= cloudflare_turnstile(data: {theme: "dark"}) %>
65
+ <%= cloudflare_turnstile(data: {size: "compact"}) %>
66
+ <%= cloudflare_turnstile(data: {size: "compact", theme: "dark"}) %>
67
+ ```
68
+
69
+ Per-instance values will override the global configuration. Both strings and symbols are accepted.
70
+
50
71
  ## License
51
72
  The gem is available as open source under the terms of the [ISC License](LICENSE.txt).
@@ -1,3 +1,3 @@
1
1
  module RailsCloudflareTurnstile
2
- VERSION = "0.4.3"
2
+ VERSION = "0.4.4"
3
3
  end
@@ -32,7 +32,10 @@ module RailsCloudflareTurnstile
32
32
 
33
33
  def turnstile_div(action, data_callback: nil, **html_options)
34
34
  config = RailsCloudflareTurnstile.configuration
35
- content_tag(:div, :class => "cf-turnstile", "data-sitekey" => site_key, "data-size" => config.size, "data-action" => action, "data-callback" => data_callback, "data-theme" => config.theme, **html_options) do
35
+ size = html_options[:data]&.delete(:size) || config.size
36
+ theme = html_options[:data]&.delete(:theme) || config.theme
37
+
38
+ content_tag(:div, :class => "cf-turnstile", "data-sitekey" => site_key, "data-size" => size, "data-action" => action, "data-callback" => data_callback, "data-theme" => theme, **html_options) do
36
39
  ""
37
40
  end
38
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_cloudflare_turnstile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Brown