Plugins must be specified with the plugins setting:
plugins = ['sigal.plugins.adjust', 'sigal.plugins.copyright']
You can either specify the name of the module which contains the plugin, or import the plugin before adding it to the list:
from sigal.plugins import copyright
plugins = ['sigal.plugins.adjust', copyright]
Note
Using an import like this will break the multiprocessing feature, because the settings dict must be serializable. So in most cases you should prefer the first option.
The plugin_paths setting can be used to specify paths to search for plugins (if they are not in the python path).
Plugins are based on signals with the blinker library. A plugin must subscribe to a signal (the list is given below). New signals can be added if need. See an example with the copyright plugin:
# -*- coding: utf-8 -*-
"""Plugin which add a copyright to the image.
Settings:
- ``copyright``: the copyright text.
TODO: Add more settings (font, size, ...)
"""
import logging
from PIL import ImageDraw
from sigal import signals
logger = logging.getLogger(__name__)
def add_copyright(img, settings=None):
logger.debug('Adding copyright to %r', img)
draw = ImageDraw.Draw(img)
draw.text((5, img.size[1] - 15), settings['copyright'])
return img
def register(settings):
if settings.get('copyright'):
signals.img_resized.connect(add_copyright)
else:
logger.warning('Copyright text is not set')
Called after the Album is initialized.
Parameters: | album – the Album object. |
---|
Called after the gallery is initialized.
Parameters: | gallery – the Gallery object. |
---|
Called after the Media (Image or Video) is initialized.
Parameters: | media – the media object. |
---|
Called after the gallery is build (after media are resized and html files are written).
Parameters: | gallery – the Gallery object. |
---|
Called after the image is resized. This signal work differently, the modified image object must be returned by the registered funtion.
Parameters: |
|
---|
Plugin which adjust the image after resizing.
Based on pilkit’s Adjust processor.
Settings:
adjust_options = {'color': 1.0,
'brightness': 1.0,
'contrast': 1.0,
'sharpness': 1.0}
Plugin which add a copyright to the image.
Settings:
TODO: Add more settings (font, size, ...)
Plugin which generates HTML pages for each image.
Currently this plugin can be used only with the colorbox theme, the other themes have to be adapted.
For themes, the previous_media and next_media variables contain the previous/next Media objects.
Plugin to upload generated files to Amazon S3.
This plugin requires boto. All generated files are uploaded to a specified S3 bucket. When using this plugin you have to make sure that the bucket already exists and the you have access to the S3 bucket. The access credentials are managed by boto and can be given as environment variables, configuration files etc. More information can be found on the boto documentation.
Settings (all settings are wrapped in upload_s3_options dict):
bucket: The to-be-used bucket for uploading.
private, public-read, public-read-write, authenticated-read
or if already uploaded files should be skipped.
control should be set by default
cache control hould be set for media files