Skip to content

Commit

Permalink
added README and performed minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
benwyrosdick committed Mar 25, 2008
1 parent 7a77cbe commit 92817d7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 0 additions & 2 deletions LICENSE
@@ -1,5 +1,3 @@


The MIT license:
Copyright (c) 2008 Less Everything, Inc.

Expand Down
11 changes: 11 additions & 0 deletions README
@@ -0,0 +1,11 @@
Less Captcha creates a user friendly, bot unfriendly image CAPTCHA alternative

== In the model

class User < ActiveRecord::Base
validates_captcha
end

== In the view

<%= captcha_field("user") %>
6 changes: 2 additions & 4 deletions lib/less_captcha.rb
Expand Up @@ -56,9 +56,8 @@ module Helper
#
# the following HTML will be generated. The hidden field contains an encrypted version of the answer
#
# <p class="less_captcha">Challenge Question</p>
# <input type="hidden" name="entry[captcha_answer]" value="..." />
# <input type="text" name="entry[captcha]" />
# <input type="hidden" name="entry[captcha_answer]" value="..." />
#
# You can use the +options+ argument to pass additional options to the text-field tag.
def captcha_field(object, options={})
Expand All @@ -69,9 +68,8 @@ def captcha_field(object, options={})
answer = a.send(op, b)
eval("@"+object.to_s).setup_captcha(answer)

result = "<label class=\"less_captcha\">#{question}</label>"
result = ActionView::Helpers::InstanceTag.new(object, PREFIX, self).to_input_field_tag("text", options)
result << ActionView::Helpers::InstanceTag.new(object, PREFIX + SUFFIX, self).to_input_field_tag("hidden", {})
result << ActionView::Helpers::InstanceTag.new(object, PREFIX, self).to_input_field_tag("text", options)
end
end
end
Expand Down

0 comments on commit 92817d7

Please sign in to comment.