This commit is contained in:
sawall 2014-10-03 01:41:09 -05:00
parent 086ba2a793
commit 1b9d4ffc66
2 changed files with 26 additions and 28 deletions

View file

@ -4,18 +4,23 @@ siglican
A static gallery generator plugin for Pelican, based on the Sigal
Colorbox/Galleria generator by Simon Conseil.
##Notes
* The bulk of the code is ported from [Sigal v0.8.0](http://sigal.saimon.org/).
* Removal of Sigal process handling, rewriting Sigal settings variables, and
integration as a Pelican Generator plugin by Scott Boone.
* The core python code used to generate gallery directories and images as well
as to populate the Jinja environment with album metadata is in beta. Jinja
templates are incomplete.
##How To
1. Create a 'siglican' directory in your base directory (at the same level
as 'content'.
2. Create an 'images' directory under siglican. Folders under this level are
albums.
3. Create album and image metadata, as desired.
4. Create theme directory inside of 'siglican'. Use the colorbox or galleria
theme as a starting point. Make sure that your Pelican theme's base.html
template has a 'head' block defined before </head>.
## To Do
1. Update galleria theme to work.
2. Change settings names to something other than SIGAL_*
3. Unit tests.
4. Logging cleanup.
5. General code and documentation cleanup.
5. General code and documentation cleanup.
##Credits
* The bulk of the code is ported from [Sigal v0.8.0](http://sigal.saimon.org/).
* Pelican integration by Scott Boone (sawall@github).

View file

@ -34,30 +34,23 @@ import os
import sys
from distutils.dir_util import copy_tree
from jinja2 import Environment, FileSystemLoader, ChoiceLoader, PrefixLoader
from jinja2 import Environment, FileSystemLoader
from jinja2.exceptions import TemplateNotFound
from .pkgmeta import __url__ as sigal_link
from .utils import url_from_path
class Writer(object):
"""Generate html pages for each directory of images."""
"""Generates html pages for albums and copies static theme files to output."""
def __init__(self, settings, theme, index_title=''):
self.settings = settings
self.theme = theme
self.output_dir = settings['SIGAL_DESTINATION']
self.index_title = index_title
self.output_dir = settings['SIGAL_DESTINATION']
self.logger = logging.getLogger(__name__)
# check for a custom theme in ./sigal/themes, if not found, look for a
# default in the sigal_theme/themes plugin directory
self.logger.info("siglican theme: %s", theme)
# pelican theme path merged with siglican theme path
theme_paths = [ os.path.join(self.theme, 'templates'),
os.path.join(self.settings['THEME'], 'templates') ]
self.logger.debug("siglican theme: %s", theme)
# setup jinja env
env_options = {'trim_blocks': True}
@ -67,21 +60,21 @@ class Writer(object):
except ValueError:
pass
### note: removed the default loader since sigal default templates
### were only used for google analytics, which have been
### removed from the siglican plugin port
# instantiate environment with pelican and siglican templates
theme_paths = [ os.path.join(self.theme, 'templates'),
os.path.join(self.settings['THEME'], 'templates') ]
env = Environment(loader=FileSystemLoader(theme_paths),
**env_options)
try:
self.template = env.get_template('album.html')
except TemplateNotFound:
self.logger.error('siglican: template album.html not found')
self.logger.error('siglican: album.html not found in templates')
sys.exit(1)
# Copy the theme files in the output dir
self.theme_path = os.path.join(settings['OUTPUT_PATH'], self.output_dir,
'static')
# copy the theme static files in the output dir
self.theme_path = os.path.join(settings['OUTPUT_PATH'],
self.output_dir,'static')
copy_tree(os.path.join(self.theme, 'static'), self.theme_path)
def generate_context(self, album):