zero-captcha 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32ca6d981dce7e6d0d1aedb7b3ea4d334c1dcbce
4
- data.tar.gz: 134f7fe4f76a173cb2f3c244e0ea6a1603dd3efd
3
+ metadata.gz: 8cc1354b1cfe9986385d427df31fc6dd85fe7b5d
4
+ data.tar.gz: 82286979f4d2ead6a0a6d6fe8a1b78743e01de6d
5
5
  SHA512:
6
- metadata.gz: 3972b53a08f9d071080b5d1cde2d1478fa913089b1210e9ec7ff22ffedab79244a5530e8d487b156a7ea04588e534ecfeb3d8d044d62c0097ec042d302bd8068
7
- data.tar.gz: 00a5818fed16ac1c45865117ad333392dc51db689a078e9b65845a47ad14c8c07af7a0cafc75c566d05934746efeac272ded185bdf6bec88c20815ebfca2fcb0
6
+ metadata.gz: d4ce1a8a0f94caa2cec5159f838bf63d5e24feb05dde790fa741527b4749f119d6dcf92faa4e6d04f5ae4e082a9f46d524372d340183dc9f940fd248b2e2b290
7
+ data.tar.gz: 0fb678437d7d9ced856f25ff82634ed5462e1ff9a6842d3168a2290965e55f9bad3a8abd2e2d8cd50130b318d8fd1a824226ee28e1b3db80398d892ce1c70ae7
data/.document CHANGED
@@ -1,5 +1,5 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore CHANGED
@@ -1,22 +1,22 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
22
- *.gem
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
22
+ *.gem
data/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License
2
-
3
- Copyright (c) 2014 Lu Wang
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1
+ The MIT License
2
+
3
+ Copyright (c) 2014 Lu Wang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
21
  THE SOFTWARE.
