]>
git.cameronkatri.com Git - cgit.git/blob - filters/email-gravatar.py
3 # Please prefer the email-gravatar.lua using lua: as a prefix over this script. This
4 # script is very slow, in comparison.
6 # This script may be used with the email-filter or repo.email-filter settings in cgitrc.
8 # The following environment variables can be used to retrieve the configuration
9 # of the repository for which this script is called:
10 # CGIT_REPO_URL ( = repo.url setting )
11 # CGIT_REPO_NAME ( = repo.name setting )
12 # CGIT_REPO_PATH ( = repo.path setting )
13 # CGIT_REPO_OWNER ( = repo.owner setting )
14 # CGIT_REPO_DEFBRANCH ( = repo.defbranch setting )
15 # CGIT_REPO_SECTION ( = section setting )
16 # CGIT_REPO_CLONE_URL ( = repo.clone-url setting )
18 # It receives an email address on argv[1] and text on stdin. It prints
19 # to stdout that text prepended by a gravatar at 10pt.
25 email
= sys
.argv
[1].lower().strip()
33 sys
.stdin
= codecs
.getreader("utf-8")(sys
.stdin
.detach())
34 sys
.stdout
= codecs
.getwriter("utf-8")(sys
.stdout
.detach())
36 md5
= hashlib
.md5(email
.encode()).hexdigest()
37 text
= sys
.stdin
.read().strip()
39 print("<img src='//www.gravatar.com/avatar/" + md5
+ "?s=13&d=retro' width='13' height='13' alt='Gravatar' /> " + text
)