allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject allura git commit: Allow a default url to be passed to gravatar macro (e.g. for a custom theme)
Date Wed, 25 Mar 2015 11:26:38 GMT
Repository: allura
Updated Branches:
  refs/heads/master cde1ffce8 -> b233388cd


Allow a default url to be passed to gravatar macro (e.g. for a custom theme)


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/b233388c
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/b233388c
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/b233388c

Branch: refs/heads/master
Commit: b233388cd4f611abd2ef0a08c057566acba1dee3
Parents: cde1ffc
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Mon Mar 23 22:01:35 2015 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Mon Mar 23 22:01:35 2015 +0000

----------------------------------------------------------------------
 Allura/allura/model/auth.py                   | 7 +++++--
 Allura/allura/templates/jinja_master/lib.html | 4 ++--
 2 files changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/b233388c/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index f7e8c91..98dc4ec 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -615,7 +615,7 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
         return '/%s/' % plugin.AuthenticationProvider.get(request).user_project_shortname(self)
 
     @memoize
-    def icon_url(self):
+    def icon_url(self, gravatar_default_url=None):
         icon_url = None
         try:
             private_project = self.private_project()
@@ -626,7 +626,10 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
         if private_project and private_project.icon:
             icon_url = self.url() + 'user_icon'
         elif self.preferences.email_address:
-            icon_url = g.gravatar(self.preferences.email_address)
+            gravatar_args = {}
+            if gravatar_default_url:
+                gravatar_args['d'] = gravatar_default_url
+            icon_url = g.gravatar(self.preferences.email_address, **gravatar_args)
         return icon_url
 
     @classmethod

http://git-wip-us.apache.org/repos/asf/allura/blob/b233388c/Allura/allura/templates/jinja_master/lib.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/lib.html b/Allura/allura/templates/jinja_master/lib.html
index e4b1eb3..78ab9c0 100644
--- a/Allura/allura/templates/jinja_master/lib.html
+++ b/Allura/allura/templates/jinja_master/lib.html
@@ -52,10 +52,10 @@
   {% endif %}
 {%- endmacro %}
 
-{% macro gravatar(user, size, className) -%}
+{% macro gravatar(user, size, className, gravatar_default_url=None) -%}
   {% set display_name = h.really_unicode(user.display_name) %}
   {% if user.icon_url() %}
-    <img src="{{user.icon_url()}}"
+    <img src="{{user.icon_url(gravatar_default_url)}}"
          alt="{{display_name}}"
          title="{{display_name}}"
          class="emboss{% if size %} x{{size}}{% endif %}{% if className %} {{className}}{%
endif %}">


Mime
View raw message