Skip to content

Commit

Permalink
[ec] Make displaying gravatars configurable.
Browse files Browse the repository at this point in the history
Some clients don't necessarily want to display gravatar images.

Note - the reason for making this configurable, rather than customizing
a CKAN instance to not use gravatars in its templates is because gravatar
images are generated for activity streams outside of the templates.
  • Loading branch information
icmurray committed Nov 13, 2012
1 parent e664c45 commit 1a14ee4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ckan/config/deployment.ini_tmpl
Expand Up @@ -109,6 +109,9 @@ ckan.favicon = /images/icons/ckan.ico
## or "mm"). Or it can be a url, e.g. "http://example.com/images/avatar.jpg"
ckan.gravatar_default = identicon

## Controls whether gravatars are displayed or not.
ckan.display_gravatars = no

This comment has been minimized.

Copy link
@tobes

tobes Nov 16, 2012

Contributor

should this default to yes/true

This comment has been minimized.

Copy link
@icmurray

icmurray Nov 16, 2012

Author Contributor

Oops, yes it should.


## Solr support
#solr_url = http://127.0.0.1:8983/solr

Expand Down
11 changes: 11 additions & 0 deletions ckan/lib/helpers.py
Expand Up @@ -536,6 +536,10 @@ def format_icon(_format):
return 'page_white'

def linked_gravatar(email_hash, size=100, default=None):

if not _display_gravatars():
return ''

return literal(
'<a href="https://gravatar.com/" target="_blank"' +
'title="%s">' % _('Update your avatar at gravatar.com') +
Expand All @@ -544,6 +548,10 @@ def linked_gravatar(email_hash, size=100, default=None):

_VALID_GRAVATAR_DEFAULTS = ['404', 'mm', 'identicon', 'monsterid', 'wavatar', 'retro']
def gravatar(email_hash, size=100, default=None):

if not _display_gravatars():
return ''

if default is None:
default = config.get('ckan.gravatar_default', 'identicon')

Expand All @@ -556,6 +564,9 @@ def gravatar(email_hash, size=100, default=None):
% (email_hash, size, default)
)

def _display_gravatars():
return asbool(config.get('ckan.display_gravatars', 'true'))

def pager_url(page, partial=None, **kwargs):
routes_dict = _pylons_default_url.environ['pylons.routes_dict']
kwargs['controller'] = routes_dict['controller']
Expand Down

0 comments on commit 1a14ee4

Please sign in to comment.