From 0cdc688555ea07bee362f76b9ce610b1801340af Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Thu, 18 Mar 2021 17:54:47 -0400 Subject: Initial commit --- .gitignore | 1 + Makefile | 28 ++++++++++++++++++++++++++++ custom.css.in | 29 +++++++++++++++++++++++++++++ email-libravatar.lua | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 custom.css.in create mode 100644 email-libravatar.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b3a5267 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.css diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1bdf890 --- /dev/null +++ b/Makefile @@ -0,0 +1,28 @@ +CSS = \ + custom.css + +FILTERS = \ + email-libravatar.lua + +all: $(CSS) + +V_GEN = $(_v_GEN_$(V)) +_v_GEN_ = $(_v_GEN_0) +_v_GEN_0 = @echo " GEN " $@; + +edit = $(V_GEN) m4 -P $@.in >$@ && chmod g-w $@ + +%: %.in + $(edit) + +%.sh: %.sh.in + $(edit) + +clean: + $(RM) $(CSS) + +deploy: all + install -m644 $(CSS) /usr/share/cgit/ + install -m644 $(FILTERS) /usr/lib/cgit/filters/ + +.PHONY: all clean diff --git a/custom.css.in b/custom.css.in new file mode 100644 index 0000000..71b860d --- /dev/null +++ b/custom.css.in @@ -0,0 +1,29 @@ +m4_include(/usr/share/cgit/cgit.css) + +div#cgit span.libravatar img.onhover { + display: none; + border: 1px solid gray; + padding: 0px; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + width: 128px; + height: 128px; +} + +div#cgit span.libravatar img.inline { + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; + width: 13px; + height: 13px; + margin-right: 0.2em; +} + +div#cgit span.libravatar:hover > img.onhover { + display: block; + position: absolute; + margin-left: 1.5em; + background-color: #eeeeee; + box-shadow: 2px 2px 7px rgba(100,100,100,0.75); +} diff --git a/email-libravatar.lua b/email-libravatar.lua new file mode 100644 index 0000000..7d378fd --- /dev/null +++ b/email-libravatar.lua @@ -0,0 +1,37 @@ +-- This script may be used with the email-filter or repo.email-filter settings in cgitrc. +-- It adds libravatar icons to author names. It is designed to be used with the lua: +-- prefix in filters. +-- +-- 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() + baseurl = os.getenv("HTTPS") and "https://seccdn.libravatar.org/" or "http://cdn.libravatar.org/" +-- html("Libravatar " .. buffer) + html("Libravatar" .. buffer) + return 0 +end + +function filter_write(str) + buffer = buffer .. str +end + + -- cgit v1.2.3