From 0c27ce4aefe14a70a823739d5670604bca9581c4 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 19 Mar 2014 02:58:41 -0600 Subject: Steal kernel.org's libravatar lua. --- filters/email-libravatar-hover.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 filters/email-libravatar-hover.lua (limited to 'filters') diff --git a/filters/email-libravatar-hover.lua b/filters/email-libravatar-hover.lua new file mode 100644 index 0000000..c14b618 --- /dev/null +++ b/filters/email-libravatar-hover.lua @@ -0,0 +1,25 @@ +local digest = require("openssl.digest") + +function md5_hex(input) + local b = digest.new("md5"):final(input) + local x = "" + for i = 1, #b do + x = x .. string.format("%.2x", string.byte(b, i)) + end + return x +end + +function filter_open(email, page) + buffer = "" + hexdigest = md5_hex(email:sub(2, -2):lower()) +end + +function filter_close() + baseurl = os.getenv("HTTPS") and "https://seccdn.libravatar.org/" or "http://cdn.libravatar.org/" + html("" .. buffer) + return 0 +end + +function filter_write(str) + buffer = buffer .. str +end -- cgit v1.2.3-18-g5258