Flask-Gravatar
**************

This is small and simple integration gravatar into flask.


Contents
========

* Installation

* Usage


Installation
------------

Flask-Gravatar is on PyPI so all you need is:

   $ pip install Flask-Gravatar

The development version can be downloaded from its page at GitHub.

   $ git clone https://github.com/zzzsochi/flask-gravatar.git
   $ cd flask-gravatar
   $ python setup.py develop
   $ ./run-tests.sh


Usage
-----

Initialize with flask application and default parameters:

   gravatar = Gravatar(app,
                       size=100,
                       rating='g',
                       default='retro',
                       force_default=False,
                       force_lower=False,
                       use_ssl=False,
                       base_url=None)

Alternatively, the default parameters can be read from the application
config values in *GRAVATAR_SIZE*, *GRAVATAR_RATING*,
*GRAVATAR_DEFAULT*, *GRAVATAR_FORCE_DEFAULT*, *GRAVATAR_FORCE_LOWER*,
*GRAVATAR_USE_SSL*, and *GRAVATAR_BASE_URL*.

Then in your template:

   {{ 'zzz.sochi@gmail.com' | gravatar }}

Bigger and adult:

   {{ 'zzz.sochi@gmail.com' | gravatar(size=200, rating='x') }}


Parameters
==========

All parameters are described in gravatar documentation.


API
---

class flask_gravatar.Gravatar(app, size=100, rating='g', default='retro', force_default=False, force_lower=False)

   Simple object for create gravatar link.

   Parameters:
      * **app** (*flask.Flask*) -- Your Flask app instance

      * **size** (*str*) -- Default size for avatar

      * **rating** (*str*) -- Default rating

      * **default** (*str*) -- Default type for unregistred emails

      * **force_default** (*bool*) -- Build only default avatars

      * **force_lower** (*bool*) -- Make email.lower() before build
        link

   __call__(email, **kw)

      Build gravatar link.

      Parameters:
         * **email** -- Email for create link

         * **kw** -- Reload defaults

   Default parameters. May change in runtime.

   size

   rating

   default

   force_default

   force_lower


Changes
-------

Version 0.5.0 (released 2018-01-05)

* Try to read configuration values from application config if a
  context is available otherwise return an instance config or
  extension default. (pull #23)

* Package refresh - testing Python 3.6, fixed links, and much more.
  (pull #22)

Version 0.4.2 (released 2015-03-23)

* Set use_ssl default value according to request protocol. (pull
  #14)

* Improved documentation typo fixes. (pull #13 #18)

* Migration from flaskext.gravatar to flask_gravatar. (pull #11 #12)

Version 0.4.1 (released 2013-11-07)

* Added Python 3 support. (pull #9)

Version 0.4.0 (released 2013-08-09)

* Added custom url support. (pull #7)

* Use setuptools. (pull #6)

Version 0.3.0 (released 2013-03-23)

* Enabled registering multiple times in one process.

Version 0.2.4 (released 2012-11-28)

* Added init_app method.

* Fixed various bugs.

Version 0.2.3 (released 2011-11-29)

* Added HTTPS suppport.

Version 0.2.2 (released 2011-01-10)

* First public release.

* It works.


Contributing
------------

Bug reports, feature requests, and other contributions are welcome. If
you find a demonstrable problem that is caused by the code of this
library, please:

1. Search for already reported problems.

2. Check if the issue has been fixed or is still reproducible on
   the latest *master* branch.

3. Create an issue with **a test case**.

If you create a feature branch, you can run the tests to ensure
everything is operating correctly:

   $ ./run-tests.sh


License
-------

Flask-Gravatar is free software; you can redistribute it and/or modify
it under the terms of the Revised BSD License quoted below.

Copyright (C) 2011, 2012, 2013, 2014, 2015 Alexander Zelenyak.
Copyright (C) 2011 Max Countryman. Copyright (C) 2012 Honza Javorek.
Copyright (C) 2012 Klinkin. Copyright (C) 2013 Donald Stufft.
Copyright (C) 2013 Julien Kauffmann. Copyright (C) 2013 Li Chuangbo.
Copyright (C) 2013 Miguel Grinberg. Copyright (C) 2014 Andrew
Grigorev. Copyright (C) 2014 Nauman Ahmad. Copyright (C) 2014 Paul
Bonser. Copyright (C) 2014 Tom Powell. Copyright (C) 2015 CERN.

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
  notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright
  notice, this list of conditions and the following disclaimer in the
  documentation and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
  contributors may be used to endorse or promote products derived from
  this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.

In applying this license, CERN does not waive the privileges and
immunities granted to it by virtue of its status as an
Intergovernmental Organization or submit itself to any jurisdiction.


Authors
=======

* Alexander Zelenyak <zzz.sochi@gmail.com>

* Andrew Grigorev <andrew@ei-grad.ru>

* Donald Stufft <donald@stufft.io>

* Honza Javorek <honza@javorek.net>

* Jiri Kuncar <jiri.kuncar@gmail.com>

* Julien Kauffmann <julien.kauffmann@freelan.org>

* Klinkin <klinkin@gmail.com>

* Li Chuangbo <im@chuangbo.li>

* Max Countryman <max.countryman@gmail.com>

* Miguel Grinberg <miguelgrinberg50@gmail.com>

* Nauman Ahmad <nauman-ahmad@outlook.com>

* Paul Bonser <pib@paulbonser.com>

* Tom Powell <tom.powell@siafutg.com>
