hostily-captcha 0.1.0 → 0.2.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
  SHA256:
3
- metadata.gz: 8647978872b4be39152495b93f3d573eaf0a05fef1f56edb6c921339a90d8c3b
4
- data.tar.gz: cc9099a1f4326fcff2cbfd6b1acfa4d37c5fe190ee4a46952d8c185ffeeb0b3c
3
+ metadata.gz: 0aa8b104a4af82b847819ae733494eb44232710cd050d4750c5a2d92e5fe0ff1
4
+ data.tar.gz: b2de93f6541a5ea7e78b2fea9dfba21d3eca3d92383bd20416870f34092255d6
5
5
  SHA512:
6
- metadata.gz: 171ff9e945d6fc22013145bddf1e3a542bb7c02fa2af3c1598cf7d6c84dca46bef8a950661caefb0882838ffe9f6b709daee206109115bdcc362eb616169b2ac
7
- data.tar.gz: 8db216a736510f450334cd9afeb3f2773da9bd0a628e2799d48c57df23e0afe30d5b9edaa03dc31eba6ac1b84e0ec03cbfb642fedd1ef5e2499853781c5ef067
6
+ metadata.gz: b553e8f4f7f173e92e7300837a4f6abf64c7a2a082867e75730a099e1fa7054c28a3726afcd32e4d0dae80a7bb5bf08e96aad260a17fd429edafb236d689f059
7
+ data.tar.gz: 3e38a9959f26540a5d47b28854ab765082f595c6e2064beb053bc804cac84078d38b2c7ba5ea17e4eb690953f5e8e3b6db90bc2c93ce0ae8405ecc585d9ad129
data/README.md CHANGED
@@ -29,7 +29,7 @@ Hostily::Captcha.configure do |c|
29
29
  c.site_key = "…" # öffentlich
30
30
  c.secret = ENV["HOSTILY_CAPTCHA_SECRET"] # nur auf dem Server
31
31
  # c.endpoint = "https://captcha.hostily.de" # Vorgabe
32
- # c.modus = "sichtbar" | "unsichtbar"; c.sprache = "de" | "en" (Vorgabe: Seitensprache)
32
+ # c.modus = "sichtbar" | "unsichtbar" | "halten" | "schieben" | "portal"; c.haltezeit = 1500 (ms, nur halten); c.sprache = "de" | "en" (Vorgabe: Seitensprache)
33
33
  # c.fail_open = true # Dienst down: durchlassen (Vorgabe); false = blockieren
34
34
  end
35
35
  ```
@@ -37,7 +37,7 @@ end
37
37
  ```erb
38
38
  <%= form_with url: contact_path do |f| %>
39
39
  …
40
- <%= hostily_captcha_tag %> <%# Widget + Skript; Optionen: site_key:, modus:, sprache:, api:, script: false %>
40
+ <%= hostily_captcha_tag %> <%# Widget + Skript; Optionen: site_key:, modus:, haltezeit:, sprache:, api:, script: false %>
41
41
  <% end %>
42
42
  ```
43
43
 
@@ -4,14 +4,21 @@ module Hostily
4
4
  module Captcha
5
5
  # View helper: <%= hostily_captcha_tag %> inside the <form>. Settings come from Hostily::Captcha.configuration.
6
6
  module ViewHelper
7
- # Widget element (and, unless script: false, the widget script). Options: site_key, modus, sprache, api.
8
- def hostily_captcha_tag(site_key: nil, modus: nil, sprache: nil, api: nil, script: true)
7
+ # Widget element (and, unless script: false, the widget script). Options: site_key, modus, haltezeit, sprache, api.
8
+ # modus: "sichtbar", "unsichtbar", "halten", "schieben"; "portal" (or false) leaves data-modus out, then the mode of the
9
+ # project in the customer portal applies. haltezeit (ms, 800-3000) is only used with "halten".
10
+ def hostily_captcha_tag(site_key: nil, modus: nil, haltezeit: nil, sprache: nil, api: nil, script: true)
9
11
  c = Hostily::Captcha.configuration
10
12
  key = site_key || c.site_key
11
13
  return hostily_captcha_html("") if key.to_s.empty? # not configured: nothing to show
12
14
 
13
15
  base = (api || c.endpoint).to_s.sub(%r{/+\z}, "")
14
- attrs = { "data-site-key" => key, "data-api" => "#{base}/api/", "data-modus" => modus || c.modus }
16
+ attrs = { "data-site-key" => key, "data-api" => "#{base}/api/" }
17
+ m = modus.nil? ? c.modus : modus
18
+ m = m.to_s
19
+ attrs["data-modus"] = m unless m.empty? || m == "portal" || m == "false"
20
+ ht = haltezeit || c.haltezeit
21
+ attrs["data-haltezeit"] = ht.to_i.clamp(800, 3000) if ht && m == "halten"
15
22
  sp = sprache || c.sprache
16
23
  attrs["data-sprache"] = sp if sp
17
24
  html = +""
@@ -1,5 +1,5 @@
1
1
  module Hostily
2
2
  module Captcha
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -5,12 +5,13 @@ require "hostily/captcha/rails"
5
5
  module Hostily
6
6
  module Captcha
7
7
  class Configuration
8
- attr_accessor :secret, :site_key, :endpoint, :timeout, :modus, :sprache, :fail_open
8
+ attr_accessor :secret, :site_key, :endpoint, :timeout, :modus, :haltezeit, :sprache, :fail_open
9
9
 
10
10
  def initialize
11
11
  @endpoint = DEFAULT_ENDPOINT
12
12
  @timeout = 5.0
13
13
  @modus = "sichtbar"
14
+ @haltezeit = nil # ms (800-3000), only for modus "halten"; nil: the widget default (1500)
14
15
  @sprache = nil # nil: the widget decides (page language)
15
16
  @fail_open = true # service down: let the request pass (false: block)
16
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hostily-captcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - connect - Media & Teledienst
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-30 00:00:00.000000000 Z
11
+ date: 2026-11-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Verify the token of a submitted form against hostily Captcha. Net::HTTP
14
14
  only; optional Rails view helper and controller method.