Remove dependency on PURI and use IRONCLAD instead of MD5.
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
diff --git a/gravatar.asd b/gravatar.asd
index b10231a..90315af 100644
--- a/gravatar.asd
+++ b/gravatar.asd
@@ -7,6 +7,6 @@
:author "Greg Pfeil <greg@technomadic.org>"
:license "Apache 2.0"
:version "0.0.1"
- :depends-on (md5 drakma puri cl-json babel)
+ :depends-on (drakma ironclad cl-json trivial-utf-8)
:components ((:file "package")
(:file "gravatar" :depends-on ("package"))))
diff --git a/gravatar.lisp b/gravatar.lisp
index dbd04e4..926212a 100644
--- a/gravatar.lisp
+++ b/gravatar.lisp
@@ -1,14 +1,14 @@
(in-package #:gravatar)
-(defvar +base-uri+ (puri:uri "https://secure.gravatar.com/")
+(defvar +base-uri+ "https://secure.gravatar.com/"
"Why would we ever _not_ use SSL?")
(defun hash (email)
- (string-downcase (format nil "~{~2,'0x~}"
- (coerce (md5:md5sum-sequence
- (string-downcase (string-trim '(#\space)
- email)))
- 'list))))
+ (ironclad:byte-array-to-hex-string
+ (ironclad:digest-sequence :md5
+ (trivial-utf-8:string-to-utf-8-bytes
+ (string-downcase (string-trim '(#\Space)
+ email))))))
(defun image-url (email &key size default force-default-p rating)
"DEFAULT may be either a URL to your own image, or one of :404, :mm,
@@ -21,29 +21,25 @@
(string (push `("d" . ,default) parameters)))
(when force-default-p (push '("f" . "y") parameters))
(when rating (push `("r" . ,(string-downcase rating)) parameters))
- (puri:merge-uris (format nil "avatar/~a~@[?~a~]"
- (hash email)
- (drakma::alist-to-url-encoded-string parameters
- :utf-8))
- +base-uri+)))
+ (format nil "~Aavatar/~A~@[?~A~]"
+ +base-uri+
+ (hash email)
+ (drakma::alist-to-url-encoded-string parameters
+ :utf-8))))
(defun generate-profile-url (email type parameters)
- (puri:merge-uris (format nil "g2-~a.~a~@[?~a~]"
- (hash email)
- (string-downcase type)
- (drakma::alist-to-url-encoded-string parameters
- :utf-8))
- +base-uri+))
+ (format nil "~Ag2-~A.~A~@[?~A~]"
+ +base-uri+
+ (hash email)
+ (string-downcase type)
+ (drakma::alist-to-url-encoded-string parameters
+ :utf-8)))
(defun profile-url (email js-callback)
(generate-profile-url email
:json
(when js-callback `(("callback" . ,js-callback)))))
-(defun profile (email)
- (json:decode-json-from-string
- (babel:octets-to-string (drakma:http-request (profile-url email nil)))))
-
(defun qr-code-url (email &key size)
(generate-profile-url email
:qr