mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Remove the dependency to pkgutil for the plugins
This commit is contained in:
parent
7184484488
commit
c5a63c953a
9 changed files with 84 additions and 89 deletions
0
pelican/plugins/__init__.py
Normal file
0
pelican/plugins/__init__.py
Normal file
23
pelican/plugins/global_license.py
Normal file
23
pelican/plugins/global_license.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
from blinker import signal
|
||||
|
||||
"""
|
||||
License plugin for Pelican
|
||||
==========================
|
||||
|
||||
Simply add license variable in article's context, which contain
|
||||
the license text.
|
||||
|
||||
Settings:
|
||||
---------
|
||||
|
||||
Add LICENSE to your settings file to define default license.
|
||||
|
||||
"""
|
||||
|
||||
def add_license(generator, metadata):
|
||||
if 'license' not in metadata.keys()\
|
||||
and 'LICENSE' in generator.settings.keys():
|
||||
metadata['license'] = generator.settings['LICENSE']
|
||||
|
||||
|
||||
signal('pelican_article_generate_context').connect(add_license)
|
||||
40
pelican/plugins/gravatar.py
Normal file
40
pelican/plugins/gravatar.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import hashlib
|
||||
|
||||
from blinker import signal
|
||||
"""
|
||||
Gravata plugin for Pelican
|
||||
==========================
|
||||
|
||||
Simply add author_gravatar variable in article's context, which contain
|
||||
the gravatar url.
|
||||
|
||||
Settings:
|
||||
---------
|
||||
|
||||
Add AUTHOR_EMAIL to your settings file to define default author email
|
||||
|
||||
Article metadata:
|
||||
------------------
|
||||
|
||||
:email: article's author email
|
||||
|
||||
If one of them are defined the author_gravatar variable is added to
|
||||
article's context.
|
||||
"""
|
||||
|
||||
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():
|
||||
gravatar_url = "http://www.gravatar.com/avatar/" + \
|
||||
hashlib.md5(metadata['email'].lower()).hexdigest()
|
||||
metadata["author_gravatar"] = gravatar_url
|
||||
|
||||
|
||||
def register():
|
||||
signal('pelican_article_generate_context').connect(add_gravatar)
|
||||
8
pelican/plugins/initialized.py
Normal file
8
pelican/plugins/initialized.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
from blinker import signal
|
||||
|
||||
|
||||
def test(sender):
|
||||
print "%s initialized !!" % sender
|
||||
|
||||
def register():
|
||||
signal('pelican_initialized').connect(test)
|
||||
Loading…
Add table
Add a link
Reference in a new issue