Module: ReCaptcha::ViewHelper

Defined in:
lib/recaptcha.rb

Instance Method Summary collapse

Instance Method Details

#get_captcha(options = {}) ⇒ Object



27
28
29
30
31
32
# File 'lib/recaptcha.rb', line 27

def get_captcha(options={})
  k = ReCaptcha::Client.new(options[:rcc_pub] || RCC_PUB, options[:rcc_priv] || RCC_PRIV, options[:ssl] || false)
  r = k.get_challenge(session[:rcc_err] || '', options)
  session[:rcc_err]=''
  r
end

#mail_hide(address, contents = nil) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/recaptcha.rb', line 33

def mail_hide(address, contents=nil)
  contents = truncate(address,10) if contents.nil?
  k = ReCaptcha::MHClient.new(MH_PUB, MH_PRIV)
  enciphered = k.encrypt(address)
  uri = "http://mailhide.recaptcha.net/d?k=#{MH_PUB}&c=#{enciphered}"
  t ="  <a href=\"\#{uri}\"\n  onclick=\"window.open('\#{uri}', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"Reveal this e-mail address\">\#{contents}</a>\n"
end