From a150b7aa4b83c1725128ecb6470b8cbf2d5e0214 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sat, 4 May 2024 21:02:51 +0200 Subject: Optional decade / year / month headings --- bin/pyggle | 29 +++++++++++++++++++++++++++-- share/css/dark.css | 4 ++++ share/css/light.css | 4 ++++ share/css/main.css | 10 ++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/bin/pyggle b/bin/pyggle index 1bbffc4..3a818b8 100755 --- a/bin/pyggle +++ b/bin/pyggle @@ -246,11 +246,12 @@ class ImageHTML: class Thumbnail: - def __init__(self, filename, im, size=250, with_gps=False): + def __init__(self, filename, im, size=250, with_gps=False, group_key_template=None): self.filename = filename self.size = size self.exif_dt = None self.gps = None + self.group_key = None with open(filename, "rb") as f: self.exif_tag = exifread.process_file(f) @@ -288,6 +289,14 @@ class Thumbnail: self._get_makemodel() self._get_details() + if group_key_template == "decade" and self.exif_dt: + year = self.exif_dt.strftime("%Y")[:3] + self.group_key = f"{year}0 – {year}9" + elif group_key_template == "year" and self.exif_dt: + self.group_key = self.exif_dt.strftime("%Y") + elif group_key_template == "year-month" and self.exif_dt: + self.group_key = self.exif_dt.strftime("%B %Y") + if with_gps: self._get_gps() @@ -562,6 +571,13 @@ if __name__ == "__main__": type=str, help="Set EXIF copyright (IN-PLACE EDIT)", ) + parser.add_argument( + "--group", + metavar="SEP", + choices=["none", "year-month", "year", "decade"], + default="none", + help="Add captions to separate images by SEP", + ) parser.add_argument( "--html-include", metavar="FILE", @@ -650,7 +666,11 @@ if __name__ == "__main__": continue thumbnail = Thumbnail( - filename, im.copy(), size=args.size, with_gps=args.with_nominatim + filename, + im.copy(), + size=args.size, + with_gps=args.with_nominatim, + group_key_template=args.group, ) thumbnails.append(thumbnail) @@ -701,7 +721,12 @@ if __name__ == "__main__": if args.sort == "time": thumbnails = sorted(thumbnails, key=lambda t: t.exif_dt, reverse=args.reverse) + prev_heading = None + for i, thumbnail in enumerate(thumbnails): + if args.group and thumbnail.group_key != prev_heading: + html_buf += f"

{thumbnail.group_key}

" + prev_heading = thumbnail.group_key html_buf += thumbnail.to_html(i, args.with_detail_page) if args.with_detail_page: diff --git a/share/css/dark.css b/share/css/dark.css index b29caad..e018ca4 100644 --- a/share/css/dark.css +++ b/share/css/dark.css @@ -7,6 +7,10 @@ a { color: #9999ff; } +h1 { + color: #cccccc; +} + .glightbox-clean .gslide-description { color: #eeeeee!important; diff --git a/share/css/light.css b/share/css/light.css index 5e7c6ad..9d7ab32 100644 --- a/share/css/light.css +++ b/share/css/light.css @@ -2,6 +2,10 @@ a { color: #000099; } +h1 { + color: #333333; +} + .glightbox-mobile .gslide-description { padding-top: 0!important; diff --git a/share/css/main.css b/share/css/main.css index d3795ee..9bfb229 100644 --- a/share/css/main.css +++ b/share/css/main.css @@ -6,6 +6,12 @@ a { text-decoration: none; } +h1 { + clear: both; + padding-top: 1em; + margin-left: 1em; +} + div.image-container { text-align: center; font-size: 80%; @@ -14,6 +20,10 @@ div.image-container { height: /* $boxheight */; } +div.image-list-end { + clear: both; +} + div.image-container a { text-decoration: none; } -- cgit v1.2.3