torsdag 22. april 2010

ReCaptcha Lift integration

"reCAPTCHA is a free CAPTCHA service that helps to digitize books, newspapers and old time radio shows." - reCaptcha.net

I had some issues making it work well with Lift so I decided to blog about it (sharing is caring).

The standard approach described here (code under) didn't show up in Opera so I chose to go with the AJAX API.




The "html"




Recaptcha.create() brings up the captcha. When the form is submitted we call setHidden() to set the hidden lift form elements.

<lift:msgs/> displays messages set with S.error.

On the server side we verify the response by calling the reCaptcha API.



Binding using the -%> operator binds the attributes from the html (here the essential id attributes).

The following was tested on Google App Engine and might need some modifications to work other places.

mandag 12. april 2010

Random unique hash in Scala

I use this code to generate random unique keys for invites: