Module: InvisibleCaptcha
- Defined in:
- lib/invisible_captcha.rb,
lib/invisible_captcha/railtie.rb,
lib/invisible_captcha/version.rb,
lib/invisible_captcha/form_helpers.rb,
lib/invisible_captcha/view_helpers.rb,
lib/invisible_captcha/controller_ext.rb
Defined Under Namespace
Modules: ControllerExt, FormHelpers, ViewHelpers
Classes: Railtie
Constant Summary
collapse
- VERSION =
"0.12.1"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.honeypots ⇒ Object
Returns the value of attribute honeypots.
12
13
14
|
# File 'lib/invisible_captcha.rb', line 12
def honeypots
@honeypots
end
|
.injectable_styles ⇒ Object
Returns the value of attribute injectable_styles.
12
13
14
|
# File 'lib/invisible_captcha.rb', line 12
def injectable_styles
@injectable_styles
end
|
.sentence_for_humans ⇒ Object
39
40
41
|
# File 'lib/invisible_captcha.rb', line 39
def sentence_for_humans
call_lambda_or_return(@sentence_for_humans)
end
|
.timestamp_enabled ⇒ Object
Returns the value of attribute timestamp_enabled.
12
13
14
|
# File 'lib/invisible_captcha.rb', line 12
def timestamp_enabled
@timestamp_enabled
end
|
.timestamp_error_message ⇒ Object
43
44
45
|
# File 'lib/invisible_captcha.rb', line 43
def timestamp_error_message
call_lambda_or_return(@timestamp_error_message)
end
|
.timestamp_threshold ⇒ Object
Returns the value of attribute timestamp_threshold.
12
13
14
|
# File 'lib/invisible_captcha.rb', line 12
def timestamp_threshold
@timestamp_threshold
end
|
.visual_honeypots ⇒ Object
Returns the value of attribute visual_honeypots.
12
13
14
|
# File 'lib/invisible_captcha.rb', line 12
def visual_honeypots
@visual_honeypots
end
|
Class Method Details
.css_strategy ⇒ Object
63
64
65
66
67
68
69
|
# File 'lib/invisible_captcha.rb', line 63
def css_strategy
[
"display:none;",
"position:absolute!important;top:-9999px;left:-9999px;",
"position:absolute!important;height:1px;width:1px;overflow:hidden;"
].sample
end
|
.generate_random_honeypot ⇒ Object
55
56
57
|
# File 'lib/invisible_captcha.rb', line 55
def generate_random_honeypot
"abcdefghijkl-mnopqrstuvwxyz".chars.sample(rand(10..20)).join
end
|
.get_honeypot ⇒ Object
59
60
61
|
# File 'lib/invisible_captcha.rb', line 59
def get_honeypot
honeypots.sample
end
|
.init! ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/invisible_captcha.rb', line 18
def init!
self.sentence_for_humans = -> { I18n.t('invisible_captcha.sentence_for_humans', default: 'If you are a human, ignore this field') }
self.timestamp_enabled = true
self.timestamp_threshold = 4
self.timestamp_error_message = -> { I18n.t('invisible_captcha.timestamp_error_message', default: 'Sorry, that was too quick! Please resubmit.') }
self.visual_honeypots = false
self.injectable_styles = false
end
|
.setup {|_self| ... } ⇒ Object
47
48
49
|
# File 'lib/invisible_captcha.rb', line 47
def setup
yield(self) if block_given?
end
|