Skip to content

Commit 9b61914

Browse files
author
Robert Bruce Park
committed
Add gravatar support to the HTML output.
1 parent a538084 commit 9b61914

File tree

3 files changed

+31
-16
lines changed

3 files changed

+31
-16
lines changed

resume.css

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,41 @@ body {
55
}
66

77
#container {
8-
margin: auto;
9-
width: 7.5in;
10-
padding: .5in;
8+
margin: auto;
9+
width: 7.5in;
10+
padding: .5in;
1111
}
1212

1313
#contact {
1414
float: right;
1515
text-align: right;
16-
/*margin-top: -5px;*/
1716
}
1817

1918
#contact p {
2019
margin: .5em;
21-
}
20+
}
21+
22+
img {
23+
padding: 4px;
24+
border: 1px solid #ccc;
25+
background: #fff;
26+
}
2227

23-
/** {
24-
clear: both;
25-
}*/
2628
a {
27-
text-decoration: none;
28-
color: #333;
29+
text-decoration: none;
30+
color: #333;
2931
}
30-
32+
3133
a:hover {
32-
text-decoration: underline;
34+
text-decoration: underline;
3335
}
3436

3537
h1 {
3638
margin-top: 0;
3739
}
3840

3941
h2 {
40-
margin-top: 0;
42+
margin-top: 0;
4143
}
4244

4345
ul {
@@ -50,7 +52,7 @@ ul li ul {
5052
}
5153

5254
li {
53-
margin-top: 0em;
55+
margin-top: 0em;
5456
}
5557

5658
ul li ul li {

resume.pdf

-4.08 KB
Binary file not shown.

resume.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,14 @@ def tex(lines, contact_lines, *args):
3939
python resume.py tex < resume.md
4040
4141
"""
42+
import hashlib
4243
import sys
4344
import re
4445

4546

47+
GRAVATAR = "http://www.gravatar.com/avatar/{hash}?s=200"
48+
49+
4650
class Processor(object):
4751
handlers = {}
4852

@@ -81,15 +85,15 @@ def sub(pattern, repl, string, **kwargs):
8185

8286
return re.sub(pattern, r"\1\2%s\%d" % (repl, num_groups + 3), string,
8387
flags=flags, **kwargs)
84-
88+
8589
# pandoc doesn't seem to support markdown inside latex blocks, so we're
8690
# just going to hardcode the two most common link formats for now so people
8791
# can put links in their contact info
8892
def replace_links(line):
8993
line = re.sub(r"<([^:]+@[^:]+?)>", r"\href{mailto:\1}{\1}", line)
9094
line = re.sub(r"<(http.+?)>", r"\url{\1}", line)
9195
return re.sub(r"\[([^\]]+)\]\(([^\)]+)\)", r"\href{\2}{\1}", line)
92-
96+
9397
contact_lines = "\n\n".join(map(replace_links, contact_lines))
9498

9599
# replacements to apply to the text in contact_lines, because it won't be
@@ -122,6 +126,15 @@ def html(lines, contact_lines, *args):
122126
lines = map(replace, lines)
123127
contact_lines = map(replace, contact_lines)
124128

129+
gravatar = None
130+
for line in contact_lines:
131+
if line.find("@") > 0:
132+
gravatar = GRAVATAR.format(
133+
hash=hashlib.md5(line.lower().strip('<>')).hexdigest())
134+
break
135+
if gravatar is not None:
136+
contact_lines.insert(0, "<img src='{}' />".format(gravatar))
137+
125138
lines.insert(0, "<div id='container'><div id='contact'>%s</div>\n" %
126139
("<p>" + "</p><p>".join(contact_lines) + "</p>"))
127140
lines.insert(1, "<div>")

0 commit comments

Comments
 (0)