all repos — cgit @ 50287e7912129881a0157e4ae6dcc42310567c6e

a hyperfast web frontend for git written in c

filters/email-gravatar.py (view raw)

 1#!/usr/bin/env python3
 2
 3# Please prefer the email-gravatar.lua using lua: as a prefix over this script. This
 4# script is very slow, in comparison.
 5#
 6# This script may be used with the email-filter or repo.email-filter settings in cgitrc.
 7#
 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 )
17#
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.
20
21import sys
22import hashlib
23
24email = sys.argv[1].lower().strip()
25if email[0] == '<':
26        email = email[1:]
27if email[-1] == '>':
28        email = email[0:-1]
29
30page = sys.argv[2]
31
32md5 = hashlib.md5(email.encode()).hexdigest()
33text = sys.stdin.read().strip()
34
35print("<img src='//www.gravatar.com/avatar/" + md5 + "?s=13&d=retro' style='height:10pt;width:10pt'> " + text)