././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1724970638.3248384 django_gravatar2-1.4.5/0000755000076500000240000000000014664173216014355 5ustar00tristanstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1724969270.0 django_gravatar2-1.4.5/LICENSE0000644000076500000240000000210514664170466015364 0ustar00tristanstaffCopyright (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. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1724969270.0 django_gravatar2-1.4.5/MANIFEST.in0000644000076500000240000000011414664170466016113 0ustar00tristanstaffinclude README include README.rst include LICENSE include example_project/* ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1724970638.3247836 django_gravatar2-1.4.5/PKG-INFO0000644000076500000240000001027714664173216015461 0ustar00tristanstaffMetadata-Version: 2.1 Name: django-gravatar2 Version: 1.4.5 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 Keywords: django gravatar avatar 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 Classifier: Programming Language :: Python :: 3 Classifier: Framework :: Django License-File: LICENSE django-gravatar ================ .. image:: https://travis-ci.org/twaddington/django-gravatar.svg?branch=master :target: https://travis-ci.org/twaddington/django-gravatar A lightweight django-gravatar app. Includes helper methods for interacting with gravatars outside of template code. **A Note on Continued Support** Hey Folks, I haven't actively maintained this project for some years now. Please let me know if there are security issues or regressions in basic functionality. I will do my best to address those. However, I don't have the time to invest in other changes to the project. Additionally, I haven't been involved in Django development in many years now. If you're interested in adopting this project please shoot me a message. --- Tristan 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" %} # 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. Run tests: :: $> cd example_project $> ./manage.py test django_gravatar ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1724969270.0 django_gravatar2-1.4.5/README0000644000076500000240000000002714664170466015240 0ustar00tristanstaffPlease see README.rst. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1724969270.0 django_gravatar2-1.4.5/README.rst0000644000076500000240000000666514664170466016065 0ustar00tristanstaffdjango-gravatar ================ .. image:: https://travis-ci.org/twaddington/django-gravatar.svg?branch=master :target: https://travis-ci.org/twaddington/django-gravatar A lightweight django-gravatar app. Includes helper methods for interacting with gravatars outside of template code. **A Note on Continued Support** Hey Folks, I haven't actively maintained this project for some years now. Please let me know if there are security issues or regressions in basic functionality. I will do my best to address those. However, I don't have the time to invest in other changes to the project. Additionally, I haven't been involved in Django development in many years now. If you're interested in adopting this project please shoot me a message. --- Tristan 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" %} # 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. Run tests: :: $> cd example_project $> ./manage.py test django_gravatar ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1724970638.3231711 django_gravatar2-1.4.5/django_gravatar/0000755000076500000240000000000014664173216017506 5ustar00tristanstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1724969270.0 django_gravatar2-1.4.5/django_gravatar/__init__.py0000644000076500000240000000000014664170466021611 0ustar00tristanstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1724969270.0 django_gravatar2-1.4.5/django_gravatar/compat.py0000644000076500000240000000120114664170466021341 0ustar00tristanstaff""" 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 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1724969270.0 django_gravatar2-1.4.5/django_gravatar/helpers.py0000644000076500000240000000653314664170466021535 0ustar00tristanstaffimport 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 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1724969270.0 django_gravatar2-1.4.5/django_gravatar/models.py0000644000076500000240000000002514664170466021344 0ustar00tristanstaff"""Stub models.py""" ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1724970638.3234286 django_gravatar2-1.4.5/django_gravatar/templatetags/0000755000076500000240000000000014664173216022200 5ustar00tristanstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1724969270.0 django_gravatar2-1.4.5/django_gravatar/templatetags/__init__.py0000644000076500000240000000000014664170466024303 0ustar00tristanstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1724969574.0 django_gravatar2-1.4.5/django_gravatar/templatetags/gravatar.py0000644000076500000240000000305514664171146024364 0ustar00tristanstafffrom 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( '{alt}'.format( css_class=css_class, src=url, width=size, height=size, alt=escape(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 escape(get_gravatar_profile_url(email)) except: return '' register.simple_tag(gravatar_url) register.simple_tag(gravatar) register.simple_tag(gravatar_profile_url) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1724970510.0 django_gravatar2-1.4.5/django_gravatar/tests.py0000644000076500000240000001530014664173016021217 0ustar00tristanstafffrom 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_img_xss(self): # Some defaults for testing email = 'matt@automattic.com' alt_text = '">' alt_text_escaped = '"><script>alert(1)</script>' 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_escaped,) 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))) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1724969270.0 django_gravatar2-1.4.5/django_gravatar/views.py0000644000076500000240000000002414664170466021215 0ustar00tristanstaff"""Stub views.py""" ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1724970638.324588 django_gravatar2-1.4.5/django_gravatar2.egg-info/0000755000076500000240000000000014664173216021262 5ustar00tristanstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1724970638.0 django_gravatar2-1.4.5/django_gravatar2.egg-info/PKG-INFO0000644000076500000240000001027714664173216022366 0ustar00tristanstaffMetadata-Version: 2.1 Name: django-gravatar2 Version: 1.4.5 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 Keywords: django gravatar avatar 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 Classifier: Programming Language :: Python :: 3 Classifier: Framework :: Django License-File: LICENSE django-gravatar ================ .. image:: https://travis-ci.org/twaddington/django-gravatar.svg?branch=master :target: https://travis-ci.org/twaddington/django-gravatar A lightweight django-gravatar app. Includes helper methods for interacting with gravatars outside of template code. **A Note on Continued Support** Hey Folks, I haven't actively maintained this project for some years now. Please let me know if there are security issues or regressions in basic functionality. I will do my best to address those. However, I don't have the time to invest in other changes to the project. Additionally, I haven't been involved in Django development in many years now. If you're interested in adopting this project please shoot me a message. --- Tristan 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" %} # 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. Run tests: :: $> cd example_project $> ./manage.py test django_gravatar ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1724970638.0 django_gravatar2-1.4.5/django_gravatar2.egg-info/SOURCES.txt0000644000076500000240000000103114664173216023141 0ustar00tristanstaffLICENSE 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 example_project/__init__.py example_project/manage.py example_project/settings.py././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1724970638.0 django_gravatar2-1.4.5/django_gravatar2.egg-info/dependency_links.txt0000644000076500000240000000000114664173216025330 0ustar00tristanstaff ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1724970638.0 django_gravatar2-1.4.5/django_gravatar2.egg-info/top_level.txt0000644000076500000240000000002014664173216024004 0ustar00tristanstaffdjango_gravatar ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1724970638.3243074 django_gravatar2-1.4.5/example_project/0000755000076500000240000000000014664173216017536 5ustar00tristanstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1724969270.0 django_gravatar2-1.4.5/example_project/__init__.py0000644000076500000240000000000014664170466021641 0ustar00tristanstaff././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1724969270.0 django_gravatar2-1.4.5/example_project/manage.py0000755000076500000240000000036214664170466021350 0ustar00tristanstaff#!/usr/bin/env python import os import sys if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") from django.core.management import execute_from_command_line execute_from_command_line(sys.argv) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1724969270.0 django_gravatar2-1.4.5/example_project/settings.py0000644000076500000240000001321414664170466021755 0ustar00tristanstaff# Django settings for {{ project_name }} project. import os PROJECT_DIR = os.path.dirname(os.path.abspath(__file__)) DEBUG = True TEMPLATE_DEBUG = DEBUG DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'sqlite.db', # Or path to database file if using sqlite3. 'USER': '', # Not used with sqlite3. 'PASSWORD': '', # Not used with sqlite3. 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. 'PORT': '', # Set to empty string for default. Not used with sqlite3. } } DOCKIT_BACKENDS = { 'default': { 'ENGINE': 'dockit.backends.mongo.backend.MongoDocumentStorage', 'USER': 'travis', 'PASSWORD': 'test', 'DB': 'mydb_test', 'HOST': '127.0.0.1', 'PORT': 27017, } } # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name # although not all choices may be available on all operating systems. # On Unix systems, a value of None will cause Django to use the same # timezone as the operating system. # If running in a Windows environment this must be set to the same as your # system time zone. TIME_ZONE = 'America/Chicago' # Language code for this installation. All choices can be found here: # http://www.i18nguy.com/unicode/language-identifiers.html LANGUAGE_CODE = 'en-us' # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale USE_L10N = True # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/home/media/media.lawrence.com/media/" MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media') # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" MEDIA_URL = '/media/' # Absolute path to the directory static files should be collected to. # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. # Example: "/home/media/media.lawrence.com/static/" STATIC_ROOT = '' # URL prefix for static files. # Example: "http://media.lawrence.com/static/" STATIC_URL = '/static/' # URL prefix for admin static files -- CSS, JavaScript and images. # Make sure to use a trailing slash. # Examples: "http://foo.com/static/admin/", "/static/admin/". ADMIN_MEDIA_PREFIX = '/static/admin/' # Additional locations of static files STATICFILES_DIRS = ( # Put strings here, like "/home/html/static" or "C:/www/django/static". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. ) # List of finder classes that know how to find static files in # various locations. STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', # 'django.contrib.staticfiles.finders.DefaultStorageFinder', ) # Make this unique, and don't share it with anybody. SECRET_KEY = 'example_project_test_key' # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', # 'django.template.loaders.eggs.Loader', ) MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', ) MIDDLEWARE = MIDDLEWARE_CLASSES # ROOT_URLCONF = 'urls' TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django_gravatar', # Uncomment the next line to enable the admin: 'django.contrib.admin', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', ) # A sample logging configuration. The only tangible logging # performed by this configuration is to send an email to # the site admins on every HTTP 500 error. # See http://docs.djangoproject.com/en/dev/topics/logging for # more details on how to customize your logging configuration. LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'mail_admins': { 'level': 'ERROR', 'class': 'django.utils.log.AdminEmailHandler' } }, 'loggers': { 'django.request': { 'handlers': ['mail_admins'], 'level': 'ERROR', 'propagate': True, }, } } TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': TEMPLATE_DIRS, 'OPTIONS': { 'debug': TEMPLATE_DEBUG, 'loaders': TEMPLATE_LOADERS, 'context_processors': ( 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ) }, }, ] ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1724970638.3250065 django_gravatar2-1.4.5/setup.cfg0000644000076500000240000000007514664173216016200 0ustar00tristanstaff[wheel] universal = 1 [egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1724970593.0 django_gravatar2-1.4.5/setup.py0000644000076500000240000000204614664173141016066 0ustar00tristanstafftry: from setuptools import setup except ImportError: from distutils.core import setup setup( name='django-gravatar2', version='1.4.5', 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', 'Programming Language :: Python :: 3', 'Framework :: Django', ] )