diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2014-04-05 06:34:44 -0300 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2014-04-05 06:34:44 -0300 |
commit | 8596183ba3df3acce0b258ac47ee0f2aef02301c (patch) | |
tree | c9a6c01da5395696d473f0e56923d731473dd20b | |
parent | f945a2abc11fc2f71edc3706bcce80b9e772b5a8 (diff) | |
parent | c376857d5274124b12c0d0f8b646d7f113a26042 (diff) | |
download | askbot-8596183ba3df3acce0b258ac47ee0f2aef02301c.tar.gz askbot-8596183ba3df3acce0b258ac47ee0f2aef02301c.tar.bz2 askbot-8596183ba3df3acce0b258ac47ee0f2aef02301c.zip |
Merge pull request #213 from michas2/master
make avatar URL configurable
-rw-r--r-- | askbot/conf/site_settings.py | 12 | ||||
-rw-r--r-- | askbot/models/__init__.py | 5 | ||||
-rw-r--r-- | askbot/templatetags/extra_tags.py | 3 |
3 files changed, 17 insertions, 3 deletions
diff --git a/askbot/conf/site_settings.py b/askbot/conf/site_settings.py index 0ac5b081..55c5c6cb 100644 --- a/askbot/conf/site_settings.py +++ b/askbot/conf/site_settings.py @@ -100,6 +100,18 @@ settings.register( ) settings.register( + livesettings.StringValue( + QA_SITE_SETTINGS, + 'AVATAR_URL', + description=_( + 'Base URL for the used avatar service' + ), + default='http://www.gravatar.com/avatar' + ) +) + + +settings.register( livesettings.BooleanValue( QA_SITE_SETTINGS, 'ENABLE_GREETING_FOR_ANON_USER', diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py index dab02fd1..a5094b78 100644 --- a/askbot/models/__init__.py +++ b/askbot/models/__init__.py @@ -265,13 +265,14 @@ User.add_to_class( ) ) -GRAVATAR_TEMPLATE = "//www.gravatar.com/avatar/%(gravatar)s?" + \ +GRAVATAR_TEMPLATE = "%(gravatar_url)s/%(gravatar)s?" + \ "s=%(size)d&d=%(type)s&r=PG" def user_get_gravatar_url(self, size): """returns gravatar url """ return GRAVATAR_TEMPLATE % { + 'gravatar_url': askbot_settings.AVATAR_URL, 'gravatar': self.gravatar, 'type': askbot_settings.GRAVATAR_TYPE, 'size': size, @@ -355,7 +356,7 @@ def user_strip_email_signature(self, text): return text def _check_gravatar(gravatar): - gravatar_url = "http://www.gravatar.com/avatar/%s?d=404" % gravatar + gravatar_url = askbot_settings.AVATAR_URL+"/%s?d=404" % gravatar code = urllib.urlopen(gravatar_url).getcode() if urllib.urlopen(gravatar_url).getcode() != 404: return 'g' #gravatar diff --git a/askbot/templatetags/extra_tags.py b/askbot/templatetags/extra_tags.py index a74438de..a29e36a2 100644 --- a/askbot/templatetags/extra_tags.py +++ b/askbot/templatetags/extra_tags.py @@ -15,7 +15,7 @@ GRAVATAR_TEMPLATE = ( '<a style="text-decoration:none" ' 'href="%(user_profile_url)s"><img class="gravatar" ' 'width="%(size)s" height="%(size)s" ' - 'src="//www.gravatar.com/avatar/%(gravatar_hash)s' + 'src="%(gravatar_url)s/%(gravatar_hash)s' '?s=%(size)s&d=%(gravatar_type)s&r=PG" ' 'title="%(username)s" ' 'alt="%(alt_text)s" /></a>') @@ -37,6 +37,7 @@ def gravatar(user, size): ) #safe_username = template.defaultfilters.urlencode(username) return mark_safe(GRAVATAR_TEMPLATE % { + 'gravatar_url': askbot_settings.AVATAR_URL, 'user_profile_url': user_profile_url, 'size': size, 'gravatar_hash': functions.get_from_dict_or_object(user, 'gravatar'), |