This extension integrates reCAPTCHA into a Radiant app. It adds a tag to place the reCAPTCHA dialog on a page and a controller method to validate the reCAPTCHA.
In and of itself, this extension is useless unless you are an extension developer. You should only install this extension if another extension needs/wants it (or you are an extension developer).
This extension is only compatible with Radiant 0.8.x
You must have an account with reCAPTCHA to obtain the necessary keys. Signup
From your extensions directory (i.e. vendor/extensions)
git clone git://github.com/tekwiz/radiant-recaptcha-extension.git recaptcha
You must set the following configurations/settings either via the Settings extension or in your
config/environment.rb. If you choose to set it in your
config/environment.rb, here is the example syntax:
Radiant::Config['recaptcha.public_key'] = 'Your reCAPTCHA public key'
recaptcha.public_key: Your reCAPTCHA public key
recaptcha.private_key: Your reCAPTCHA private key
Insert this tag into your page or snippet to include a reCAPTCHA box. You do not need to include the
public_key attribute if you have set your public key in the configuration/settings.
<r:recaptcha [public_key="your_public_key"] [ssl="false|true"] [noscript="true|false"] />
public_key: your reCAPTCHA public key if you don't want to set it in your configuration or the settings plugin. This will override any configurations/settings you have in place.
ssl: whether or not to use reCAPTCHA's SSL connection (only needed if your public site is running SSL). Default: false
noscript: whether or not to include a noscript version of the reCAPTCHA plugin. Default: true
verify_recaptcha method is available a protected method in Controllers:
if verify_recaptcha(:model => @obj) redirect_to objs_url else render :action => 'new' end
Verification Method Options
private_key: your reCAPTCHA private key if you don't want to set it in your configuration or the settings plugin. This will override any configurations/settings you have in place.
model: the ActiveRecord model (or any object that has a Hash or ActiveRecord::Errors at
obj.errors) to add any verification errors to.
request: the Rack Request object from a controller. The method may obtain it auto-magically, but this is only guaranteed when it is used inside a controller.
Don't mess with
cookie[:recaptcha_error] unless you know what you're doing. This is a variable that is passed from the reCAPTCHA validation server to the plugin.
Thanks to Mr. Jason L Perry for providing the basis for this extension. Most of the code for
lib/recaptcha.rb is taken and modified from Jason L Perry's recaptcha plugin
Mr. Perry's copyright notice
Copyright (c) 2007 Jason L Perry
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.