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
+1 -1
View File
@@ -1,7 +1,7 @@
{{if .Photos}}
<div class="photo-grid">
{{range .Photos}}
<a href="{{.URL}}" target="_blank"><img src="{{.ThumbURL}}" alt="{{.Name}}" loading="lazy"></a>
<a href="{{.URL}}" target="_blank"><img src="{{.ThumbURL}}" alt="" loading="lazy"></a>
{{end}}
</div>
{{end}}
+1 -1
View File
@@ -7,7 +7,7 @@
{{if .Photos}}
<div class="photo-grid">
{{range .Photos}}
<a href="{{.URL}}" target="_blank"><img src="{{.ThumbURL}}" alt="{{.Name}}" loading="lazy"></a>
<a href="{{.URL}}" target="_blank"><img src="{{.ThumbURL}}" alt="" loading="lazy"></a>
{{end}}
</div>
{{end}}
+2 -2
View File
@@ -1,4 +1,4 @@
<h2 id="months">Months</h2>
<h2 id="months">Monate</h2>
{{range .Months}}
<h3 id="{{.ID}}">
<a href="{{.URL}}">{{.Name}}</a>
@@ -6,7 +6,7 @@
{{if .Photos}}
<div class="photo-grid">
{{range .Photos}}
<a href="{{.URL}}" target="_blank"><img src="{{.ThumbURL}}" alt="{{.Name}}" loading="lazy"></a>
<a href="{{.URL}}" target="_blank"><img src="{{.ThumbURL}}" alt="" loading="lazy"></a>
{{end}}
</div>
{{end}}
+6
View File
@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"
fill="none" stroke="#cfcfcf" stroke-width="1.5" stroke-linejoin="miter" shape-rendering="crispEdges">
<rect x="1" y="2" width="14" height="12"/>
<path d="M1 11l4-4 3 3 2-2 5 5"/>
<rect x="10" y="4" width="2" height="2" fill="#cfcfcf" stroke="none"/>
</svg>

After

Width:  |  Height:  |  Size: 328 B

+1
View File
@@ -374,6 +374,7 @@ textarea {
height: 140px;
object-fit: cover;
display: block;
background: var(--bg-panel) url("/_/icons/thumb-placeholder.svg") center/2rem no-repeat;
}
/* === Empty state === */
+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,
})
}