Gytis Karčiauskas лет назад: 9
Родитель
Сommit
3b088dae4c
2 измененных файлов с 17 добавлено и 11 удалено
  1. 3 2
      gallery/README.md
  2. 14 9
      gallery/gallery.py

+ 3 - 2
gallery/README.md

@@ -7,9 +7,10 @@ Gallery
 ##How to Use
 
 1. Group images into folders, with each folder representing an album.
-2. Place all album folders within a folder named gallery, which resides within the images folder.
+2. Place all album folders within a folder, which should reside under content.
+3. Insert `GALLERY_PATH` to your `pelicanconf.py` and set a path to that folder. By default it is `images/gallery`.
 
-		./content/images/gallery/album_name
+		./content/images/gallery/{your albums}
 	
 ###Articles
 

+ 14 - 9
gallery/gallery.py

@@ -2,10 +2,19 @@ import os
 from pelican import signals
 
 
-def add_gallery_post(generator):
+def get_content_path(pelican):
+    return pelican.settings.get('PATH')
+
+
+def get_gallery_path(pelican):
+    gallery_path = pelican.settings.get('GALLERY_PATH', 'images/gallery')
+    content_path = get_content_path(pelican)
+
+    return os.path.join(content_path, gallery_path)
 
-    contentpath = generator.settings.get('PATH')
-    gallerycontentpath = os.path.join(contentpath,'images/gallery')
+
+def add_gallery_post(generator):
+    gallerycontentpath = get_gallery_path(generator)
 
     for article in generator.articles:
         if 'gallery' in article.metadata.keys():
@@ -24,9 +33,7 @@ def add_gallery_post(generator):
 
 
 def add_gallery_page(generator):
-
-    contentpath = generator.settings.get('PATH')
-    gallerycontentpath = os.path.join(contentpath,'images/gallery')
+    gallerycontentpath = get_gallery_path(generator)
 
     for page in generator.pages:
         if 'gallery' in page.metadata.keys():
@@ -45,9 +52,7 @@ def add_gallery_page(generator):
 
 
 def generate_gallery_page(generator):
-
-    contentpath = generator.settings.get('PATH')
-    gallerycontentpath = os.path.join(contentpath,'images/gallery')
+    gallerycontentpath = get_gallery_path(generator)
 
     for page in generator.pages:
         if page.metadata.get('template') == 'gallery':