Use placeholder svg

This commit is contained in:
2026-04-23 20:58:33 +02:00
parent 337ec9ef6e
commit 4415a391e2
6 changed files with 40 additions and 13 deletions
+29 -9
View File
@@ -401,20 +401,36 @@ func renderDiaryYear(fsPath, urlPath string) template.HTML {
photos := yearPhotos(fsPath, urlPath)
entries, err := os.ReadDir(fsPath)
if err != nil {
return ""
}
var months []diaryMonthSummary
// Collect month numbers from both subdirectories and photo filenames so
// years that contain only photos (no diary entries) still list months.
monthSet := map[int]bool{}
monthDirs := map[int]string{}
entries, _ := os.ReadDir(fsPath)
for _, e := range entries {
if !e.IsDir() {
continue
}
monthNum, err := strconv.Atoi(e.Name())
if err != nil || monthNum < 1 || monthNum > 12 {
n, err := strconv.Atoi(e.Name())
if err != nil || n < 1 || n > 12 {
continue
}
monthSet[n] = true
monthDirs[n] = e.Name()
}
for _, p := range photos {
if p.Date.Year() == year {
monthSet[int(p.Date.Month())] = true
}
}
monthNums := make([]int, 0, len(monthSet))
for m := range monthSet {
monthNums = append(monthNums, m)
}
sort.Ints(monthNums)
var months []diaryMonthSummary
for _, monthNum := range monthNums {
var monthPhotos []diaryPhoto
for _, p := range photos {
if p.Date.Year() == year && int(p.Date.Month()) == monthNum {
@@ -422,10 +438,14 @@ func renderDiaryYear(fsPath, urlPath string) template.HTML {
}
}
monthDate := time.Date(year, time.Month(monthNum), 1, 0, 0, 0, 0, time.UTC)
dirName, ok := monthDirs[monthNum]
if !ok {
dirName = fmt.Sprintf("%02d", monthNum)
}
months = append(months, diaryMonthSummary{
ID: monthDate.Format("2006-01"),
Name: fmt.Sprintf("%s %d", germanMonths[monthDate.Month()], year),
URL: path.Join(urlPath, e.Name()) + "/",
URL: path.Join(urlPath, dirName) + "/",
Photos: monthPhotos,
})
}