@@ -1,53 +1,61 @@
1
- # Zero Captcha
2
-
3
- **The simplest way to add a zero friction captcha in your Rails forms.**
4
-
5
- A zero captcha works off the idea that most simple bots do not run a full
6
- JavaScript interpreter when crawling web forms, so they are unable to fill a
7
- required field whereas the required field is actually hidden and autopopulated
8
- by JavaScript in a real browser with a real human. This means having a layer of
9
- spam protection while maintaining zero friction.
10
-
11
- This should not be used solely by itself, but can be useful as an extra layer
12
- of defense alongside honeypot captchas and/or more traditional captchas.
13
-
14
- ## Requirements
15
-
16
- Requires jQuery on running on the client side.
17
-
18
- ## Installation
19
-
20
- In your Gemfile, simply add
21
-
22
- gem 'zero-captcha'
23
-
24
- ## Usage
25
-
26
- ### form_for
27
-
28
- Simply specify that the form has a honeypot in the HTML options hash:
29
-
30
- <% form_for Comment.new, :html => { :zero_captcha => true } do |form| -%>
31
- ...
32
- <% end -%>
33
-
34
- ### form_tag with block
35
-
36
- Simply specify that the form has a honeypot in the options hash:
37
-
38
- <% form_tag comments_path, :zero_captcha => true do -%>
39
- ...
40
- <% end -%>
41
-
42
- ### form_tag without block
43
-
44
- Simply specify that the form has a honeypot in the options hash:
45
-
46
- <%= form_tag comments_path, :zero_captcha => true -%>
47
- ...
48
- </form>
49
-
50
-
51
- ## Copyright
52
-
53
- See LICENSE for details.
1
+ # Zero Captcha
2
+
3
+ **The simplest way to add a zero friction captcha in your Rails forms.**
4
+
5
+ A zero captcha works off the idea that most simple bots do not run a full
6
+ JavaScript interpreter when crawling web forms, so they are unable to fill a
7
+ required field whereas the required field is actually hidden and autopopulated
8
+ by JavaScript in a real browser with a real human. This means having a layer of
9
+ spam protection while maintaining zero friction.
10
+
11
+ This should not be used solely by itself, but can be useful as an extra layer
12
+ of defense alongside honeypot captchas and/or more traditional captchas.
13
+
14
+ ## Requirements
15
+
16
+ Requires jQuery on running on the client side.
17
+
18
+ ## Installation
19
+
20
+ In your Gemfile, simply add
21
+
22
+ gem 'zero-captcha'
23
+
24
+ ## Usage
25
+
26
+ ### form_for
27
+
28
+ Simply specify that the form has a honeypot in the HTML options hash:
29
+
30
+ <% form_for Comment.new, html: { zero_captcha: true } do |form| -%>
31
+ ...
32
+ <% end -%>
33
+
34
+ ### form_tag with block
35
+
36
+ Simply specify that the form has a honeypot in the options hash:
37
+
38
+ <% form_tag comments_path, zero_captcha: true do -%>
39
+ ...
40
+ <% end -%>
41
+
42
+ ### form_tag without block
43
+
44
+ Simply specify that the form has a honeypot in the options hash:
45
+
46
+ <%= form_tag comments_path, zero_captcha: true -%>
47
+ ...
48
+ </form>
49
+
50
+ ## Addition Usage
51
+
52
+ By default, zero-captcha works by checking against a verify value __if__ provided. If not provided, zero captcha will not activate.
53
+
54
+ However, if you wish to force the presence of a zero-captcha value, you may use this in your controller:
55
+
56
+ `prepend_before_filter :require_zero_captcha, only: [:create]`
57
+
58
+
59
+ ## Copyright
60
+
61
+ See LICENSE for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.3
@@ -1,23 +1,27 @@
1
- require 'zero-captcha/form_tag_helper'
2
-
3
- module ZeroCaptcha
4
- module SpamProtection
5
- def zero_captcha_fields
6
- { :_zc_field => '5b5cd0da3121fc53b4bc84d0c8af2e81' } # change this in controller by overriding `zero_captcha_fields`
7
- end
8
-
9
- def protect_from_spam_with_zero_captcha
10
- head :ok if zero_captcha_fields.any? { |name, value| params[name] && params[name] != value }
11
- end
12
-
13
- def self.included(base) # :nodoc:
14
- base.send :helper_method, :zero_captcha_fields
15
-
16
- if base.respond_to? :before_filter
17
- base.send :prepend_before_filter, :protect_from_spam_with_zero_captcha, :only => [:create, :update]
18
- end
19
- end
20
- end
21
- end
22
-
23
- ActionController::Base.send(:include, ZeroCaptcha::SpamProtection) if defined?(ActionController::Base)
1
+ require 'zero-captcha/form_tag_helper'
2
+
3
+ module ZeroCaptcha
4
+ module SpamProtection
5
+ def zero_captcha_fields
6
+ { :_zc_field => '5b5cd0da3121fc53b4bc84d0c8af2e81' } # change this in controller by overriding `zero_captcha_fields`
7
+ end
8
+
9
+ def protect_from_spam_with_zero_captcha
10
+ head :ok if zero_captcha_fields.any? { |name, value| params[name] && params[name] != value }
11
+ end
12
+
13
+ def require_zero_captcha
14
+ head :ok if zero_captcha_fields.any? { |name, value| !params.has_key?(name) }
15
+ end
16
+
17
+ def self.included(base) # :nodoc:
18
+ base.send :helper_method, :zero_captcha_fields
19
+
20
+ if base.respond_to? :before_filter
21
+ base.send :prepend_before_filter, :protect_from_spam_with_zero_captcha, :only => [:create, :update]
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ ActionController::Base.send(:include, ZeroCaptcha::SpamProtection) if defined?(ActionController::Base)
@@ -1,33 +1,33 @@
1
- # Override the form_tag helper to add zero captcha spam protection to forms.
2
- module ActionView
3
- module Helpers
4
- module FormTagHelper
5
- def form_tag_html_with_zero_captcha(options)
6
- zero_captcha = options.delete(:zero_captcha) || options.delete('zero_captcha')
7
- html = form_tag_html_without_zero_captcha(options)
8
- if zero_captcha
9
- captcha = "".respond_to?(:html_safe) ? zero_captcha_html.html_safe : zero_captcha
10
- if block_given?
11
- html.insert(html.index('</form>'), captcha)
12
- else
13
- html += captcha
14
- end
15
- end
16
- html
17
- end
18
- alias_method_chain :form_tag_html, :zero_captcha
19
-
20
- private
21
- def zero_captcha_html
22
- zero_captcha_fields.collect do |name, value|
23
- content_tag :div do
24
- hidden_field_tag(name, 'verify') +
25
- javascript_tag do
26
- "jQuery('input[name=#{name}]').val('#{value}')".html_safe
27
- end
28
- end
29
- end.join
30
- end
31
- end
32
- end
33
- end
1
+ # Override the form_tag helper to add zero captcha spam protection to forms.
2
+ module ActionView
3
+ module Helpers
4
+ module FormTagHelper
5
+ def form_tag_html_with_zero_captcha(options)
6
+ zero_captcha = options.delete(:zero_captcha) || options.delete('zero_captcha')
7
+ html = form_tag_html_without_zero_captcha(options)
8
+ if zero_captcha
9
+ captcha = "".respond_to?(:html_safe) ? zero_captcha_html.html_safe : zero_captcha
10
+ if block_given?
11
+ html.insert(html.index('</form>'), captcha)
12
+ else
13
+ html += captcha
14
+ end
15
+ end
16
+ html
17
+ end
18
+ alias_method_chain :form_tag_html, :zero_captcha
19
+
20
+ private
21
+ def zero_captcha_html
22
+ zero_captcha_fields.collect do |name, value|
23
+ content_tag :div do
24
+ hidden_field_tag(name, 'verify') +
25
+ javascript_tag do
26
+ "jQuery('input[name=#{name}]').val('#{value}')".html_safe
27
+ end
28
+ end
29
+ end.join
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,40 +1,40 @@
1
- # -*- encoding: utf-8 -*-
2
- Gem::Specification.new do |s|
3
- s.name = %q{zero-captcha}
4
- s.version = "0.0.2"
5
-
6
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
7
- s.authors = ['lunaru']
8
- s.date = %q{2014-10-25}
9
- s.description = %q{A simple way to add zero friction captchas to Rails forms}
10
- s.extra_rdoc_files = [
11
- "LICENSE",
12
- "README.markdown"
13
- ]
14
- s.files = [
15
- ".document",
16
- ".gitignore",
17
- "LICENSE",
18
- "README.markdown",
19
- "VERSION",
20
- "zero-captcha.gemspec",
21
- "lib/zero-captcha.rb",
22
- "lib/zero-captcha/form_tag_helper.rb"
23
- ]
24
- s.homepage = %q{http://github.com/lunaru/rails-zero-captcha}
25
- s.rdoc_options = ["--charset=UTF-8"]
26
- s.require_paths = ["lib"]
27
- s.rubygems_version = %q{1.3.6}
28
- s.summary = %q{A simple way to add zero friction captchas to Rails forms}
29
-
30
- if s.respond_to? :specification_version then
31
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
32
- s.specification_version = 3
33
-
34
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
35
- else
36
- end
37
- else
38
- end
39
- end
40
-
1
+ # -*- encoding: utf-8 -*-
2
+ Gem::Specification.new do |s|
3
+ s.name = %q{zero-captcha}
4
+ s.version = "0.0.3"
5
+
6
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
7
+ s.authors = ['lunaru']
8
+ s.date = %q{2014-10-25}
9
+ s.description = %q{A simple way to add zero friction captchas to Rails forms}
10
+ s.extra_rdoc_files = [
11
+ "LICENSE",
12
+ "README.markdown"
13
+ ]
14
+ s.files = [
15
+ ".document",
16
+ ".gitignore",
17
+ "LICENSE",
18
+ "README.markdown",
19
+ "VERSION",
20
+ "zero-captcha.gemspec",
21
+ "lib/zero-captcha.rb",
22
+ "lib/zero-captcha/form_tag_helper.rb"
23
+ ]
24
+ s.homepage = %q{http://github.com/lunaru/rails-zero-captcha}
25
+ s.rdoc_options = ["--charset=UTF-8"]
26
+ s.require_paths = ["lib"]
27
+ s.rubygems_version = %q{1.3.6}
28
+ s.summary = %q{A simple way to add zero friction captchas to Rails forms}
29
+
30
+ if s.respond_to? :specification_version then
31
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
32
+ s.specification_version = 3
33
+
34
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
35
+ else
36
+ end
37
+ else
38
+ end
39
+ end
40
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zero-captcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - lunaru
@@ -18,35 +18,35 @@ extra_rdoc_files:
18
18
  - LICENSE
19
19
  - README.markdown
20
20
  files:
21
- - .document
22
- - .gitignore
21
+ - ".document"
22
+ - ".gitignore"
23
23
  - LICENSE
24
24
  - README.markdown
25
25
  - VERSION
26
- - zero-captcha.gemspec
27
26
  - lib/zero-captcha.rb
28
27
  - lib/zero-captcha/form_tag_helper.rb
28
+ - zero-captcha.gemspec
29
29
  homepage: http://github.com/lunaru/rails-zero-captcha
30
30
  licenses: []
31
31
  metadata: {}
32
32
  post_install_message:
33
33
  rdoc_options:
34
- - --charset=UTF-8
34
+ - "--charset=UTF-8"
35
35
  require_paths:
36
36
  - lib
37
37
  required_ruby_version: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  required_rubygems_version: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - '>='
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
47
  requirements: []
48
48
  rubyforge_project:
49
- rubygems_version: 2.0.14
49
+ rubygems_version: 2.2.2
50
50
  signing_key:
51
51
  specification_version: 3
52
52
  summary: A simple way to add zero friction captchas to Rails forms