56 lines
2.1 KiB
HTML

{{ $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" -}}
{{/* warnf "%#v" $cat */}}
{{- $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 -}}
{{- $cats := slice .class -}}
{{- if eq (printf "%T" .class) "[]interface {}" }}{{ $cats = .class }}{{ end -}}
{{- if not (in $cats $cat) }}{{ continue }}{{ end -}}
{{/* warnf "%T %#v" .class . */}}
<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>