about summary refs log tree commit diff homepage
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go29
1 files changed, 14 insertions, 15 deletions
diff --git a/main.go b/main.go
index b364d20..dfc01a5 100644
--- a/main.go
+++ b/main.go
@@ -48,7 +48,6 @@ type Archive struct {
 	Title   string
 	Prev    string
 	Next    string
-	Entries []Page
 }
 
 // Type Directory represents a library directory in file system.
@@ -147,7 +146,17 @@ func main() {
 		// Render archive page
 		entries, _ := os.ReadDir(path.Join(p, ".."))
 		index := find(entries, stat.Name())
-		var pages []Page
+		prev := ""
+		if index > 0 {
+			prev = entries[index-1].Name()
+		}
+		next := ""
+		if index < len(entries)-1 {
+			next = entries[index+1].Name()
+		}
+		t.ExecuteTemplate(w, "archive-head.html",
+			Archive{ stat.Name(), prev, next })
+
 		for i, f := range cbz.File {
 			image, _ := cbz.File[i].Open()
 			defer image.Close()
@@ -155,21 +164,11 @@ func main() {
 			n, _ := image.Read(buf)
 			mime := http.DetectContentType(buf[:n])
 			if strings.HasPrefix(mime, "image/") {
-				pages = append(pages, Page{i, f.Name})
+				t.ExecuteTemplate(w, "archive-page.html",
+					Page{i, f.Name})
 			}
 		}
-
-		prev := ""
-		if index > 0 {
-			prev = entries[index-1].Name()
-		}
-		next := ""
-		if index < len(entries)-1 {
-			next = entries[index+1].Name()
-		}
-		t.ExecuteTemplate(w, "archive.html", Archive{
-			stat.Name(), prev, next, pages,
-		})
+		t.ExecuteTemplate(w, "archive-foot.html", nil)
 	})
 
 	addr := os.Getenv("PHYLACTERY_ADDRESS")