Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add field labels for accessibility. Fix validation error.

  • Loading branch information...
commit 7e1844438b1d04613b1f95d27e155f7be2bad4c6 1 parent 067e25f
curtis authored
View
2  Rakefile
@@ -10,7 +10,7 @@ begin
gem.email = "curtis@flatterline.com"
gem.homepage = "http://github.com/curtis/honeypot-captcha"
gem.authors = ["curtis"]
- gem.add_development_dependency "rspec", ">= 1.2.9"
+ # gem.add_development_dependency "rspec", ">= 1.2.9"
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
end
Jeweler::GemcutterTasks.new
View
2  VERSION
@@ -1 +1 @@
-0.0.1
+0.0.2
View
7 honeypot-captcha.gemspec
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = %q{honeypot-captcha}
- s.version = "0.0.1"
+ s.version = "0.0.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["curtis"]
- s.date = %q{2010-04-09}
+ s.date = %q{2010-05-23}
s.description = %q{A simple way to add honeypot captchas to Rails forms}
s.email = %q{curtis@flatterline.com}
s.extra_rdoc_files = [
@@ -38,12 +38,9 @@ Gem::Specification.new do |s|
s.specification_version = 3
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
else
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
end
else
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
end
end
View
4 lib/honeypot-captcha.rb
@@ -3,11 +3,11 @@
module HoneypotCaptcha
module SpamProtection
def honeypot_fields
- [:a_comment_body]
+ { :a_comment_body => 'Do not fill in this field' }
end
def protect_from_spam
- head :ok if honeypot_fields.any? { |f| !params[f].blank? }
+ head :ok if honeypot_fields.any? { |f,l| !params[f].blank? }
end
def self.included(base) # :nodoc:
View
15 lib/honeypot-captcha/form_tag_helper.rb
@@ -21,13 +21,16 @@ def form_tag_with_honeypot(url_for_options = {}, options = {}, *parameters_for_u
def honey_pot_captcha
html_ids = []
- honeypot_fields.collect do |f|
+ honeypot_fields.collect do |f, l|
html_ids << (html_id = "#{f}_hp_#{Time.now.to_i}")
- content_tag(:div, send([:text_field_tag, :text_area_tag][rand(2)], f), :id => html_id)
- end.join +
- content_tag(:style, :type => 'text/css', :media => 'screen') do
- "#{html_ids.map { |i| "##{i}" }.join(', ')} { display:none; }"
- end
+ content_tag :div, :id => html_id do
+ content_tag(:style, :type => 'text/css', :media => 'screen', :scoped => "scoped") do
+ "#{html_ids.map { |i| "##{i}" }.join(', ')} { display:none; }"
+ end +
+ label_tag(f, l) +
+ send([:text_field_tag, :text_area_tag][rand(2)], f)
+ end
+ end.join
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.