ctucx.git: gallery

static-site-generator for image-galleries [used @ photos.ctu.cx]

commit 5bed374fb1e47ea2eefc6b3468164dec9bac3b28
parent 0ca925ad12ea0eee6fe63fe35039777d3813df7b
Author: Leah (ctucx) <leah@ctu.cx>
Date: Sun, 14 Mar 2021 13:02:28 +0100

picture.html: prefetch prev/next image
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/assets/picture.html b/src/assets/picture.html
@@ -31,6 +31,13 @@
 
 		<link type="text/css" rel="stylesheet" href="/style.css">
 		<link rel="shortcut icon" href="favicon.ico">
+
+		{{#hasNext}}
+		<link rel="prefetch" href="thumbnails/medium/{{next_filename}}" as="image">
+		{{/hasNext}}
+		{{#hasPrev}}
+		<link rel="prefetch" href="thumbnails/medium/{{prev_filename}}" as="image">
+		{{/hasPrev}}
 	</head>
 	<body>
 		<header class="transparent">
diff --git a/src/gallery.nim b/src/gallery.nim
@@ -287,12 +287,14 @@ proc generateWebsite(targetDir: string, album: Album) =
             pictureTemplateContext["takestamp"] = %"-"
 
         if index > 0:
-            pictureTemplateContext["hasPrev"]   = %true
-            pictureTemplateContext["prev_name"] = %album.pictures[index-1].name
+            pictureTemplateContext["hasPrev"]       = %true
+            pictureTemplateContext["prev_name"]     = %album.pictures[index-1].name
+            pictureTemplateContext["prev_filename"] = %album.pictures[index-1].filename
 
         if index+1 < album.pictures.len:
-            pictureTemplateContext["hasNext"]   = %true
-            pictureTemplateContext["next_name"] = %album.pictures[index+1].name
+            pictureTemplateContext["hasNext"]       = %true
+            pictureTemplateContext["next_name"]     = %album.pictures[index+1].name
+            pictureTemplateContext["next_filename"] = %album.pictures[index+1].filename
 
 
         echo "Generate picture page: " & picture.name