about summary refs log tree commit diff
path: root/filters/email-gravatar.py
blob: d70440ea543cc30fd6de6512d03431a6f2dc97e3 (plain) (blame)
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
#!/usr/bin/env python3

# Please prefer the email-gravatar.lua using lua: as a prefix over this script. This
# script is very slow, in comparison.
#
# This script may be used with the email-filter or repo.email-filter settings in cgitrc.
#
# The following environment variables can be used to retrieve the configuration
# of the repository for which this script is called:
# CGIT_REPO_URL        ( = repo.url       setting )
# CGIT_REPO_NAME       ( = repo.name      setting )
# CGIT_REPO_PATH       ( = repo.path      setting )
# CGIT_REPO_OWNER      ( = repo.owner     setting )
# CGIT_REPO_DEFBRANCH  ( = repo.defbranch setting )
# CGIT_REPO_SECTION    ( = section        setting )
# CGIT_REPO_CLONE_URL  ( = repo.clone-url setting )
#
# It receives an email address on argv[1] and text on stdin. It prints
# to stdout that text prepended by a gravatar at 10pt.

import sys
import hashlib
import codecs

email = sys.argv[1].lower().strip()
if email[0] == '<':
        email = email[1:]
if email[-1] == '>':
        email = email[0:-1]

page = sys.argv[2]

sys.stdin = codecs.getreader("utf-8")(sys.stdin.detach())
sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())

md5 = hashlib.md5(email.encode()).hexdigest()
text = sys.stdin.read().strip()

print("<img src='//www.gravatar.com/avatar/" + md5 + "?s=13&amp;d=retro' width='13' height='13' alt='Gravatar' /> " + text)
Tarmak 2 to console keymapJune McEnroe 2017-07-04Remove pathogenJune McEnroe Apparently this is built in now. Except it loads from a weird path structure. 2017-07-04Consolidate pbd, pbcopy, pbpasteJune McEnroe 2017-07-04Reorganize neovim configuration, againJune McEnroe 2017-07-04Remove <Esc><Esc> terminal mappingJune McEnroe <C-w><Esc> works just as well. Convenient. 2017-07-04Generalize C-w neovim terminal mappingJune McEnroe 2017-07-04Remove tmuxJune McEnroe tmux configuration was starting to bother me, and it got worse with Sierra. Turns out that neovim terminal emulation is much more natural to work with and requires less configuration, though I still disapprove of the feature being included in an editor! For detaching and attaching sessions, abduco is a simple tool that seems to work decently, but given that I will likely only be running neovim in the sessions, I might come up with something even simpler. 2017-07-04Show terminal title in statuslineJune McEnroe 2017-07-04Add nvim terminal mappingsJune McEnroe 2017-06-29Add color to xxJune McEnroe 2017-06-28Set tmux copy-mode-vi bindings for TarmakJune McEnroe 2017-06-27Link Scala syntax fileJune McEnroe Oops. 2017-06-27Clean up top of trivial colorscheme fileJune McEnroe 2017-06-27Fix Scala syntax highlight linksJune McEnroe