invisible_captcha 0.2.0 → 0.4.1
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.
- data/README.md +3 -5
- data/Rakefile +2 -3
- data/VERSION +1 -1
- data/invisible_captcha.gemspec +4 -4
- data/lib/invisible_captcha.rb +10 -0
- data/lib/invisible_captcha/validator.rb +1 -1
- data/lib/invisible_captcha/view_helpers.rb +14 -12
- metadata +6 -5
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Invisible Captcha
|
2
|
-
Simple protection for ActiveModel
|
2
|
+
Simple protection for ActiveModel (and ActiveRecord) instances using honeypot strategy.
|
3
3
|
|
4
4
|
## Installation
|
5
5
|
Add this line to you Gemfile:
|
@@ -20,10 +20,10 @@ In your form:
|
|
20
20
|
```ruby
|
21
21
|
<%= form_for(@topic) do |f| %>
|
22
22
|
|
23
|
-
<!-- use form helper -->
|
23
|
+
<!-- You can use form helper -->
|
24
24
|
<%= f.invisible_captcha :subtitle %>
|
25
25
|
|
26
|
-
<!-- or
|
26
|
+
<!-- or view helper -->
|
27
27
|
<%= invisible_captcha :topic, :subtitle %>
|
28
28
|
|
29
29
|
<% end %>
|
@@ -32,8 +32,6 @@ In your form:
|
|
32
32
|
In your ActiveModel:
|
33
33
|
|
34
34
|
```ruby
|
35
|
-
attr_accessor :subtitle
|
36
|
-
|
37
35
|
validates :subtitle, :invisible_captcha => true
|
38
36
|
```
|
39
37
|
|
data/Rakefile
CHANGED
@@ -13,12 +13,11 @@ require 'rake'
|
|
13
13
|
|
14
14
|
require 'jeweler'
|
15
15
|
Jeweler::Tasks.new do |gem|
|
16
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
16
|
gem.name = "invisible_captcha"
|
18
17
|
gem.homepage = "http://github.com/markets/invisible_captcha"
|
19
18
|
gem.license = "MIT"
|
20
|
-
gem.summary = %Q{Simple honeypot protection}
|
21
|
-
gem.description = %Q{Simple protection for ActiveModel
|
19
|
+
gem.summary = %Q{Simple honeypot protection for RoR apps}
|
20
|
+
gem.description = %Q{Simple protection for ActiveModel (and ActiveRecord) instances using honeypot strategy.}
|
22
21
|
gem.email = "srmarc.ai@gmail.com"
|
23
22
|
gem.authors = ["Marc Anguera Insa"]
|
24
23
|
# dependencies defined in Gemfile
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.1
|
data/invisible_captcha.gemspec
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "invisible_captcha"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Marc Anguera Insa"]
|
12
|
-
s.date = "2013-
|
13
|
-
s.description = "Simple protection for ActiveModel
|
12
|
+
s.date = "2013-08-29"
|
13
|
+
s.description = "Simple protection for ActiveModel (and ActiveRecord) instances using honeypot strategy."
|
14
14
|
s.email = "srmarc.ai@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.md"
|
@@ -30,7 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
s.licenses = ["MIT"]
|
31
31
|
s.require_paths = ["lib"]
|
32
32
|
s.rubygems_version = "1.8.24"
|
33
|
-
s.summary = "Simple honeypot protection"
|
33
|
+
s.summary = "Simple honeypot protection for RoR apps"
|
34
34
|
|
35
35
|
if s.respond_to? :specification_version then
|
36
36
|
s.specification_version = 3
|
data/lib/invisible_captcha.rb
CHANGED
@@ -2,3 +2,13 @@ GEM_PATH = File.dirname(__FILE__) + "/invisible_captcha"
|
|
2
2
|
require "#{GEM_PATH}/view_helpers.rb"
|
3
3
|
require "#{GEM_PATH}/form_helpers.rb"
|
4
4
|
require "#{GEM_PATH}/validator.rb"
|
5
|
+
|
6
|
+
module InvisibleCaptcha
|
7
|
+
|
8
|
+
mattr_accessor :sentence_for_humans
|
9
|
+
self.sentence_for_humans = 'If you are a human, ignore this field'
|
10
|
+
|
11
|
+
mattr_accessor :error_message
|
12
|
+
self.error_message = 'YOU ARE A ROBOT!'
|
13
|
+
|
14
|
+
end
|
@@ -5,22 +5,24 @@ module InvisibleCaptcha
|
|
5
5
|
build_invisible_captcha(model_name.to_s, method.to_s)
|
6
6
|
end
|
7
7
|
|
8
|
-
|
8
|
+
private
|
9
9
|
|
10
10
|
def build_invisible_captcha(model_name, method)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
text_field_tag("#{model_name}[#{method}]")
|
20
|
-
end
|
21
|
-
end.join.html_safe
|
11
|
+
label = InvisibleCaptcha.sentence_for_humans
|
12
|
+
html_id = "#{model_name}_#{Time.now.to_i}"
|
13
|
+
|
14
|
+
content_tag(:div, :id => html_id) do
|
15
|
+
insert_inline_css_for(html_id) +
|
16
|
+
label_tag("#{model_name}_#{method}", label) +
|
17
|
+
text_field_tag("#{model_name}[#{method}]")
|
18
|
+
end.html_safe
|
22
19
|
end
|
23
20
|
|
21
|
+
def insert_inline_css_for(container_id)
|
22
|
+
content_tag(:style, :type => 'text/css', :media => 'screen', :scoped => 'scoped') do
|
23
|
+
"##{container_id} { display:none; }"
|
24
|
+
end
|
25
|
+
end
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: invisible_captcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -75,7 +75,8 @@ dependencies:
|
|
75
75
|
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
|
-
description: Simple protection for ActiveModel
|
78
|
+
description: Simple protection for ActiveModel (and ActiveRecord) instances using
|
79
|
+
honeypot strategy.
|
79
80
|
email: srmarc.ai@gmail.com
|
80
81
|
executables: []
|
81
82
|
extensions: []
|
@@ -106,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
107
|
version: '0'
|
107
108
|
segments:
|
108
109
|
- 0
|
109
|
-
hash:
|
110
|
+
hash: 403370753
|
110
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
112
|
none: false
|
112
113
|
requirements:
|
@@ -118,5 +119,5 @@ rubyforge_project:
|
|
118
119
|
rubygems_version: 1.8.24
|
119
120
|
signing_key:
|
120
121
|
specification_version: 3
|
121
|
-
summary: Simple honeypot protection
|
122
|
+
summary: Simple honeypot protection for RoR apps
|
122
123
|
test_files: []
|