From 5ff3481cce56f40f15fa305b91f9ce26494909db Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Wed, 15 Jul 2026 06:14:57 -1000 Subject: Reorganize into source, assets and libraries The C sources move to source/, the served files to assets/, the bundled Git submodule to libraries/git and the filter scripts to extensions/. Everything the build generates now lands in build/, so a clean is a single remove and the tree stays clean. --- extensions/email-gravatar.lua | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 extensions/email-gravatar.lua (limited to 'extensions/email-gravatar.lua') diff --git a/extensions/email-gravatar.lua b/extensions/email-gravatar.lua new file mode 100644 index 0000000..c39b490 --- /dev/null +++ b/extensions/email-gravatar.lua @@ -0,0 +1,35 @@ +-- This script may be used with the email-filter or repo.email-filter settings in cgitrc. +-- It adds gravatar icons to author names. It is designed to be used with the lua: +-- prefix in filters. It is much faster than the corresponding python script. +-- +-- Requirements: +-- luaossl +-- +-- + +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 = "" + md5 = md5_hex(email:sub(2, -2):lower()) +end + +function filter_close() + html("Gravatar " .. buffer) + return 0 +end + +function filter_write(str) + buffer = buffer .. str +end + + -- cgit v2.8.0