Browse Source

Prepare generation of thumb photos

master
Marien Fressinaud 6 years ago
parent
commit
8ba92e9046
3 changed files with 16 additions and 4 deletions
  1. 1
    1
      Herisson/gallery.html.j2
  2. 1
    1
      Herisson/index.html.j2
  3. 14
    2
      boop.py

+ 1
- 1
Herisson/gallery.html.j2 View File

@@ -24,7 +24,7 @@
{% for photo in gallery.photos %}
<div class="photo">
<a href="{{ photo.url }}" target="_blank" rel="noreferrer">
<img src="{{ photo.url }}" alt="" />
<img src="{{ photo.thumb_url }}" alt="" />
</a>
</div>
{% endfor %}

+ 1
- 1
Herisson/index.html.j2 View File

@@ -22,7 +22,7 @@
{% for gallery in galleries -%}
<div class="gallery-cover">
<a href="{{ gallery.url }}.html">
<img src="{{ gallery.cover_photo.url }}" alt="" />
<img src="{{ gallery.cover_photo.thumb_url }}" alt="" />
<span class="gallery-cover-name">
{{ gallery.name }}
</span>

+ 14
- 2
boop.py View File

@@ -40,7 +40,13 @@ def list_photos_in(gallery_dir):
]
for photo_file in photo_files:
url = os.path.join(gallery_dir.name, photo_file.name)
photo = {"name": photo_file.name, "url": url}
thumb_url = os.path.join(gallery_dir.name, f"thumb_{photo_file.name}")
photo = {
"name": photo_file.name,
"path": photo_file.path,
"url": url,
"thumb_url": thumb_url,
}
yield photo


@@ -97,7 +103,13 @@ def generate_gallery_dir(output_path, gallery):
gallery_output_path = os.path.join(output_path, gallery["name"])
if os.path.isdir(gallery_output_path):
os.mkdir(gallery_output_path)
shutil.copytree(gallery["path"], gallery_output_path)

for photo in gallery["photos"]:
photo_output_path = os.path.join(output_path, photo["url"])
shutil.copyfile(photo["path"], photo_output_path)

thumb_output_path = os.path.join(output_path, photo["thumb_url"])
shutil.copyfile(photo["path"], thumb_output_path)


def main():

Loading…
Cancel
Save