[extensions-web] gravatar: Fix fallback
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] gravatar: Fix fallback
- Date: Thu, 9 Feb 2012 19:28:14 +0000 (UTC)
commit 9298de88a55748d081b482048b5e16e853598871
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Thu Feb 9 14:27:59 2012 -0500
gravatar: Fix fallback
It seems gravatar doesn't like relative URLs
.../auth/templates/registration/profile.html | 2 +-
.../extensions/templates/extensions/comments.html | 2 +-
sweettooth/extensions/templatetags/gravatar.py | 4 +++-
3 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/sweettooth/auth/templates/registration/profile.html b/sweettooth/auth/templates/registration/profile.html
index c1bf1dc..62bfe51 100644
--- a/sweettooth/auth/templates/registration/profile.html
+++ b/sweettooth/auth/templates/registration/profile.html
@@ -12,7 +12,7 @@
{% else %}
<h2>{{ display_name }}</h2>
{% endif %}
- <img class="gravatar" src="{% gravatar_url user.email 128 %}">
+ <img class="gravatar" src="{% gravatar_url request user.email 128 %}">
<p>
Your avatar is managed through <a href="https://secure.gravatar.com/">Gravatar</a>
</p>
diff --git a/sweettooth/extensions/templates/extensions/comments.html b/sweettooth/extensions/templates/extensions/comments.html
index cea9902..c0db913 100644
--- a/sweettooth/extensions/templates/extensions/comments.html
+++ b/sweettooth/extensions/templates/extensions/comments.html
@@ -11,7 +11,7 @@
{% else %}
<div class="comment">
{% endif %}
- <img src="{% gravatar_url comment.email %}" class="gravatar">
+ <img src="{% gravatar_url request comment.email %}" class="gravatar">
<div class="rating-author">
{% if comment.rating != -1 %}
<div class="rating" data-rating-value="{{ comment.rating }}"></div> by
diff --git a/sweettooth/extensions/templatetags/gravatar.py b/sweettooth/extensions/templatetags/gravatar.py
index df034a3..887a0a1 100644
--- a/sweettooth/extensions/templatetags/gravatar.py
+++ b/sweettooth/extensions/templatetags/gravatar.py
@@ -6,7 +6,9 @@ register = template.Library()
GRAVATAR_BASE = "https://secure.gravatar.com/avatar/%s?%s"
@register.simple_tag
-def gravatar_url(email, size=70, default="/static/images/nobody.png"):
+def gravatar_url(request, email, size=70):
email_md5 = hashlib.md5(email.lower()).hexdigest()
+ default = request.build_absolute_uri("/static/images/nobody.png")
options = urllib.urlencode(dict(d=default, s=size))
+
return GRAVATAR_BASE % (email_md5, options)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]