diff --git a/gallery/README.md b/gallery/README.md index 09ac0fd..ecb4e83 100644 --- a/gallery/README.md +++ b/gallery/README.md @@ -16,7 +16,11 @@ Gallery Attach an album to an article/post by placing a gallery metadata tag with the name of the album. gallery:album_name - + +Optionaly you can also add (on one(1) line!) + + gallerycaptions:{'file1':'title1', 'file4':'title4'} + The template has access to the album name. article.album @@ -25,6 +29,10 @@ And the filename of images within an album. article.albumimages +And the titles associated to the pictures, as a dictionary. + + article.gallerycaptions + ###Gallery Page Create a page and a gallery template (named gallery.html). And inform pelican to use the gallery template for the page. @@ -43,7 +51,11 @@ The dictionary key is the name of the album and the lists contain the filenames.

{{ article.album }}

@@ -62,7 +74,13 @@ The dictionary key is the name of the album and the lists contain the filenames. title:Foo gallery:albumname - + +or, to add captions: + + title:Foo + gallery:albumname + gallerycaptions:{'file1':'title1', 'file4':'title4'} + ###pages/gallery.md title:All Images diff --git a/gallery/gallery.py b/gallery/gallery.py index 3bde1c5..d72c338 100644 --- a/gallery/gallery.py +++ b/gallery/gallery.py @@ -1,4 +1,5 @@ import os +import ast from pelican import signals @@ -11,6 +12,7 @@ def add_gallery_post(generator): if 'gallery' in article.metadata.keys(): album = article.metadata.get('gallery') galleryimages = [] + gallerycaptions = dict() articlegallerypath=os.path.join(gallerycontentpath, album) @@ -19,8 +21,12 @@ def add_gallery_post(generator): if os.path.isfile(os.path.join(os.path.join(gallerycontentpath, album), i)): galleryimages.append(i) + if 'gallerycaptions' in article.metadata.keys(): + gallerycaptions = ast.literal_eval(article.metadata.get('gallerycaptions')) + article.album = album article.galleryimages = sorted(galleryimages) + article.gallerycaptions = gallerycaptions def generate_gallery_page(generator):