From 1b9d4ffc66738614f4edcb2181e39cce39359adb Mon Sep 17 00:00:00 2001 From: sawall Date: Fri, 3 Oct 2014 01:41:09 -0500 Subject: [PATCH] cleanup --- README.md | 23 ++++++++++++++--------- writer.py | 31 ++++++++++++------------------- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 31cce37..45575c3 100644 --- a/README.md +++ b/README.md @@ -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 . ## 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. \ No newline at end of file +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). \ No newline at end of file diff --git a/writer.py b/writer.py index 3367d55..dff8b7d 100644 --- a/writer.py +++ b/writer.py @@ -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):