Skip to content

Commit

Permalink
Merge pull request #3599 from vonshednob/status-support-for-galleries
Browse files Browse the repository at this point in the history
Status support for galleries
  • Loading branch information
Kwpolska committed Feb 13, 2022
2 parents b42b2b4 + 5c52b9f commit 1bc90dc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
9 changes: 9 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
New in master
=============

Features
--------

* Gallery index pages support the `status` flag (Issue #3598)


New in v8.2.0
=============

Expand Down
7 changes: 5 additions & 2 deletions docs/manual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2089,8 +2089,11 @@ The ``conf.py`` options affecting images and gallery pages are these:
If you add a reST file in ``galleries/gallery_name/index.txt`` its contents will be
converted to HTML and inserted above the images in the gallery page. The
format is the same as for posts. You can use the ``title`` and ``previewimage``
metadata fields to change how the gallery is shown.
format is the same as for posts. You can use the ``title``, ``previewimage``, and
``status`` metadata fields to change how the gallery is shown.

If the ``status`` is ``private``, ``draft``, or ``publish_later``, the
gallery will not appear in the index, the RSS feeds, nor in the sitemap.

If you add some image filenames in ``galleries/gallery_name/exclude.meta``, they
will be excluded in the gallery page.
Expand Down
8 changes: 8 additions & 0 deletions nikola/plugins/task/galleries.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def set_site(self, site):
'exif_whitelist': site.config['EXIF_WHITELIST'],
'preserve_icc_profiles': site.config['PRESERVE_ICC_PROFILES'],
'index_path': site.config['INDEX_PATH'],
'index_file': site.config['INDEX_FILE'],
'disable_indexes': site.config['DISABLE_INDEXES'],
'galleries_use_thumbnail': site.config['GALLERIES_USE_THUMBNAIL'],
'galleries_default_thumbnail': site.config['GALLERIES_DEFAULT_THUMBNAIL'],
Expand Down Expand Up @@ -270,6 +271,10 @@ def gen_tasks(self):
for path, folder in folder_list:
fpost = self.parse_index(path, input_folder, output_folder)
if fpost:
# do not add galleries to the folders that are either
# of these states (#3598)
if fpost.is_draft or fpost.is_private or fpost.publish_later:
continue
ft = fpost.title(lang) or folder
else:
ft = folder
Expand Down Expand Up @@ -522,6 +527,9 @@ def parse_index(self, gallery, input_folder, output_folder):
post.meta[lang]['title'] = os.path.split(gallery)[1]
# Register the post (via #2417)
self.site.post_per_input_file[index_path] = post
# Register post for the sitemap, too (#3598)
index_output = os.path.join(gallery, self.kw['index_file'])
self.site.post_per_file[index_output] = post
else:
post = None
return post
Expand Down

0 comments on commit 1bc90dc

Please sign in to comment.