]> gitweb.factorcode.org Git - factor.git/blob - extra/gravatar/gravatar.factor
interpolate: split out format into a hook
[factor.git] / extra / gravatar / gravatar.factor
1 ! Copyright (C) 2011 John Benediktsson
2 ! See http://factorcode.org/license.txt for BSD license
3
4 USING: accessors ascii assocs checksums checksums.md5
5 classes.tuple formatting http.client images.http json.reader
6 kernel math.parser sequences strings ;
7
8 IN: gravatar
9
10 TUPLE: info aboutMe accounts currentLocation displayName emails
11 hash id ims name phoneNumbers photos preferredUsername
12 profileBackground profileUrl requestHash thumbnailUrl urls ;
13
14 : gravatar-id ( email -- gravatar-id )
15     [ blank? ] trim >lower md5 checksum-bytes bytes>hex-string ;
16
17 : gravatar-info ( gravatar-id -- info )
18     "http://gravatar.com/%s.json" sprintf http-get nip
19     >string json> "entry" of first info from-slots ;
20
21 : gravatar. ( gravatar-id -- )
22     gravatar-info thumbnailUrl>> http-image. ;