import plugins from core and restructure repo

This commit is contained in:
Deniz Turgut
2013-04-10 19:12:31 -04:00
parent 66e83158ba
commit 9e70c17839
135 changed files with 2628 additions and 204 deletions

15
gravatar/Readme.rst Normal file
View File

@@ -0,0 +1,15 @@
Gravatar
--------
This plugin assigns the ``author_gravatar`` variable to the Gravatar URL and
makes the variable available within the article's context. You can add
``AUTHOR_EMAIL`` to your settings file to define the default author's email
address. Obviously, that email address must be associated with a Gravatar
account.
Alternatively, you can provide an email address from within article metadata::
:email: john.doe@example.com
If the email address is defined via at least one of the two methods above,
the ``author_gravatar`` variable is added to the article's context.

1
gravatar/__init__.py Normal file
View File

@@ -0,0 +1 @@
from .gravatar import *

31
gravatar/gravatar.py Normal file
View File

@@ -0,0 +1,31 @@
"""
Gravatar plugin for Pelican
===========================
This plugin assigns the ``author_gravatar`` variable to the Gravatar URL and
makes the variable available within the article's context.
"""
import hashlib
import six
from pelican import signals
def add_gravatar(generator, metadata):
#first check email
if 'email' not in metadata.keys()\
and 'AUTHOR_EMAIL' in generator.settings.keys():
metadata['email'] = generator.settings['AUTHOR_EMAIL']
#then add gravatar url
if 'email' in metadata.keys():
email_bytes = six.b(metadata['email']).lower()
gravatar_url = "http://www.gravatar.com/avatar/" + \
hashlib.md5(email_bytes).hexdigest()
metadata["author_gravatar"] = gravatar_url
def register():
signals.article_generate_context.connect(add_gravatar)