Add an init subcommand, to copy a sample config file in the current directory.
This commit is contained in:
@@ -103,7 +103,7 @@ The configuration for the gallery must be set in ``<input_dir>/sigal.conf.py``.
|
||||
An example file with explanations on the settings is available in
|
||||
``tests/sample/sigal.conf.py`` and is shown below:
|
||||
|
||||
.. literalinclude:: ../tests/sample/sigal.conf.py
|
||||
.. literalinclude:: ../sigal/templates/sigal.conf.py
|
||||
:language: python
|
||||
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ __author__ = "Simon Conseil"
|
||||
__version__ = "0.2"
|
||||
__license__ = "MIT"
|
||||
|
||||
import codecs
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
@@ -67,6 +68,17 @@ def init_logging(level=logging.INFO):
|
||||
logger.addHandler(handler)
|
||||
|
||||
|
||||
def init():
|
||||
"""Copy a sample config file in the current directory."""
|
||||
|
||||
from pkg_resources import resource_string
|
||||
conf = resource_string(__name__, 'templates/sigal.conf.py')
|
||||
|
||||
with codecs.open('sigal.conf.py', 'w', 'utf-8') as f:
|
||||
f.write(conf)
|
||||
print "Sample config file created: sigal.conf.py"
|
||||
|
||||
|
||||
@arg('input-dir', help='Input directory')
|
||||
@arg('output-dir', nargs='?', default='_build',
|
||||
help='Output directory (default: _build/)')
|
||||
@@ -136,5 +148,5 @@ def serve(path):
|
||||
def main():
|
||||
parser = ArghParser(description='Simple static gallery generator.',
|
||||
version=__version__)
|
||||
parser.add_commands([build, serve])
|
||||
parser.add_commands([init, build, serve])
|
||||
parser.dispatch()
|
||||
|
||||
55
sigal/templates/sigal.conf.py
Normal file
55
sigal/templates/sigal.conf.py
Normal file
@@ -0,0 +1,55 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# All configuration values have a default; values that are commented out serve
|
||||
# to show the default. Default values are specified when modified in this
|
||||
# example config file
|
||||
|
||||
# Theme :
|
||||
# - colorbox (default), galleria, or the path to a custom theme directory
|
||||
theme = 'galleria'
|
||||
|
||||
# Size of resized image
|
||||
img_size = (640, 480)
|
||||
|
||||
# Generate thumbnails
|
||||
# make_thumbs = True
|
||||
|
||||
# Subdirectory of the thumbnails
|
||||
# thumb_dir = 'thumbnails'
|
||||
|
||||
# Prefix and/or suffix for thumbnail names (default: '')
|
||||
# thumb_prefix =
|
||||
# thumb_suffix = '.tn'
|
||||
|
||||
# Thumbnail size (default: (150, 112))
|
||||
thumb_size = (200, 150)
|
||||
|
||||
# Crop the image to fill the box
|
||||
# thumb_fit = True
|
||||
|
||||
# Keep original image (default: False)
|
||||
# keep_orig = True
|
||||
|
||||
# Subdirectory for original images
|
||||
# orig_dir = 'original'
|
||||
|
||||
# Jpeg options
|
||||
# jpg_options = {'quality': 85,
|
||||
# 'optimize': True,
|
||||
# 'progressive': True}
|
||||
|
||||
# Add index.html to the URLs
|
||||
# index_in_url = False
|
||||
|
||||
# A list of links (tuples (title, URL))
|
||||
# links = [('Example link', 'http://example.org'),
|
||||
# ('Another link', 'http://example.org')]
|
||||
|
||||
# Keep exif metadatas in output image (default: False)
|
||||
# copy_exif = True
|
||||
|
||||
# Add a copyright text on the image (default: '')
|
||||
# copyright = "An example copyright message"
|
||||
|
||||
# Google Analytics tracking code (UA-xxxx-x)
|
||||
# google_analytics = ''
|
||||
Reference in New Issue
Block a user