No commit activity in last 3 years
No release in over 3 years
Simple, easy way to implement recaptcha for Sinatra
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Quick, simple, easy way to implement REcaptcha for Sinatra apps

Installation

gem sources -a http://gems.github.com

sudo gem install djbender-sinatra-recaptcha


require 'rubygems'
require 'sinatra'
require 'sinatra/recaptcha'

configure do
   # https://admin.recaptcha.net/accounts/signup/
   Sinatra::ReCaptcha.public_key  = 'your_public_key'
   Sinatra::ReCaptcha.private_key = 'your_private_key'
   # to use ssl set Sinatra::ReCaptcha.server = 'https://api-secure.recaptcha.net'
end


get '/' do
  haml :recaptcha
end

post '/' do
  halt(401, "invalid captcha") unless recaptcha_correct?
  "passed!"
end

__END__

@@ captcha

%h1 Try ReCaptcha
%form{:method=>"post", :action=>"/post"}
  = recaptcha
  # you can also use recaptcha(:ajax) to use a pure ajax version--
  %input{:type=>'submit', :value => 'Send'}