Module: Card::Set::All::Recaptcha::HtmlFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
tmpsets/set/mod028-recaptcha/all/recaptcha.rb

Instance Method Summary collapse

Instance Method Details

#card_form_html_opts(action, opts = {}) ⇒ Object



105
106
107
108
109
# File 'tmpsets/set/mod028-recaptcha/all/recaptcha.rb', line 105

def card_form_html_opts action, opts={}
  super
  opts["data-recaptcha"] ||= "on" if recaptcha?(opts)
  opts
end

#hidden_form_tags(action, opts) ⇒ Object



99
100
101
102
103
# File 'tmpsets/set/mod028-recaptcha/all/recaptcha.rb', line 99

def hidden_form_tags action, opts
  return super unless recaptcha?(opts)

  super + recaptcha_token(action)
end

#recaptcha?(opts) ⇒ Boolean

Returns:

  • (Boolean)


111
112
113
# File 'tmpsets/set/mod028-recaptcha/all/recaptcha.rb', line 111

def recaptcha? opts
  card.recaptcha_on? && opts[:recaptcha] != :off
end

#recaptcha_script_urlObject



95
96
97
# File 'tmpsets/set/mod028-recaptcha/all/recaptcha.rb', line 95

def recaptcha_script_url
  "https://www.google.com/recaptcha/api.js?render=#{Card.config.recaptcha_site_key}"
end

#recaptcha_token(action) ⇒ Object



85
86
87
88
89
90
91
92
93
# File 'tmpsets/set/mod028-recaptcha/all/recaptcha.rb', line 85

def recaptcha_token action
  output [
    javascript_include_tag(recaptcha_script_url),
    hidden_field_tag("recaptcha_token", "",
                     "data-site-key": Card.config.recaptcha_site_key,
                     "data-action": action,
                     class: "_recaptcha-token")
  ]
end