GithubHelp home page GithubHelp logo

yangyubo / django-gravatar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from twaddington/django-gravatar

0.0 2.0 0.0 126 KB

WARN: DO NOT use this repo, it's a fork of twaddington's django-gravatar, used for sending pull request to upstream.

Home Page: https://github.com/twaddington/django-gravatar

License: MIT License

Python 100.00%

django-gravatar's Introduction

django-gravatar

A lightweight django-gravatar app. Includes helper methods for interacting with gravatars outside of template code.

image

Features

  • Helper methods for constructing a gravatar url and checking an email for an existing gravatar
  • Templatetags for generating a gravatar url or gravatar <img> tag.
  • Full test suite!

Installing

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

url = get_gravatar_url('[email protected]', size=150)
gravatar_exists = has_gravatar('[email protected]')

Use in templates:

{% load gravatar %}

{% gravatar_url user.email 150 %}
# https://secure.gravatar.com/avatar/hash.jpg?size=150

{% gravatar user.email 150 %}
# <img class="gravatar" src="https://secure.gravatar.com/avatar/hash.jpg?size=150" width="150" height="150" alt="" />

{% gravatar user.email 150 "[email protected]" %}
# <img class="gravatar" src="https://secure.gravatar.com/avatar/hash.jpg?size=150" width="150" height="150" alt="[email protected]" />

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.

django-gravatar's People

Contributors

bouke avatar jyaganeh avatar msabramo avatar twaddington avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.