allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [6/7] allura git commit: [#8143] hi-res user icons, including gravatar
Date Tue, 31 Jan 2017 20:27:08 GMT
[#8143] hi-res user icons, including gravatar


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

Branch: refs/heads/db/8143
Commit: 2b894fcd2dace3c9e68fd41456fb77c827f5db80
Parents: a124e25
Author: Dave Brondsema <dave@brondsema.net>
Authored: Tue Jan 31 13:01:06 2017 -0500
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Tue Jan 31 15:12:31 2017 -0500

----------------------------------------------------------------------
 Allura/allura/controllers/project.py          |  2 +-
 Allura/allura/model/auth.py                   | 11 +++++++++--
 Allura/allura/templates/jinja_master/lib.html | 11 +++++++++--
 3 files changed, 19 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/2b894fcd/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index eca8833..32167dc 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -433,7 +433,7 @@ class ProjectController(FeedController):
     @expose()
     def user_icon(self, **kw):
         try:
-            return self.icon()
+            return self.icon(**kw)
         except exc.HTTPNotFound:
             redirect(g.forge_static('images/user.png'))
 

http://git-wip-us.apache.org/repos/asf/allura/blob/2b894fcd/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 94bbcf0..69a3bd7 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -624,7 +624,7 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
         return '/%s/' % plugin.AuthenticationProvider.get(request).user_project_shortname(self)
 
     @memoize
-    def icon_url(self, gravatar_default_url=None):
+    def icon_url(self, gravatar_default_url=None, return_more=False):
         icon_url = None
         try:
             private_project = self.private_project()
@@ -632,14 +632,21 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
             log.warn('Error getting/creating user-project for %s',
                      self.username, exc_info=True)
             private_project = None
+        icon_source = None
         if private_project and private_project.icon:
             icon_url = self.url() + 'user_icon'
+            icon_source = 'local'
         elif 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
+            icon_source = 'gravatar'
+
+        if return_more:
+            return icon_url, private_project, icon_source
+        else:
+            return icon_url
 
     @classmethod
     def upsert(cls, username):

http://git-wip-us.apache.org/repos/asf/allura/blob/2b894fcd/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 65a5f52..8feabf0 100644
--- a/Allura/allura/templates/jinja_master/lib.html
+++ b/Allura/allura/templates/jinja_master/lib.html
@@ -54,8 +54,15 @@
 
 {% 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(gravatar_default_url)}}"
+  {% set icon_url, user_proj, icon_source = user.icon_url(gravatar_default_url, return_more=True)
%}
+  {% if icon_url %}
+    <img {% if icon_source == 'local' %}
+             {{ project_icon_srcs(user_proj, icon_url=icon_url) }}
+         {% elif icon_source == 'gravatar' %}
+             src="{{ icon_url }}"
+             srcset="{{icon_url}}&s={{ size*1.5 }} 1.5x,
+                     {{icon_url}}&s={{ size*2 }} 2x,"
+         {% endif %}
          alt="{{display_name}}"
          title="{{display_name}}"
          class="emboss{% if size %} x{{size}}{% endif %}{% if className %} {{className}}{%
endif %}">


Mime
View raw message