Commit a78991d0b0e914e629d99746262da3618fec7cf8

Thomas de Grivel 2014-03-03T21:25:28

Remove dependency on PURI and use IRONCLAD instead of MD5.

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