Commit 0c27ce4aefe14a70a823739d5670604bca9581c4

Parents: 8a0eaa5204a7360d96c82e6b938424438dddb617

From: Jason A. Donenfeld <Jason@zx2c4.com>
Date: Wed Mar 19 02:58:41 2014 +0700

Steal kernel.org's libravatar lua.

		

Stats

cgit.css +28/-0
filters/email-libravatar-hover.lua +25/-0

Changeset

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
diff --git a/cgit.css b/cgit.css
index 1b848cf712c9e93c3c29e299008786d6edae87d4..f525ecc61e068745b5d260beb7a4de299220b142 100644
--- a/cgit.css
+++ b/cgit.css
@@ -897,3 +897,31 @@
 div#cgit table.ssdiff td.space div {
 	min-height: 3em;
 }
+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;
+        opacity: 0.6;
+}
+
+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/filters/email-libravatar-hover.lua b/filters/email-libravatar-hover.lua
new file mode 100644
index 0000000000000000000000000000000000000000..c14b618b1c5c5b26d8d1ea3f598950f5cb101351
--- /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("<span class='libravatar'><img class='inline' src='" .. baseurl .. "avatar/" .. hexdigest .. "?s=13&amp;d=retro' /><img class='onhover' src='" .. baseurl .. "avatar/" .. hexdigest .. "?s=128&amp;d=retro' /></span>" .. buffer)
+	return 0
+end
+
+function filter_write(str)
+	buffer = buffer .. str
+end