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
|
3. Simplicity of implementation, adhere to KISS
|
||||||
4. Performance
|
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
|
## What to Avoid
|
||||||
|
|
||||||
- Any parallel folder structure (e.g. a separate `media/` tree mirroring `pages/`)
|
- Any parallel folder structure (e.g. a separate `media/` tree mirroring `pages/`)
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{{range .Days}}
|
{{range .Days}}
|
||||||
<div class="diary-section">
|
<div class="diary-section">
|
||||||
<h2 class="diary-heading">
|
<h2>
|
||||||
{{if .URL}}<a href="{{.URL}}">{{.Heading}}</a>{{else}}{{.Heading}}{{end}}
|
{{if .URL}}<a href="{{.URL}}">{{.Heading}}</a>{{else}}{{.Heading}}{{end}}
|
||||||
|
{{if .EditURL}}<a href="{{.EditURL}}" class="btn btn-small">edit</a>{{end}}
|
||||||
</h2>
|
</h2>
|
||||||
{{if .Content}}<div class="content">{{.Content}}</div>{{end}}
|
{{if .Content}}<div class="content">{{.Content}}</div>{{end}}
|
||||||
{{if .Photos}}
|
{{if .Photos}}
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ textarea:focus {
|
|||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.diary-heading {
|
.diary-section h2 {
|
||||||
font-size: 1.2rem;
|
font-size: 1.2rem;
|
||||||
color: white;
|
color: white;
|
||||||
margin-bottom: 0.75rem;
|
margin-bottom: 0.75rem;
|
||||||
|
|||||||
38
diary.go
38
diary.go
@@ -77,6 +77,7 @@ type diaryMonthSummary struct {
|
|||||||
type diaryDaySection struct {
|
type diaryDaySection struct {
|
||||||
Heading string
|
Heading string
|
||||||
URL string
|
URL string
|
||||||
|
EditURL string
|
||||||
Content template.HTML
|
Content template.HTML
|
||||||
Photos []diaryPhoto
|
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 diaryMonthTmpl = template.Must(template.ParseFS(assets, "assets/diary/diary-month.html"))
|
||||||
var diaryDayTmpl = template.Must(template.ParseFS(assets, "assets/diary/diary-day.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{
|
var photoExts = map[string]bool{
|
||||||
".jpg": true, ".jpeg": true, ".png": true, ".gif": true, ".webp": true,
|
".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 {
|
for _, dayNum := range days {
|
||||||
date := time.Date(year, time.Month(monthNum), dayNum, 0, 0, 0, 0, time.UTC)
|
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)) + "/"
|
dayURL := path.Join(urlPath, fmt.Sprintf("%02d", dayNum)) + "/"
|
||||||
var content template.HTML
|
var content template.HTML
|
||||||
if dirName, ok := dayDirs[dayNum]; ok {
|
if dirName, ok := dayDirs[dayNum]; ok {
|
||||||
@@ -247,6 +282,7 @@ func renderDiaryMonth(fsPath, urlPath string) template.HTML {
|
|||||||
sections = append(sections, diaryDaySection{
|
sections = append(sections, diaryDaySection{
|
||||||
Heading: heading,
|
Heading: heading,
|
||||||
URL: dayURL,
|
URL: dayURL,
|
||||||
|
EditURL: dayURL + "?edit",
|
||||||
Content: content,
|
Content: content,
|
||||||
Photos: photos,
|
Photos: photos,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user