Mail hide filter using reCaptcha

5 views
Skip to first unread message

LarryK

unread,
Jun 26, 2009, 12:33:07 PM6/26/09
to Liquid Templates
Hi All,

The old technique of protecting email addresses on web pages by using
Javascript no longer works since Google now executes the Javascript.
See http://it.slashdot.org/story/09/06/23/173229/Has-Google-Broken-JavaScript-Spam-Munging

So I implemented a Liquid filter that uses the http://mailhide.recaptcha.net/
Mailhide service.

1) Install gem ruby-recaptcha. See http://bitbucket.org/mml/ruby-recaptcha/wiki/Home
gem install recaptcha

2) Obtain a free set of Mailhide cryptographic keys from
http://mailhide.recaptcha.net/apikey
Install them in your app. I added them to environment.rb
# ReCaptcha Mailhide keys
# See mailhide.recaptcha.net
MH_PUB = "01xxxxxxxxxxxxxxxxxx"
MH_PRIV = "A5xxxxxxxxxxxxxxxxxxx"

3) Add a filter to liquid:

module Liquid
module MyFilters
include ReCaptcha::ViewHelper

def email_hide(plain, label = "show")
# returns link to show email via recaptcha
return(nil) if plain.blank?
mail_hide(plain, label)
end

end

Template.register_filter(MyFilters)
end

Now your templates can use the email_hide filter to output email
addresses without showing them to spammers

Thanks again Tobias and the community for a great project.

Regards,

Larry
Reply all
Reply to author
Forward
0 new messages