diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Draw no avatar when luaossl is missing
The require at the top raised as cgit loaded the filter, so every page that lists an author stopped at its first author cell with an error.
Diffstat (limited to 'custom/extensions/email-gravatar.lua')
-rw-r--r--custom/extensions/email-gravatar.lua7
1 file changed, 4 insertions, 3 deletions
diff --git a/custom/extensions/email-gravatar.lua b/custom/extensions/email-gravatar.lua
index 01db3f9..836841f 100644
--- a/custom/extensions/email-gravatar.lua
+++ b/custom/extensions/email-gravatar.lua
@@ -12,7 +12,8 @@
-- The one dependency is luaossl, the OpenSSL binding that provides
-- openssl.digest, from <https://github.com/wahern/luaossl>. The reliable
-- cross-platform install is LuaRocks, matched to the Lua version cgit is built
--- against, and it needs the OpenSSL development headers present.
+-- against, and it needs the OpenSSL development headers present. Without it
+-- the filter draws no icons and leaves the names as they are.
--
-- # Debian and Ubuntu
-- sudo apt install luarocks libssl-dev
@@ -31,7 +32,7 @@
-- that is not acceptable for your instance. Addresses are hashed with MD5,
-- which Gravatar still accepts.
-local digest = require("openssl.digest")
+local has_digest, digest = pcall(require, "openssl.digest")
-- The size is in pixels and serves both as the image asked of the service
@@ -94,7 +95,7 @@ end
function filter_open(email, page)
buffer = ""
local address = normalize_email(email)
- if address == nil then
+ if address == nil or not has_digest then
avatar_hash = nil
else
avatar_hash = hash_hex(address)