Skip to content
Browse files

Merging branch scambra

  • Loading branch information...
2 parents 3629f1c + 2f68a51 commit ce58e8f6c5479c157553c24d7d5280e6f3590511 @subwindow committed
Showing with 10 additions and 10 deletions.
  1. +2 −2 lib/negative_captcha.rb
  2. +8 −8 lib/negative_captcha_view_helpers.rb
View
4 lib/negative_captcha.rb
@@ -11,10 +11,10 @@ class NegativeCaptcha
def initialize(opts)
@secret = opts[:secret]||MD5.hexdigest("this_is_a_secret_key")
- @spinner = MD5.hexdigest(([timestamp, @secret] + (opts[:spinner].is_a?(Array) ? opts[:spinner] : [opts[:spinner]]))*'-')
+ @timestamp = opts[:params][:timestamp] || Time.now()
+ @spinner = MD5.hexdigest(([@timestamp, @secret] + (opts[:spinner].is_a?(Array) ? opts[:spinner] : [opts[:spinner]]))*'-')
@message = opts[:message]||"Please try again. This usually happens because an automated script attempted to submit this form."
@fields = opts[:fields].inject({}){|hash, field_name| hash[field_name] = MD5.hexdigest([field_name, @spinner, @secret]*'-'); hash }
- @timestamp = Time.now()
@values = {}
@error = "No params provided"
process(opts[:params]) if opts[:params] && (opts[:params][:spinner]||opts[:params][:timestamp])
View
16 lib/negative_captcha_view_helpers.rb
@@ -7,17 +7,17 @@ def negative_captcha(captcha)
end
def negative_text_field_tag(negative_captcha, field, options={})
- [
- text_field_tag(negative_captcha.fields[field], negative_captcha.values[field], options),
- "<div style='position: absolute; left: -2000px;'>" + text_field_tag(field, '', :tabindex => '999') + "</div>"
- ].join
+ text_field_tag(negative_captcha.fields[field], negative_captcha.values[field], options) +
+ content_tag('div', :style => 'position: absolute; left: -2000px;') {
+ text_field_tag(field, '', :tabindex => '999', :autocomplete => 'off')
+ }
end
def negative_text_area_tag(negative_captcha, field, options={})
- [
- text_area_tag(negative_captcha.fields[field], negative_captcha.values[field] || options[:value], options),
- "<div style='position: absolute; left: -2000px;'>" + text_area_tag(field, '', :tabindex => '999', :rows => 2, :cols => 1) + "</div>"
- ].join
+ text_area_tag(negative_captcha.fields[field], negative_captcha.values[field], options) +
+ content_tag('div', :style => 'position: absolute; left: -2000px;') {
+ text_area_tag(field, '', :tabindex => '999', :autocomplete => 'off')
+ }
end
def negative_hidden_field_tag(negative_captcha, field, options={})

0 comments on commit ce58e8f

Please sign in to comment.
Something went wrong with that request. Please try again.