Permalink
Browse files

Merge branch 'hotfix/1.5.0.1'

  • Loading branch information...
2 parents 3ee280f + 6c7c9ee commit 5b63f4375fd35cc3656e981ace52c2432264698f @amalloy amalloy committed Oct 2, 2011
View
@@ -1,4 +1,4 @@
-(defproject foreclojure "1.5.0"
+(defproject foreclojure "1.5.0.1"
:description "4clojure - a website for lisp beginners"
:dependencies [[clojure "1.2.1"]
[clojure-contrib "1.2.0"]
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -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 "/" %)))
@@ -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,14 +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 (md5 (canonical-email email))
+ (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}))])))

0 comments on commit 5b63f43

Please sign in to comment.