summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Unit 193 <unit193@unit193.net>2021-03-18 17:54:47 -0400
committerLibravatar Unit 193 <unit193@unit193.net>2021-03-18 17:54:47 -0400
commit0cdc688555ea07bee362f76b9ce610b1801340af (patch)
tree65701185be4826627a1a51315d38dfccf664cbc3
downloadcgit-assets-0cdc688555ea07bee362f76b9ce610b1801340af.tar.bz2
cgit-assets-0cdc688555ea07bee362f76b9ce610b1801340af.tar.xz
cgit-assets-0cdc688555ea07bee362f76b9ce610b1801340af.tar.zst
Initial commit
-rw-r--r--.gitignore1
-rw-r--r--Makefile28
-rw-r--r--custom.css.in29
-rw-r--r--email-libravatar.lua37
4 files changed, 95 insertions, 0 deletions
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
+-- <http://25thandclement.com/~william/projects/luaossl.html>
+--
+
+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("<img src='" .. baseurl .. "avatar/" .. md5 .. "?s=13&amp;d=retro' width='13' height='13' alt='Libravatar' /> " .. buffer)
+ html("<span class='libravatar'><img class='inline' src='" .. baseurl .. "avatar/" .. md5 .. "?s=13&amp;d=retro' width='13' height='13' alt='Libravatar' /><img class='onhover' src='" .. baseurl .. "avatar/" .. md5 .. "?s=128&amp;d=retro' /></span>" .. buffer)
+ return 0
+end
+
+function filter_write(str)
+ buffer = buffer .. str
+end
+
+