Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use default gravatar image

  • Loading branch information...
commit 6c7c9eecb929db31b6b0dcc3dd2973e9daf405b4 1 parent a400304
Alan Malloy amalloy authored
Showing with 11 additions and 10 deletions.
  1. +4 −4 src/foreclojure/ring_utils.clj
  2. +7 −6 src/foreclojure/users.clj
8 src/foreclojure/ring_utils.clj
View
@@ -1,9 +1,9 @@
(ns foreclojure.ring-utils
(:require [foreclojure.config :as config]))
-(def ^:dynamic *url* nil) ; url of current request
-(def ^:dynamic *host* nil) ; Host header sent by client
-(def ^:dynamic *http-scheme* nil) ; keyword, :http or :https
+(def ^{:dynamic true} *url* nil) ; url of current request
+(def ^{:dynamic true} *host* nil) ; Host header sent by client
+(def ^{:dynamic true} *http-scheme* nil) ; keyword, :http or :https
(defn get-host [request]
(get-in request [:headers "host"]))
@@ -16,5 +16,5 @@
(handler req))))
(def static-url (if-let [host config/static-host]
- #(str (name *http-scheme*) "://" host "/" %)
+ #(str (name (or *http-scheme* :http)) "://" host "/" %)
#(str "/" %)))
13 src/foreclojure/users.clj
View
@@ -4,14 +4,15 @@
[sandbar.stateful-session :as session])
(:use [foreclojure.utils :only [from-mongo row-class rank-class get-user with-user]]
[foreclojure.template :only [def-page content-page]]
- [foreclojure.ring-utils :only [*http-scheme*]]
+ [foreclojure.ring-utils :only [*http-scheme* static-url]]
[foreclojure.config :only [config repo-url]]
[somnium.congomongo :only [fetch-one fetch update!]]
[compojure.core :only [defroutes GET POST]]
[hiccup.form-helpers :only [form-to hidden-field]]
[hiccup.page-helpers :only [link-to]]
[clojure.contrib.json :only [json-str]])
- (:import org.apache.commons.codec.digest.DigestUtils))
+ (:import org.apache.commons.codec.digest.DigestUtils
+ java.net.URLEncoder))
(def golfer-tags (into [:contributor]
(when (:golfing-active config)
@@ -69,16 +70,16 @@
(link-to (str "mailto:" (email-address username))
username))
-
-
(let [canonical-email (comp string/trim string/lower-case)
- md5 #(DigestUtils/md5Hex %)]
+ md5 #(DigestUtils/md5Hex %)
+ no-gravatar-url (static-url "images/no-gravatar.png")
+ encoded (URLEncoder/encode no-gravatar-url)]
(defn gravatar-img [{:keys [email size class] :or {size 24}}]
(let [hash (if email
(md5 (canonical-email email))
"0000000000000000")
url (str (name *http-scheme*) "://www.gravatar.com/avatar/"
- hash "?s=" size "&d=identicon")]
+ hash "?s=" size "&d=" encoded)]
[:img (conj {:src url, :alt "gravatar icon"
:width size :height size}
(when class {:class class}))])))
Please sign in to comment.
Something went wrong with that request. Please try again.