Skip to content

Commit

Permalink
Merge pull request #125 from XenGi/patch-1
Browse files Browse the repository at this point in the history
Sort images by filename in Gallery plugin
  • Loading branch information
justinmayer committed Jan 8, 2014
2 parents 7e832f7 + dacc640 commit f30a68f
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions gallery/gallery.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,46 @@
import os
from pelican import signals


def add_gallery_post(generator):

contentpath = generator.settings.get('PATH')
contentpath = generator.settings.get('PATH')
gallerycontentpath = os.path.join(contentpath,'images/gallery')



for article in generator.articles:
if 'gallery' in article.metadata.keys():
album = article.metadata.get('gallery')
galleryimages = []

articlegallerypath=os.path.join(gallerycontentpath, album)
if(os.path.isdir(articlegallerypath)):

if(os.path.isdir(articlegallerypath)):
for i in os.listdir(articlegallerypath):
if os.path.isfile(os.path.join(os.path.join(gallerycontentpath, album), i)):
galleryimages.append(i)

article.album=album
article.galleryimages=galleryimages

article.album = album
article.galleryimages = sorted(galleryimages)


def generate_gallery_page(generator):

contentpath = generator.settings.get('PATH')
contentpath = generator.settings.get('PATH')
gallerycontentpath = os.path.join(contentpath,'images/gallery')



for page in generator.pages:
if page.metadata.get('template') == 'gallery':
gallery=dict()
gallery = dict()

for a in os.listdir(gallerycontentpath):
if os.path.isdir(os.path.join(gallerycontentpath, a)):

for i in os.listdir(os.path.join(gallerycontentpath, a)):
if os.path.isfile(os.path.join(os.path.join(gallerycontentpath, a), i)):
gallery.setdefault(a, []).append(i)

page.gallery=gallery
gallery[a].sort()

page.gallery=gallery


def register():
Expand Down

0 comments on commit f30a68f

Please sign in to comment.