Code Monkey home page Code Monkey logo

chronossc / django-gravatar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from santa4nt/django-gravatar

1.0 2.0 0.0 119 KB

A reusable Django application that exports template tags to convert email addresses to Gravatar-backed avatars, as dynamically generated URLs. My plan is to add support to gravatar profile , and in future, caching. See http://github.com/DrMegahertz/django-gravatar/tree/cache for some local file caching implemented.

License: MIT License

Python 100.00%

django-gravatar's Introduction

Django Gravatar

django-gravatar is a Django application that exports template tags to convert email addresses to Gravatar-stored avatars, as dynamically generated hyperlinks.

This repo is intended to have some customizations, like gravatar profile support and caching. Go to end of doc to see some interesting coplementary info & links :)

By including the app, django_gravatar, in your settings module, you can load a custom templatetags module, gravatar_tags, to generate a Gravatar URL from an input of an email address and a set of optional parameters.

To load the custom tags into your template, include the following:

{% load gravatar_tags %}

Currently, this will enable the following tags:

{% gravatar_url <email> <params> %}
{% gravatar_url <email> %}

Where <email> is either a string variable or a string literal of an email address, and <params> is either an object or dictionary variable of the following set of parameters:

  • size -- corresponding to Gravatar parameter s, the value must be between 1 and 512, inclusive. The default is 80.
  • rating -- corresponding to Gravatar parameter r, the value must be in ('g', 'pg', 'r', 'x'). The default is 'g'.
  • default -- corresponding to Gravatar parameter d, the value must be in ('identicon', 'monsterid', 'wavatar', '404') or a valid URI. The default is nothing.

For size and rating, when the given value is already default (i.e., 80 or 'g', respectively), it will be omitted in the generated URL parameters.

If no <params> argument is supplied, the defaults will be used (that is, omitted to rely on Gravatar's default fallback values).

Example

Besides the django_gravatar directory, where the app logic is that you should include or point to in your project, this directory also includes a dummy project harness to demonstrate and/or test the app.

To demonstrate the example harness:

# from this directory
$ python example/manage.py runserver --pythonpath='.' \
  --settings='example.settings'

Then browse to:

http://localhost:8000/email/<[email protected]>

To run unit tests (one is included with the django_gravatar app), use the harness:

# from this directory
$ python example/manage.py test --pythonpath='.'

TODO

  • Add profile support
  • Add caching support
  • Add some pre-validation to know if avatar/profile exists

Links

Visit the main Mercurial repository at bitbucket.

Visit the original (not my) mirror Git repository at github.

Visit DrMegahertz repo for some local file caching implemented.

Visit Lance McNearney article to check some validation if is a valid gravatar.

django-gravatar's People

Contributors

chronossc avatar

Stargazers

 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.