Migrate to central appointment database #45

Merged
christian merged 34 commits from sync-calendar into develop 2025-01-20 13:11:20 +00:00
2 changed files with 59 additions and 0 deletions
Showing only changes of commit ca6b1c16db - Show all commits

7
data/days.yml Normal file
View File

@ -0,0 +1,7 @@
Mon: Montag
Tue: Dienstag
Wed: Mittwoch
Thu: Donnerstag
Fri: Freitag
Sat: Samstag
Sun: Sonntag

View File

@ -0,0 +1,52 @@
{{ $calendars := .Site.Data.schedule.calendars -}}
{{- $list := slice -}}
{{- range $room, $roomData := $calendars -}}
{{- if ($roomData.ignore | default false) -}}{{ continue }}{{- end -}}
{{- $roomName := $roomData.name | default $room -}}
{{/* warnf "%s " $room */}}
{{- range $roomData.schedule -}}
{{- $addData := dict "room" $roomName "weight" 0 -}}
{{- $addData = merge $addData . -}}
{{/* warnf "%#v" $addData */}}
{{- $list = $list | append $addData -}}
{{- end -}}
{{- end -}}
{{- $cat := .Get "category" -}}
{{- $showAge := .Get "showAge" | default false -}}
{{- $list = sort $list "start" -}}
{{- $list = sort $list "title" -}}
{{- $list = sort $list "weight" -}}
{{/* warnf "%#v" $list */}}
<table>
<thead>
<tr>
<th>Gruppe</th>
{{ if $showAge }}<th>Jahrgang</th>{{ end }}
<th>Tag</th>
<th>Zeit</th>
<th>Ort</th>
</tr>
</thead>
<tbody>
{{ range $list -}}
{{- if ne .class $cat }}{{ continue }}{{ end -}}
{{/* warnf "%#v" . */}}
<tr>
<td>
{{ .title }}{{ with .subtitle }} - {{ . }}{{ end }}
</td>
{{ if $showAge }}<td>{{ .age }}</td>{{ end }}
<td>{{ index site.Data.days .day }}</td>
<td>
{{- $startTimeStr := printf "2025-01-02T%s:00" .start -}}
{{- $startTime := time.AsTime $startTimeStr -}}
{{- $duration := time.Duration "minute" .duration -}}
{{- $endTime := $startTime.Add $duration}}
{{/* warnf "Start %s, duration %s, %s" $startTime $duration $endTime */}}
{{- $startTime.Format "15:04"}} - {{ $endTime.Format "15:04" }}
</td>
<td>{{ .room }}</td>
</tr>
{{- end}}
</tbody>
</table>