From 085c1dee882e16d3b51b3e4b57c6ff95e8fd3cfc Mon Sep 17 00:00:00 2001 From: Nick Pegg Date: Sat, 3 Aug 2024 18:55:44 -0700 Subject: [PATCH] some styling --- photoalbum/generate.py | 10 ++++++++++ photoalbum/skel/_templates/album.html | 10 ++++++++-- photoalbum/skel/_templates/base.html | 2 ++ photoalbum/skel/static/index.css | 19 +++++++++++++++++++ 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/photoalbum/generate.py b/photoalbum/generate.py index e6a755b..b041239 100644 --- a/photoalbum/generate.py +++ b/photoalbum/generate.py @@ -156,10 +156,15 @@ def generate_html(config: Config, root_dir: ImageDirectory) -> None: for album_dir in root_dir.walk(): html_path = album_dir.path / "index.html" + static_path = root_dir.path.relative_to( + html_path.parent, walk_up=True + ) / "static" + logger.debug(f"Rendering {html_path}") with html_path.open("w") as f: f.write( album_tmpl.render( + static_dir=static_path, album_dir=album_dir, ) ) @@ -168,11 +173,16 @@ def generate_html(config: Config, root_dir: ImageDirectory) -> None: # TODO: If a file with a matching name but .txt or .md, add that as the # description for the image html_path = image_path.html_path() + static_path = root_dir.path.relative_to( + html_path.parent, walk_up=True + ) / "static" html_path.parent.mkdir(exist_ok=True) + logger.debug(f"Rendering {html_path}") with html_path.open("w") as f: f.write( photo_tmpl.render( + static_dir=static_path, image_path=image_path, ) ) diff --git a/photoalbum/skel/_templates/album.html b/photoalbum/skel/_templates/album.html index 67e98a0..9985b0d 100644 --- a/photoalbum/skel/_templates/album.html +++ b/photoalbum/skel/_templates/album.html @@ -1,9 +1,15 @@ {% extends "base.html" %} {% block content %} + {% if not album_dir.is_root %} +

+ up +

+ {% endif %} + {% if album_dir.children %}

Albums

-
+