Update diary view with new buttons
This commit is contained in:
@@ -65,6 +65,11 @@ When building features, apply this order:
|
||||
3. Simplicity of implementation, adhere to KISS
|
||||
4. Performance
|
||||
|
||||
## Date Formatting
|
||||
|
||||
- General UI dates (file listings, metadata): ISO `YYYY-MM-DD`
|
||||
- Diary long-form dates: German locale, e.g. `Mittwoch, 1. April 2026` — use `formatGermanDate` in `diary.go`; Go's `time.Format` is English-only so locale names are kept in maps keyed by `time.Weekday` / `time.Month`
|
||||
|
||||
## What to Avoid
|
||||
|
||||
- Any parallel folder structure (e.g. a separate `media/` tree mirroring `pages/`)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
{{range .Days}}
|
||||
<div class="diary-section">
|
||||
<h2 class="diary-heading">
|
||||
<h2>
|
||||
{{if .URL}}<a href="{{.URL}}">{{.Heading}}</a>{{else}}{{.Heading}}{{end}}
|
||||
{{if .EditURL}}<a href="{{.EditURL}}" class="btn btn-small">edit</a>{{end}}
|
||||
</h2>
|
||||
{{if .Content}}<div class="content">{{.Content}}</div>{{end}}
|
||||
{{if .Photos}}
|
||||
|
||||
@@ -351,7 +351,7 @@ textarea:focus {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.diary-heading {
|
||||
.diary-section h2 {
|
||||
font-size: 1.2rem;
|
||||
color: white;
|
||||
margin-bottom: 0.75rem;
|
||||
|
||||
38
diary.go
38
diary.go
@@ -77,6 +77,7 @@ type diaryMonthSummary struct {
|
||||
type diaryDaySection struct {
|
||||
Heading string
|
||||
URL string
|
||||
EditURL string
|
||||
Content template.HTML
|
||||
Photos []diaryPhoto
|
||||
}
|
||||
@@ -89,6 +90,40 @@ var diaryYearTmpl = template.Must(template.ParseFS(assets, "assets/diary/diary-y
|
||||
var diaryMonthTmpl = template.Must(template.ParseFS(assets, "assets/diary/diary-month.html"))
|
||||
var diaryDayTmpl = template.Must(template.ParseFS(assets, "assets/diary/diary-day.html"))
|
||||
|
||||
var germanWeekdays = map[time.Weekday]string{
|
||||
time.Sunday: "Sonntag",
|
||||
time.Monday: "Montag",
|
||||
time.Tuesday: "Dienstag",
|
||||
time.Wednesday: "Mittwoch",
|
||||
time.Thursday: "Donnerstag",
|
||||
time.Friday: "Freitag",
|
||||
time.Saturday: "Samstag",
|
||||
}
|
||||
|
||||
var germanMonths = map[time.Month]string{
|
||||
time.January: "Januar",
|
||||
time.February: "Februar",
|
||||
time.March: "März",
|
||||
time.April: "April",
|
||||
time.May: "Mai",
|
||||
time.June: "Juni",
|
||||
time.July: "Juli",
|
||||
time.August: "August",
|
||||
time.September: "September",
|
||||
time.October: "Oktober",
|
||||
time.November: "November",
|
||||
time.December: "Dezember",
|
||||
}
|
||||
|
||||
func formatGermanDate(t time.Time) string {
|
||||
return fmt.Sprintf("%s, %d. %s %d",
|
||||
germanWeekdays[t.Weekday()],
|
||||
t.Day(),
|
||||
germanMonths[t.Month()],
|
||||
t.Year(),
|
||||
)
|
||||
}
|
||||
|
||||
var photoExts = map[string]bool{
|
||||
".jpg": true, ".jpeg": true, ".png": true, ".gif": true, ".webp": true,
|
||||
}
|
||||
@@ -222,7 +257,7 @@ func renderDiaryMonth(fsPath, urlPath string) template.HTML {
|
||||
for _, dayNum := range days {
|
||||
date := time.Date(year, time.Month(monthNum), dayNum, 0, 0, 0, 0, time.UTC)
|
||||
|
||||
heading := date.Format("Monday, January 2")
|
||||
heading := formatGermanDate(date)
|
||||
dayURL := path.Join(urlPath, fmt.Sprintf("%02d", dayNum)) + "/"
|
||||
var content template.HTML
|
||||
if dirName, ok := dayDirs[dayNum]; ok {
|
||||
@@ -247,6 +282,7 @@ func renderDiaryMonth(fsPath, urlPath string) template.HTML {
|
||||
sections = append(sections, diaryDaySection{
|
||||
Heading: heading,
|
||||
URL: dayURL,
|
||||
EditURL: dayURL + "?edit",
|
||||
Content: content,
|
||||
Photos: photos,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user