Skip to content

Commit d0cec6a

Browse files
committed
Add plugin to obfuscate email
1 parent 8193d49 commit d0cec6a

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

_includes/team-profile.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ <h1>{{ member.name }}</h1>
1818
<p> {{ member.responsibilities | markdownify | remove: '<p>' | remove: '</p>'}} </p>
1919
{% endif %}
2020
{% if member.email %}
21-
<i>email: <{{ member.email }}></i>
21+
<i>email: <{{ member.email | mailObfuscate }}></i>
2222
{% endif %}
2323
{% if member.education %}
2424
<p> <strong>Education:</strong> {{ member.education }} </p>

_plugins/mail_obfuscate.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require "base64"
2+
require "uri"
3+
4+
module ObfuscateMailAddress
5+
def mailObfuscate(input)
6+
base64Mail = Base64.strict_encode64(Addressable::URI.encode(input))
7+
8+
# See http://techblog.tilllate.com/2008/07/20/ten-methods-to-obfuscate-e-mail-addresses-compared/
9+
output = "<a href=\"#\" "
10+
output += "data-contact=\"#{base64Mail}\" target=\"_blank\" "
11+
output += "onfocus=\"this.href = 'mailto:' + atob(this.dataset.contact)\">"
12+
output += "<script type=\"text/javascript\">document.write(atob(\"#{base64Mail}\"));</script></a>"
13+
return output
14+
end
15+
end
16+
17+
Liquid::Template.register_filter(ObfuscateMailAddress)

0 commit comments

Comments
 (0)