cleanup
This commit is contained in:
parent
086ba2a793
commit
1b9d4ffc66
2 changed files with 26 additions and 28 deletions
21
README.md
21
README.md
|
@ -4,14 +4,15 @@ siglican
|
||||||
A static gallery generator plugin for Pelican, based on the Sigal
|
A static gallery generator plugin for Pelican, based on the Sigal
|
||||||
Colorbox/Galleria generator by Simon Conseil.
|
Colorbox/Galleria generator by Simon Conseil.
|
||||||
|
|
||||||
##Notes
|
##How To
|
||||||
|
1. Create a 'siglican' directory in your base directory (at the same level
|
||||||
* The bulk of the code is ported from [Sigal v0.8.0](http://sigal.saimon.org/).
|
as 'content'.
|
||||||
* Removal of Sigal process handling, rewriting Sigal settings variables, and
|
2. Create an 'images' directory under siglican. Folders under this level are
|
||||||
integration as a Pelican Generator plugin by Scott Boone.
|
albums.
|
||||||
* The core python code used to generate gallery directories and images as well
|
3. Create album and image metadata, as desired.
|
||||||
as to populate the Jinja environment with album metadata is in beta. Jinja
|
4. Create theme directory inside of 'siglican'. Use the colorbox or galleria
|
||||||
templates are incomplete.
|
theme as a starting point. Make sure that your Pelican theme's base.html
|
||||||
|
template has a 'head' block defined before </head>.
|
||||||
|
|
||||||
## To Do
|
## To Do
|
||||||
1. Update galleria theme to work.
|
1. Update galleria theme to work.
|
||||||
|
@ -19,3 +20,7 @@ Colorbox/Galleria generator by Simon Conseil.
|
||||||
3. Unit tests.
|
3. Unit tests.
|
||||||
4. Logging cleanup.
|
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).
|
29
writer.py
29
writer.py
|
@ -34,30 +34,23 @@ import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from distutils.dir_util import copy_tree
|
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 jinja2.exceptions import TemplateNotFound
|
||||||
|
|
||||||
from .pkgmeta import __url__ as sigal_link
|
from .pkgmeta import __url__ as sigal_link
|
||||||
from .utils import url_from_path
|
from .utils import url_from_path
|
||||||
|
|
||||||
class Writer(object):
|
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=''):
|
def __init__(self, settings, theme, index_title=''):
|
||||||
self.settings = settings
|
self.settings = settings
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
self.output_dir = settings['SIGAL_DESTINATION']
|
|
||||||
self.index_title = index_title
|
self.index_title = index_title
|
||||||
|
self.output_dir = settings['SIGAL_DESTINATION']
|
||||||
self.logger = logging.getLogger(__name__)
|
self.logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# check for a custom theme in ./sigal/themes, if not found, look for a
|
self.logger.debug("siglican theme: %s", theme)
|
||||||
# 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') ]
|
|
||||||
|
|
||||||
# setup jinja env
|
# setup jinja env
|
||||||
env_options = {'trim_blocks': True}
|
env_options = {'trim_blocks': True}
|
||||||
|
@ -67,21 +60,21 @@ class Writer(object):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
### note: removed the default loader since sigal default templates
|
# instantiate environment with pelican and siglican templates
|
||||||
### were only used for google analytics, which have been
|
theme_paths = [ os.path.join(self.theme, 'templates'),
|
||||||
### removed from the siglican plugin port
|
os.path.join(self.settings['THEME'], 'templates') ]
|
||||||
env = Environment(loader=FileSystemLoader(theme_paths),
|
env = Environment(loader=FileSystemLoader(theme_paths),
|
||||||
**env_options)
|
**env_options)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.template = env.get_template('album.html')
|
self.template = env.get_template('album.html')
|
||||||
except TemplateNotFound:
|
except TemplateNotFound:
|
||||||
self.logger.error('siglican: template album.html not found')
|
self.logger.error('siglican: album.html not found in templates')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Copy the theme files in the output dir
|
# copy the theme static files in the output dir
|
||||||
self.theme_path = os.path.join(settings['OUTPUT_PATH'], self.output_dir,
|
self.theme_path = os.path.join(settings['OUTPUT_PATH'],
|
||||||
'static')
|
self.output_dir,'static')
|
||||||
copy_tree(os.path.join(self.theme, 'static'), self.theme_path)
|
copy_tree(os.path.join(self.theme, 'static'), self.theme_path)
|
||||||
|
|
||||||
def generate_context(self, album):
|
def generate_context(self, album):
|
||||||
|
|
Loading…
Reference in a new issue