Skip to content
Browse files

Get rid of the ratings and default images maps since we don't need th…

…en anymore. Also be a pedant.
  • Loading branch information...
1 parent 6b2be75 commit 770a5d217112f09058a35d0fab210dab41899be7 @Raynes committed Dec 29, 2011
Showing with 3 additions and 19 deletions.
  1. +3 −19 src/clavatar/core.clj
View
22 src/clavatar/core.clj
@@ -3,20 +3,6 @@
(def ^:private gravatar-base-url ".gravatar.com/avatar/")
-(def ^:private ratings
- {:g "g"
- :pg "pg"
- :r "r"
- :x "x"})
-
-(def ^:private default-images
- {:404 "404"
- :mm "mm"
- :identicon "identicon"
- :monster "monsterid"
@ghoseb
ghoseb added a note Dec 29, 2011

You need to fix the docs to list all the options. As you can see here, the actual param is monsterid and not monster.

I chose to keep the option maps for two reasons -

  • To minimise the delta so that it's easy to review
  • To keep the possibility of sanitizing the options in the future.

Right now the lib will happily accept any keyword as the options and will generate useless URLs.

@Raynes
Owner
Raynes added a note Dec 29, 2011

The docs actually do list all of the options (the docs to gravatar). It actually had :monsterid listed rather than :monster, so this was actually a bit of a bugfix (not your fault though). I agree, keeping them would have been useful if we did sanitizing eventually, but since we aren't, it was hard to justify leaving them in.

@ghoseb
ghoseb added a note Dec 29, 2011

Makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
- :wavatar "wavatar"
- :retro "retro"})
-
(defn- md5sum
"Calculate the MD5 checksum of a string and return the hex-digest string."
[^String s]
@@ -28,12 +14,12 @@
"Generate the hash needed for Gravatar.
The hash is generated by trimming, lowercasing & md5-summing the email."
[^String email]
- (md5sum (.toLowerCase (.trim email))))
+ (-> email .trim .toLowerCase md5sum))
@ghoseb
ghoseb added a note Dec 29, 2011

Is this how pedant's code? :-P

@Raynes
Owner
Raynes added a note Dec 29, 2011

Definitely.

@ghoseb
ghoseb added a note Dec 29, 2011

May be Clojure hipsters do... ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
(defn- genparams
"Generate the parameters needed for Gravatar."
[& {size :size default :default rating :rating}]
- (format "?s=%s&r=%s&d=%s&" size (ratings rating) (default-images default)))
+ (format "?s=%s&r=%s&d=%s&" size (name rating) (name default)))
(defn gravatar
"Returns the URL to a gravatar image for an email.
@@ -58,6 +44,4 @@
(genhash email)
".jpg"
(genparams :size size :default default :rating rating))]
- (if https
- (str "https://secure" base-url)
- (str "http://www" base-url))))
+ (str (if https "https://secure" "http://www") base-url)))

0 comments on commit 770a5d2

Please sign in to comment.
Something went wrong with that request. Please try again.