Skip to content

Commit

Permalink
Add a setting and a cli option to specify the gallery title (ref #91).
Browse files Browse the repository at this point in the history
  • Loading branch information
saimn committed Aug 26, 2014
1 parent 32e6ba2 commit 1fe827e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Version 0.8.dev

Released on 2014-xx-xx.

- Add a setting and a cli option to specify the gallery title (``title`` and
``--title``) (ref #91).
- Add a mailing list at Librelist (sigal at librelist.com).
- Add an option to specify the port to use for the serve command.
- Replace argh with click.
Expand Down
7 changes: 6 additions & 1 deletion sigal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ def init(path):
help="Configuration file")
@option('-t', '--theme', help="Specify a theme directory, or a theme name for "
"the themes included with Sigal")
@option('--title', help="Title of the gallery (overrides the title setting.")
@option('-n', '--ncpu', help="Number of cpu to use (default: all)")
def build(source, destination, debug, verbose, force, config, theme, ncpu):
def build(source, destination, debug, verbose, force, config, theme, title,
ncpu):
"""Run sigal to process a directory.
If provided, 'source', 'destination' and 'theme' will override the
Expand Down Expand Up @@ -121,6 +123,9 @@ def build(source, destination, debug, verbose, force, config, theme, ncpu):
"directory.")
sys.exit(1)

if title:
settings['title'] = title

locale.setlocale(locale.LC_ALL, settings['locale'])
init_plugins(settings)

Expand Down
8 changes: 6 additions & 2 deletions sigal/gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,11 @@ def __init__(self, settings, ncpu=None):
self.logger.debug('Albums:\n%r', albums.values())
signals.gallery_initialized.send(self)

@property
def title(self):
"""Title of the gallery."""
return self.settings['title'] or self.albums['.'].title

def init_pool(self, ncpu):
try:
cpu_count = multiprocessing.cpu_count()
Expand Down Expand Up @@ -539,8 +544,7 @@ def build(self, force=False):
print('')

if self.settings['write_html']:
writer = Writer(self.settings, index_title=self.albums['.'].title)

writer = Writer(self.settings, index_title=self.title)
for album in self.albums.values():
writer.write(album)

Expand Down
1 change: 1 addition & 0 deletions sigal/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
'thumb_prefix': '',
'thumb_size': (200, 150),
'thumb_suffix': '',
'title': '',
'video_size': (480, 360),
'webm_options': ['-crf', '10', '-b:v', '1.6M',
'-qmin', '4', '-qmax', '63'],
Expand Down
5 changes: 5 additions & 0 deletions sigal/templates/sigal.conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
# to show the default. Default values are specified when modified in this
# example config file

# Gallery title. Can be set here or as the '--title' option of the `sigal
# build` command, or in the 'index.md' file of the source directory.
# The priority order is: cli option > settings file > index.md file
# title = "Sigal test gallery"

# Source directory. Can be set here or as the first argument of the `sigal
# build` command
source = 'pictures'
Expand Down

0 comments on commit 1fe827e

Please sign in to comment.