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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +21 -0
- data/lib/rails_cloudflare_turnstile/version.rb +1 -1
- data/lib/rails_cloudflare_turnstile/view_helpers.rb +4 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b7659efa813de9ccb8abc20baf2a954c21a3f7d191d16260d26d796a9283ff29
|
|
4
|
+
data.tar.gz: 2c0000a022e6c692fb512f65208dae866527d3c44f9d5857d7263512aa4db759
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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).
|
|
@@ -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
|
-
|
|
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
|