Module: Captchator::View

Included in:
ActionView::Base
Defined in:
lib/captchator/view.rb

Instance Method Summary collapse

Instance Method Details

#captchator_imageObject



34
35
36
37
38
# File 'lib/captchator/view.rb', line 34

def captchator_image
"<img src=\"\#{captchator_image_path}\" id=\"captchator_image\" />\n"
end

#captchator_image_pathObject



30
31
32
# File 'lib/captchator/view.rb', line 30

def captchator_image_path
  File.join("http://captchator.com/captcha/image", captchator_session_id)
end

#captchator_inputObject



15
16
17
# File 'lib/captchator/view.rb', line 15

def captchator_input
  text_field_tag(:captchator_answer)
end

#captchator_instructionsObject



3
4
5
# File 'lib/captchator/view.rb', line 3

def captchator_instructions
  ENV['captchator_instructions'] || "Please write the text shown in the captcha box to prove you're not a machine."
end

#captchator_labelObject



11
12
13
# File 'lib/captchator/view.rb', line 11

def captchator_label
  label_tag('captchator_answer', captchator_image)
end

#captchator_refreshObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/captchator/view.rb', line 19

def captchator_refresh
  link_to("refresh captcha", {:anchor => 'captchaptor_image'}, {
    :id => 'captchator_refresh',
    :onclick => "var new_url = \"\#{captchator_image_path}?\" + (new Date).getTime();\n$('#captchator_image').attr('src', new_url);\nreturn false;\n    JAVASCRIPT\n  })\nend\n"

#captchator_tagsObject



7
8
9
# File 'lib/captchator/view.rb', line 7

def captchator_tags
  captchator_label + captchator_input + captchator_refresh
end