1 ! Copyright (C) 2011 John Benediktsson
2 ! See http://factorcode.org/license.txt for BSD license
4 USING: accessors ascii assocs checksums checksums.md5
5 classes.tuple formatting http.client images.http json.reader
6 kernel math.parser sequences strings ;
10 TUPLE: info aboutMe accounts currentLocation displayName emails
11 hash id ims name phoneNumbers photos preferredUsername
12 profileBackground profileUrl requestHash thumbnailUrl urls ;
14 : gravatar-id ( email -- gravatar-id )
15 [ blank? ] trim >lower md5 checksum-bytes bytes>hex-string ;
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 ;
21 : gravatar. ( gravatar-id -- )
22 gravatar-info thumbnailUrl>> http-image. ;