django-gravatar2-1.4.2/ 0000755 0000765 0000024 00000000000 13136460363 015463 5 ustar tristan staff 0000000 0000000 django-gravatar2-1.4.2/django_gravatar/ 0000755 0000765 0000024 00000000000 13136460363 020614 5 ustar tristan staff 0000000 0000000 django-gravatar2-1.4.2/django_gravatar/__init__.py 0000644 0000765 0000024 00000000000 13136455566 022724 0 ustar tristan staff 0000000 0000000 django-gravatar2-1.4.2/django_gravatar/compat.py 0000644 0000765 0000024 00000001201 13136455566 022454 0 ustar tristan staff 0000000 0000000 """
This module provides compatibility with older versions of Django and Python
"""
try:
from urllib.parse import urlparse, parse_qs, quote_plus, urlencode
except ImportError: # Python 2
from urlparse import urlparse, parse_qs
from urllib import quote_plus, urlencode
try:
from urllib.request import Request, urlopen
except ImportError: # Python 2
from urllib2 import Request, urlopen
try:
from urllib.error import HTTPError
except ImportError: # Python 2
from urllib2 import HTTPError
try:
from urllib.error import URLError
except ImportError: # Python 2
from urllib2 import URLError
django-gravatar2-1.4.2/django_gravatar/helpers.py 0000644 0000765 0000024 00000006533 13136455566 022650 0 ustar tristan staff 0000000 0000000 import hashlib
from django.conf import settings
from .compat import urlencode, urlopen, Request, HTTPError, URLError
# These options can be used to change the default image if no gravatar is found
GRAVATAR_DEFAULT_IMAGE_404 = '404'
GRAVATAR_DEFAULT_IMAGE_MYSTERY_MAN = 'mm'
GRAVATAR_DEFAULT_IMAGE_IDENTICON = 'identicon'
GRAVATAR_DEFAULT_IMAGE_MONSTER = 'monsterid'
GRAVATAR_DEFAULT_IMAGE_WAVATAR = 'wavatar'
GRAVATAR_DEFAULT_IMAGE_RETRO = 'retro'
# These options can be used to restrict gravatar content
GRAVATAR_RATING_G = 'g'
GRAVATAR_RATING_PG = 'pg'
GRAVATAR_RATING_R = 'r'
GRAVATAR_RATING_X = 'x'
# Get Gravatar base url from settings.py
GRAVATAR_URL = getattr(settings, 'GRAVATAR_URL', 'http://www.gravatar.com/')
GRAVATAR_SECURE_URL = getattr(settings, 'GRAVATAR_SECURE_URL', 'https://secure.gravatar.com/')
# Get user defaults from settings.py
GRAVATAR_DEFAULT_SIZE = getattr(settings, 'GRAVATAR_DEFAULT_SIZE', 80)
GRAVATAR_DEFAULT_IMAGE = getattr(settings, 'GRAVATAR_DEFAULT_IMAGE',
GRAVATAR_DEFAULT_IMAGE_MYSTERY_MAN)
GRAVATAR_DEFAULT_RATING = getattr(settings, 'GRAVATAR_DEFAULT_RATING',
GRAVATAR_RATING_G)
GRAVATAR_DEFAULT_SECURE = getattr(settings, 'GRAVATAR_DEFAULT_SECURE', True)
def calculate_gravatar_hash(email):
# Calculate the email hash
enc_email = email.strip().lower().encode("utf-8")
email_hash = hashlib.md5(enc_email).hexdigest()
return email_hash
def get_gravatar_url(email, size=GRAVATAR_DEFAULT_SIZE, default=GRAVATAR_DEFAULT_IMAGE,
rating=GRAVATAR_DEFAULT_RATING, secure=GRAVATAR_DEFAULT_SECURE):
"""
Builds a url to a gravatar from an email address.
:param email: The email to fetch the gravatar for
:param size: The size (in pixels) of the gravatar to fetch
:param default: What type of default image to use if the gravatar does not exist
:param rating: Used to filter the allowed gravatar ratings
:param secure: If True use https, otherwise plain http
"""
if secure:
url_base = GRAVATAR_SECURE_URL
else:
url_base = GRAVATAR_URL
# Calculate the email hash
email_hash = calculate_gravatar_hash(email)
# Build querystring
query_string = urlencode({
's': str(size),
'd': default,
'r': rating,
})
# Build url
url = '{base}avatar/{hash}.jpg?{qs}'.format(base=url_base,
hash=email_hash, qs=query_string)
return url
def has_gravatar(email):
"""
Returns True if the user has a gravatar, False if otherwise
"""
# Request a 404 response if the gravatar does not exist
url = get_gravatar_url(email, default=GRAVATAR_DEFAULT_IMAGE_404)
# Verify an OK response was received
try:
request = Request(url)
request.get_method = lambda: 'HEAD'
return 200 == urlopen(request).code
except (HTTPError, URLError):
return False
def get_gravatar_profile_url(email, secure=GRAVATAR_DEFAULT_SECURE):
"""
Builds a url to a gravatar profile from an email address.
:param email: The email to fetch the gravatar for
:param secure: If True use https, otherwise plain http
"""
if secure:
url_base = GRAVATAR_SECURE_URL
else:
url_base = GRAVATAR_URL
# Calculate the email hash
email_hash = calculate_gravatar_hash(email)
# Build url
url = '{base}{hash}'.format(base=url_base, hash=email_hash)
return url
django-gravatar2-1.4.2/django_gravatar/models.py 0000644 0000765 0000024 00000000025 13136455566 022457 0 ustar tristan staff 0000000 0000000 """Stub models.py"""
django-gravatar2-1.4.2/django_gravatar/templatetags/ 0000755 0000765 0000024 00000000000 13136460363 023306 5 ustar tristan staff 0000000 0000000 django-gravatar2-1.4.2/django_gravatar/templatetags/__init__.py 0000644 0000765 0000024 00000000000 13136455566 025416 0 ustar tristan staff 0000000 0000000 django-gravatar2-1.4.2/django_gravatar/templatetags/gravatar.py 0000644 0000765 0000024 00000003035 13136455566 025501 0 ustar tristan staff 0000000 0000000 from django import template
from django.utils.html import escape
from django.utils.safestring import mark_safe
from ..helpers import GRAVATAR_DEFAULT_SIZE, get_gravatar_profile_url, get_gravatar_url
# Get template.Library instance
register = template.Library()
def gravatar_url(user_or_email, size=GRAVATAR_DEFAULT_SIZE):
""" Builds a gravatar url from an user or email """
if hasattr(user_or_email, 'email'):
email = user_or_email.email
else:
email = user_or_email
try:
return escape(get_gravatar_url(email=email, size=size))
except:
return ''
def gravatar(user_or_email, size=GRAVATAR_DEFAULT_SIZE, alt_text='', css_class='gravatar'):
""" Builds an gravatar
tag from an user or email """
if hasattr(user_or_email, 'email'):
email = user_or_email.email
else:
email = user_or_email
try:
url = escape(get_gravatar_url(email=email, size=size))
except:
return ''
return mark_safe(
'
'.format(
css_class=css_class, src=url, width=size, height=size, alt=alt_text
)
)
def gravatar_profile_url(user_or_email):
if hasattr(user_or_email, 'email'):
email = user_or_email.email
else:
email = user_or_email
try:
return get_gravatar_profile_url(email)
except:
return ''
register.simple_tag(gravatar_url)
register.simple_tag(gravatar)
register.simple_tag(gravatar_profile_url)
django-gravatar2-1.4.2/django_gravatar/tests.py 0000644 0000765 0000024 00000013062 13136455566 022343 0 ustar tristan staff 0000000 0000000 from django.template import Context, Template
from django.test import TestCase
from django.utils.html import escape
from .compat import parse_qs, quote_plus, urlparse
from .helpers import *
class TestGravatarHelperMethods(TestCase):
def test_gravatar_hash_generation(self):
"""
Verify the generation of hash from email string.
"""
email = "MyEmailAddress@example.com"
email_hash = "0bc83cb571cd1c50ba6f3e8a78ef1346"
self.assertEqual(calculate_gravatar_hash(email), email_hash)
self.assertEqual(calculate_gravatar_hash(email), calculate_gravatar_hash(email.lower()))
def test_gravatar_url(self):
"""
Verify that the gravatar_url method returns the expected output.
"""
email = "joe@example.com"
email_upper = "JOE@example.com"
email_strip = " JOE@example.com "
# Construct the url
url = get_gravatar_url(email)
# Verify email is properly sanitized
self.assertEqual(url, get_gravatar_url(email_upper))
self.assertEqual(url, get_gravatar_url(email_strip))
# Parse query string from url
urlp = urlparse(url)
qs = parse_qs(urlp.query)
# Verify the correct query arguments are included with the proper defaults
self.assertTrue('s' in qs)
self.assertTrue('d' in qs)
self.assertTrue('r' in qs)
self.assertEqual(qs.get('s').pop(), str(GRAVATAR_DEFAULT_SIZE))
self.assertEqual(qs.get('d').pop(), GRAVATAR_DEFAULT_IMAGE)
self.assertEqual(qs.get('r').pop(), GRAVATAR_DEFAULT_RATING)
# Verify the correct protocol is used
if GRAVATAR_DEFAULT_SECURE:
self.assertTrue(GRAVATAR_SECURE_URL in url)
else:
self.assertTrue(GRAVATAR_URL in url)
# Verify that a url value for default is urlencoded
default_url = 'https://www.example.com/default.jpg'
url = get_gravatar_url(email, default=default_url)
# Verify urlencoding
self.assertTrue(quote_plus(default_url) in url)
def test_has_gravatar(self):
"""
Verify that the has_gravatar helper method correctly
determines if a user has a gravatar or not.
"""
bad_email = 'eve@example.com'
good_email = 'matt@automattic.com'
self.assertFalse(has_gravatar(bad_email))
self.assertTrue(has_gravatar(good_email))
def test_gravatar_profile_url(self):
"""
Verify that the get_gravatar_profile_url helper method correctly
generates a profile url for gravatar user.
"""
email = 'joe@example.com'
profile_url = get_gravatar_profile_url(email)
email_hash = calculate_gravatar_hash(email)
self.assertTrue(profile_url.endswith(email_hash))
class TestGravatarTemplateTags(TestCase):
def test_gravatar_url(self):
email = 'matt@automattic.com'
context = Context({'email': email})
t = Template("{% load gravatar %}{% gravatar_url email %}")
rendered = t.render(context)
self.assertEqual(rendered, escape(get_gravatar_url(email)))
def test_gravatar_img(self):
# Some defaults for testing
email = 'matt@automattic.com'
alt_text = 'some alt text'
css_class = 'gravatar-thumb'
size = 250
# Build context
context = Context({
'email': email,
'size': size,
'alt_text': alt_text,
'css_class': css_class,
})
# Default behavior
t = Template("{% load gravatar %}{% gravatar email %}")
rendered = t.render(context)
self.assertTrue(escape(get_gravatar_url(email)) in rendered)
self.assertTrue('class="gravatar"' in rendered)
self.assertTrue('alt=""' in rendered)
t = Template("{% load gravatar %}{% gravatar email size alt_text css_class %}")
rendered = t.render(context)
self.assertTrue('width="%s"' % (size,) in rendered)
self.assertTrue('height="%s"' % (size,) in rendered)
self.assertTrue('alt="%s"' % (alt_text,) in rendered)
self.assertTrue('class="%s"' % (css_class,) in rendered)
def test_gravatar_user_url(self):
# class with email attribute
class user:
email = 'bouke@webatoom.nl'
context = Context({'user': user})
t = Template("{% load gravatar %}{% gravatar_url user %}")
rendered = t.render(context)
self.assertEqual(rendered, escape(get_gravatar_url(user.email)))
def test_gravatar_user_img(self):
# class with email attribute
class user:
email = 'bouke@webatoom.nl'
context = Context({'user': user})
t = Template("{% load gravatar %}{% gravatar user %}")
rendered = t.render(context)
self.assertTrue(escape(get_gravatar_url(user.email)) in rendered)
def test_invalid_input(self):
context = Context({'email': None})
t = Template("{% load gravatar %}{% gravatar email %}")
rendered = t.render(context)
self.assertEqual("", rendered, "Invalid input should return empty result")
def test_gravatar_profile_url(self):
"""
Verify the profile url generated from template gravatar_profile_url tag.
"""
# class with email attribute
class user:
email = 'bouke@webatoom.nl'
context = Context({'user': user})
t = Template("{% load gravatar %}{% gravatar_profile_url user %}")
rendered = t.render(context)
self.assertEqual(rendered, escape(get_gravatar_profile_url(user.email)))
django-gravatar2-1.4.2/django_gravatar/views.py 0000644 0000765 0000024 00000000024 13136455566 022330 0 ustar tristan staff 0000000 0000000 """Stub views.py"""
django-gravatar2-1.4.2/django_gravatar2.egg-info/ 0000755 0000765 0000024 00000000000 13136460363 022370 5 ustar tristan staff 0000000 0000000 django-gravatar2-1.4.2/django_gravatar2.egg-info/dependency_links.txt 0000644 0000765 0000024 00000000001 13136460363 026436 0 ustar tristan staff 0000000 0000000
django-gravatar2-1.4.2/django_gravatar2.egg-info/PKG-INFO 0000644 0000765 0000024 00000011377 13136460363 023476 0 ustar tristan staff 0000000 0000000 Metadata-Version: 1.1
Name: django-gravatar2
Version: 1.4.2
Summary: Essential Gravatar support for Django. Features helper methods, templatetags and a full test suite!
Home-page: https://github.com/twaddington/django-gravatar
Author: Tristan Waddington
Author-email: tristan.waddington@gmail.com
License: MIT
Description: django-gravatar
================
.. image:: https://secure.travis-ci.org/twaddington/django-gravatar.png
:target: https://travis-ci.org/twaddington/django-gravatar
A lightweight django-gravatar app. Includes helper methods for interacting with gravatars outside of template code.
If you like this library and it's saved you some time, please consider
supporting further development with a `Gittip donation`_!
Features
--------
- Helper methods for constructing a gravatar url and checking an email for an existing gravatar
- Templatetags for generating a gravatar url or gravatar
tag.
- Full test suite!
Installing
----------
Install from PyPi:
You can pip install the app directly from GitHub:
::
$ pip install git+git://github.com/twaddington/django-gravatar.git#egg=DjangoGravatar
Alternatively, you can now install directly from PyPi!
::
$ pip install django-gravatar2
Make sure you install `django-gravatar2 `_ as
there are several other incompatible django-gravatar libraries available.
Add django_gravatar to your INSTALLED_APPS in settings.py:
::
INSTALLED_APPS = (
# ...
'django_gravatar',
)
Basic Usage
-----------
Use in code:
::
from django_gravatar.helpers import get_gravatar_url, has_gravatar, get_gravatar_profile_url, calculate_gravatar_hash
url = get_gravatar_url('alice@example.com', size=150)
gravatar_exists = has_gravatar('bob@example.com')
profile_url = get_gravatar_profile_url('alice@example.com')
email_hash = calculate_gravatar_hash('alice@example.com')
Use in templates:
::
{% load gravatar %}
{% gravatar_url user.email 150 %}
# https://secure.gravatar.com/avatar/hash.jpg?size=150
{% gravatar user.email 150 %}
#
{% gravatar user.email 150 "user@example.com" %}
#
{% gravatar_profile_url user.email %}
# https://secure.gravatar.com/hash
Configuring
-----------
The following options can be configured in your settings.py:
GRAVATAR_URL # Gravatar base url. Defaults to 'http://www.gravatar.com/'
GRAVATAR_SECURE_URL # Gravatar base secure https url. Defaults to 'https://secure.gravatar.com/'
GRAVATAR_DEFAULT_SIZE # Gravatar size in pixels. Defaults to '80'
GRAVATAR_DEFAULT_IMAGE # An image url or one of the following: 'mm', 'identicon', 'monsterid', 'wavatar', 'retro'. Defaults to 'mm'
GRAVATAR_DEFAULT_RATING # One of the following: 'g', 'pg', 'r', 'x'. Defaults to 'g'
GRAVATAR_DEFAULT_SECURE # True to use https by default, False for plain http. Defaults to True
Contributing
------------
Feel free to `fork django-gravatar `_
on GitHub! We'd love to see your pull requests. Please make sure you run
tests before submitting a patch.
.. _Gittip donation: https://www.gittip.com/twaddington/
Keywords: django gravatar avatar
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Framework :: Django
django-gravatar2-1.4.2/django_gravatar2.egg-info/SOURCES.txt 0000644 0000765 0000024 00000000707 13136460363 024260 0 ustar tristan staff 0000000 0000000 LICENSE
MANIFEST.in
README
README.rst
setup.cfg
setup.py
django_gravatar/__init__.py
django_gravatar/compat.py
django_gravatar/helpers.py
django_gravatar/models.py
django_gravatar/tests.py
django_gravatar/views.py
django_gravatar/templatetags/__init__.py
django_gravatar/templatetags/gravatar.py
django_gravatar2.egg-info/PKG-INFO
django_gravatar2.egg-info/SOURCES.txt
django_gravatar2.egg-info/dependency_links.txt
django_gravatar2.egg-info/top_level.txt django-gravatar2-1.4.2/django_gravatar2.egg-info/top_level.txt 0000644 0000765 0000024 00000000020 13136460363 025112 0 ustar tristan staff 0000000 0000000 django_gravatar
django-gravatar2-1.4.2/LICENSE 0000644 0000765 0000024 00000002105 13136455566 016477 0 ustar tristan staff 0000000 0000000 Copyright (c) 2013 Tristan Waddington
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
django-gravatar2-1.4.2/MANIFEST.in 0000644 0000765 0000024 00000000062 13136455566 017230 0 ustar tristan staff 0000000 0000000 include README
include README.rst
include LICENSE
django-gravatar2-1.4.2/PKG-INFO 0000644 0000765 0000024 00000011377 13136460363 016571 0 ustar tristan staff 0000000 0000000 Metadata-Version: 1.1
Name: django-gravatar2
Version: 1.4.2
Summary: Essential Gravatar support for Django. Features helper methods, templatetags and a full test suite!
Home-page: https://github.com/twaddington/django-gravatar
Author: Tristan Waddington
Author-email: tristan.waddington@gmail.com
License: MIT
Description: django-gravatar
================
.. image:: https://secure.travis-ci.org/twaddington/django-gravatar.png
:target: https://travis-ci.org/twaddington/django-gravatar
A lightweight django-gravatar app. Includes helper methods for interacting with gravatars outside of template code.
If you like this library and it's saved you some time, please consider
supporting further development with a `Gittip donation`_!
Features
--------
- Helper methods for constructing a gravatar url and checking an email for an existing gravatar
- Templatetags for generating a gravatar url or gravatar
tag.
- Full test suite!
Installing
----------
Install from PyPi:
You can pip install the app directly from GitHub:
::
$ pip install git+git://github.com/twaddington/django-gravatar.git#egg=DjangoGravatar
Alternatively, you can now install directly from PyPi!
::
$ pip install django-gravatar2
Make sure you install `django-gravatar2 `_ as
there are several other incompatible django-gravatar libraries available.
Add django_gravatar to your INSTALLED_APPS in settings.py:
::
INSTALLED_APPS = (
# ...
'django_gravatar',
)
Basic Usage
-----------
Use in code:
::
from django_gravatar.helpers import get_gravatar_url, has_gravatar, get_gravatar_profile_url, calculate_gravatar_hash
url = get_gravatar_url('alice@example.com', size=150)
gravatar_exists = has_gravatar('bob@example.com')
profile_url = get_gravatar_profile_url('alice@example.com')
email_hash = calculate_gravatar_hash('alice@example.com')
Use in templates:
::
{% load gravatar %}
{% gravatar_url user.email 150 %}
# https://secure.gravatar.com/avatar/hash.jpg?size=150
{% gravatar user.email 150 %}
#
{% gravatar user.email 150 "user@example.com" %}
#
{% gravatar_profile_url user.email %}
# https://secure.gravatar.com/hash
Configuring
-----------
The following options can be configured in your settings.py:
GRAVATAR_URL # Gravatar base url. Defaults to 'http://www.gravatar.com/'
GRAVATAR_SECURE_URL # Gravatar base secure https url. Defaults to 'https://secure.gravatar.com/'
GRAVATAR_DEFAULT_SIZE # Gravatar size in pixels. Defaults to '80'
GRAVATAR_DEFAULT_IMAGE # An image url or one of the following: 'mm', 'identicon', 'monsterid', 'wavatar', 'retro'. Defaults to 'mm'
GRAVATAR_DEFAULT_RATING # One of the following: 'g', 'pg', 'r', 'x'. Defaults to 'g'
GRAVATAR_DEFAULT_SECURE # True to use https by default, False for plain http. Defaults to True
Contributing
------------
Feel free to `fork django-gravatar `_
on GitHub! We'd love to see your pull requests. Please make sure you run
tests before submitting a patch.
.. _Gittip donation: https://www.gittip.com/twaddington/
Keywords: django gravatar avatar
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Framework :: Django
django-gravatar2-1.4.2/README 0000644 0000765 0000024 00000000027 13136455566 016353 0 ustar tristan staff 0000000 0000000 Please see README.rst.
django-gravatar2-1.4.2/README.rst 0000644 0000765 0000024 00000006062 13136455566 017167 0 ustar tristan staff 0000000 0000000 django-gravatar
================
.. image:: https://secure.travis-ci.org/twaddington/django-gravatar.png
:target: https://travis-ci.org/twaddington/django-gravatar
A lightweight django-gravatar app. Includes helper methods for interacting with gravatars outside of template code.
If you like this library and it's saved you some time, please consider
supporting further development with a `Gittip donation`_!
Features
--------
- Helper methods for constructing a gravatar url and checking an email for an existing gravatar
- Templatetags for generating a gravatar url or gravatar
tag.
- Full test suite!
Installing
----------
Install from PyPi:
You can pip install the app directly from GitHub:
::
$ pip install git+git://github.com/twaddington/django-gravatar.git#egg=DjangoGravatar
Alternatively, you can now install directly from PyPi!
::
$ pip install django-gravatar2
Make sure you install `django-gravatar2 `_ as
there are several other incompatible django-gravatar libraries available.
Add django_gravatar to your INSTALLED_APPS in settings.py:
::
INSTALLED_APPS = (
# ...
'django_gravatar',
)
Basic Usage
-----------
Use in code:
::
from django_gravatar.helpers import get_gravatar_url, has_gravatar, get_gravatar_profile_url, calculate_gravatar_hash
url = get_gravatar_url('alice@example.com', size=150)
gravatar_exists = has_gravatar('bob@example.com')
profile_url = get_gravatar_profile_url('alice@example.com')
email_hash = calculate_gravatar_hash('alice@example.com')
Use in templates:
::
{% load gravatar %}
{% gravatar_url user.email 150 %}
# https://secure.gravatar.com/avatar/hash.jpg?size=150
{% gravatar user.email 150 %}
#
{% gravatar user.email 150 "user@example.com" %}
#
{% gravatar_profile_url user.email %}
# https://secure.gravatar.com/hash
Configuring
-----------
The following options can be configured in your settings.py:
GRAVATAR_URL # Gravatar base url. Defaults to 'http://www.gravatar.com/'
GRAVATAR_SECURE_URL # Gravatar base secure https url. Defaults to 'https://secure.gravatar.com/'
GRAVATAR_DEFAULT_SIZE # Gravatar size in pixels. Defaults to '80'
GRAVATAR_DEFAULT_IMAGE # An image url or one of the following: 'mm', 'identicon', 'monsterid', 'wavatar', 'retro'. Defaults to 'mm'
GRAVATAR_DEFAULT_RATING # One of the following: 'g', 'pg', 'r', 'x'. Defaults to 'g'
GRAVATAR_DEFAULT_SECURE # True to use https by default, False for plain http. Defaults to True
Contributing
------------
Feel free to `fork django-gravatar `_
on GitHub! We'd love to see your pull requests. Please make sure you run
tests before submitting a patch.
.. _Gittip donation: https://www.gittip.com/twaddington/
django-gravatar2-1.4.2/setup.cfg 0000644 0000765 0000024 00000000075 13136460363 017306 0 ustar tristan staff 0000000 0000000 [wheel]
universal = 1
[egg_info]
tag_build =
tag_date = 0
django-gravatar2-1.4.2/setup.py 0000644 0000765 0000024 00000002275 13136460341 017177 0 ustar tristan staff 0000000 0000000 try:
from setuptools import setup
except ImportError:
from distutils.core import setup
setup(
name='django-gravatar2',
version='1.4.2',
description='Essential Gravatar support for Django. Features helper'
' methods, templatetags and a full test suite!',
long_description=open('README.rst').read(),
keywords='django gravatar avatar',
license='MIT',
author='Tristan Waddington',
author_email='tristan.waddington@gmail.com',
url='https://github.com/twaddington/django-gravatar',
packages=['django_gravatar', 'django_gravatar.templatetags'],
classifiers=[
'Development Status :: 5 - Production/Stable', # 4 Beta, 5 Production/Stable
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Framework :: Django',
]
)