{{ $model := .model }}

Personen {{ if $model.Agents.Items }}{{ len $model.Agents.Items }}{{ end }}

{{ if $model.Agents.Items }}
{{ range $i, $agent := $model.Agents.Items }} {{ $gnd := GetGND $agent.GND }}
{{- index $agent.Names 0 -}} {{ if $gnd }} {{ if and $gnd.DateOfBirth $gnd.DateOfDeath }}
{{- if $gnd.DateOfBirth -}} {{- HRDateYear (index $gnd.DateOfBirth 0) -}} {{- else -}} [?] {{- end -}}  –  {{- if $gnd.DateOfDeath -}} {{- HRDateYear (index $gnd.DateOfDeath 0) -}} {{- else -}} [?] {{- end -}}
{{ end }} {{ end }}
{{ end }}
{{ else }}

Keine Personen gefunden.

{{ end }}

Orte {{ if $model.Places.Items }}{{ len $model.Places.Items }}{{ end }}

{{ if $model.Places.Items }}
{{ range $i, $place := $model.Places.Items }} {{ end }}
{{ else }}

Keine Orte gefunden.

{{ end }}

Kategorien {{ if $model.Categories.Items }}{{ len $model.Categories.Items }}{{ end }}

{{ if $model.Categories.Items }}
{{ range $i, $category := $model.Categories.Items }} {{ end }}
{{ else }}

Keine Kategorien gefunden.

{{ end }}

Ausgaben {{ if $model.Issues.Items }}{{ len $model.Issues.Items }}{{ end }}

{{ if $model.Issues.Items }}
{{ range $i, $issue := $model.Issues.Items }}
KGPZ {{ $issue.Datum.When.Year }}/{{ $issue.Number.No }}
{{ HRDateShort $issue.Datum.When.String }}
{{ end }}
{{ else }}

Keine Ausgaben gefunden.

{{ end }}

Werke {{ if $model.Works.Items }}{{ len $model.Works.Items }}{{ end }}

{{ if $model.Works.Items }}
{{ range $i, $w := $model.Works.Items }}
{{- if ne (len $w.Citation.InnerXML ) 0 -}}
{{- /* Show all work contributors with their roles */ -}} {{- $workContributors := slice -}} {{- range $workAgentRef := $w.AgentRefs -}} {{- $agent := GetAgent $workAgentRef.Ref -}} {{- if and $agent (gt (len $agent.Names) 0) -}} {{- if eq $workAgentRef.Category "übersetzer" -}} {{- $workContributors = append $workContributors (printf "%s (Übers.)" $workAgentRef.Ref (index $agent.Names 0)) -}} {{- else if eq $workAgentRef.Category "herausgeber" -}} {{- $workContributors = append $workContributors (printf "%s (Hrsg.)" $workAgentRef.Ref (index $agent.Names 0)) -}} {{- else -}} {{- $workContributors = append $workContributors (printf "%s" $workAgentRef.Ref (index $agent.Names 0)) -}} {{- end -}} {{- end -}} {{- end -}} {{- range $index, $contributor := $workContributors -}} {{- if gt $index 0 }}, {{ end }}{{ Safe $contributor }} {{- end -}} {{- if gt (len $workContributors) 0 }}: {{ end }}{{- Safe $w.Citation.HTML -}} {{- range $_, $url := $w.URLs -}} {{ $url.Chardata }} {{- end -}}
{{- end -}} {{- /* Find all pieces that reference this work */ -}} {{ $workPieces := LookupPieces $w }} {{ if len $workPieces }}
{{- /* Group pieces by category + author combination */ -}} {{- $pieceGroups := dict -}} {{- range $_, $p := $workPieces -}} {{- /* Get categories for this piece */ -}} {{- $categoryFlags := GetCategoryFlags $p.Item -}} {{- $categories := slice -}} {{- if $categoryFlags.Rezension -}} {{- $categories = append $categories "Rezension" -}} {{- end -}} {{- if $categoryFlags.Auszug -}} {{- $categories = append $categories "Auszug" -}} {{- end -}} {{- if $categoryFlags.Theaterkritik -}} {{- $categories = append $categories "Theaterkritik" -}} {{- end -}} {{- if $categoryFlags.Uebersetzung -}} {{- $categories = append $categories "Übersetzung" -}} {{- end -}} {{- if $categoryFlags.Kommentar -}} {{- $categories = append $categories "Kommentar" -}} {{- end -}} {{- if $categoryFlags.Replik -}} {{- $categories = append $categories "Replik" -}} {{- end -}} {{- if $categoryFlags.Anzeige -}} {{- $categories = append $categories "Anzeige" -}} {{- end -}} {{- if $categoryFlags.Provinienz -}} {{- $categories = append $categories "Provinienz" -}} {{- end -}} {{- if eq (len $categories) 0 -}} {{- $categories = append $categories "Beitrag" -}} {{- end -}} {{- /* Get authors, translators, and editors for this piece */ -}} {{- $pieceAuthors := slice -}} {{- $pieceTranslators := slice -}} {{- $pieceEditors := slice -}} {{- range $agentref := $p.Item.AgentRefs -}} {{- if (or (eq $agentref.Category "") (eq $agentref.Category "autor")) -}} {{- $pieceAuthors = append $pieceAuthors $agentref.Ref -}} {{- else if eq $agentref.Category "übersetzer" -}} {{- $pieceTranslators = append $pieceTranslators $agentref.Ref -}} {{- else if eq $agentref.Category "herausgeber" -}} {{- $pieceEditors = append $pieceEditors $agentref.Ref -}} {{- end -}} {{- end -}} {{- $sortedAuthors := sortStrings $pieceAuthors -}} {{- $sortedTranslators := sortStrings $pieceTranslators -}} {{- $sortedEditors := sortStrings $pieceEditors -}} {{- /* Create group key: categories + authors + translators + editors */ -}} {{- $sortedCategories := sortStrings $categories -}} {{- $groupKey := printf "%s|%s|%s|%s" (joinWithUnd $sortedCategories) (joinWithUnd $sortedAuthors) (joinWithUnd $sortedTranslators) (joinWithUnd $sortedEditors) -}} {{- /* Add piece to group (check for duplicates by ID) */ -}} {{- $existing := index $pieceGroups $groupKey -}} {{- if $existing -}} {{- /* Check if piece is already in group */ -}} {{- $found := false -}} {{- range $existingPiece := $existing -}} {{- if eq $existingPiece.Item.ID $p.Item.ID -}} {{- $found = true -}} {{- end -}} {{- end -}} {{- if not $found -}} {{- $pieceGroups = merge $pieceGroups (dict $groupKey (append $existing $p)) -}} {{- end -}} {{- else -}} {{- $pieceGroups = merge $pieceGroups (dict $groupKey (slice $p)) -}} {{- end -}} {{- end -}} {{- /* Display each group */ -}} {{- range $groupKey, $groupPieces := $pieceGroups -}}
{{- /* Extract categories, authors, translators, and editors from group key */ -}} {{- $keyParts := split $groupKey "|" -}} {{- $categoryName := index $keyParts 0 -}} {{- $authorPart := index $keyParts 1 -}} {{- $translatorPart := "" -}} {{- if gt (len $keyParts) 2 -}} {{- $translatorPart = index $keyParts 2 -}} {{- end -}} {{- $editorPart := "" -}} {{- if gt (len $keyParts) 3 -}} {{- $editorPart = index $keyParts 3 -}} {{- end -}} {{- /* Use plural if multiple pieces grouped together */ -}} {{- $displayCategory := $categoryName -}} {{- if gt (len $groupPieces) 1 -}} {{- if eq $categoryName "Rezension" -}} {{- $displayCategory = "Rezensionen" -}} {{- else if eq $categoryName "Auszug" -}} {{- $displayCategory = "Auszüge" -}} {{- else if eq $categoryName "Theaterkritik" -}} {{- $displayCategory = "Theaterkritiken" -}} {{- else if eq $categoryName "Übersetzung" -}} {{- $displayCategory = "Übersetzungen" -}} {{- else if eq $categoryName "Kommentar" -}} {{- $displayCategory = "Kommentare" -}} {{- else if eq $categoryName "Replik" -}} {{- $displayCategory = "Repliken" -}} {{- else if eq $categoryName "Anzeige" -}} {{- $displayCategory = "Anzeigen" -}} {{- else if eq $categoryName "Beitrag" -}} {{- $displayCategory = "Beiträge" -}} {{- end -}} {{- end -}} {{ $displayCategory }}{{- if or (ne $authorPart "") (ne $translatorPart "") (ne $editorPart "") }} von {{ end }} {{- /* Display authors */ -}} {{- if ne $authorPart "" -}} {{- range $i, $authorID := (split $authorPart " und ") -}} {{- if gt $i 0 }} und {{ end }} {{- $agent := GetAgent $authorID -}} {{- if and $agent (gt (len $agent.Names) 0) -}} {{ index $agent.Names 0 }} {{- end -}} {{- end -}} {{- end -}} {{- /* Display translators with (Übers.) suffix */ -}} {{- if ne $translatorPart "" -}} {{- if ne $authorPart "" }}, {{ end }} {{- range $i, $translatorID := (split $translatorPart " und ") -}} {{- if gt $i 0 }}, {{ end }} {{- $agent := GetAgent $translatorID -}} {{- if and $agent (gt (len $agent.Names) 0) -}} {{ index $agent.Names 0 }} (Übers.) {{- end -}} {{- end -}} {{- end -}} {{- /* Display editors with (Hrsg.) suffix */ -}} {{- if ne $editorPart "" -}} {{- if or (ne $authorPart "") (ne $translatorPart "") }}, {{ end }} {{- range $i, $editorID := (split $editorPart " und ") -}} {{- if gt $i 0 }}, {{ end }} {{- $agent := GetAgent $editorID -}} {{- if and $agent (gt (len $agent.Names) 0) -}} {{ index $agent.Names 0 }} (Hrsg.) {{- end -}} {{- end -}} {{- end -}}: {{- /* Show citations separated by commas */ -}} {{ " " }}{{- range $pieceIndex, $p := $groupPieces -}} {{- range $issueIndex, $issue := $p.Item.IssueRefs -}} {{- if or (gt $pieceIndex 0) (gt $issueIndex 0) }}, {{ end -}} {{- template "_citation" $issue -}} {{- end -}} {{- /* Add "Ganzer Beitrag" link if piece spans multiple issues */ -}} {{- if gt (len $p.Item.IssueRefs) 1 -}} {{ " " }} {{- end -}} {{- end -}}
{{- end -}}
{{ end }}
{{ end }}
{{ else }}

Keine Werke gefunden.

{{ end }}

Beiträge {{ if $model.Pieces.Items }}{{ len $model.Pieces.Items }}{{ end }}

{{ if $model.Pieces.Items }}
{{- /* Group pieces by their own title/incipit, not by work being reviewed */ -}} {{- $groupedPieces := dict -}} {{- range $_, $piece := $model.Pieces.Items -}} {{- $groupKey := "" -}} {{- if $piece.Title -}} {{- $groupKey = index $piece.Title 0 -}} {{- else if $piece.Incipit -}} {{- $groupKey = index $piece.Incipit 0 -}} {{- else -}} {{- $groupKey = printf "untitled-%s" $piece.ID -}} {{- end -}} {{- $existing := index $groupedPieces $groupKey -}} {{- if $existing -}} {{- $groupedPieces = merge $groupedPieces (dict $groupKey (append $existing $piece)) -}} {{- else -}} {{- $groupedPieces = merge $groupedPieces (dict $groupKey (slice $piece)) -}} {{- end -}} {{- end -}}
{{- /* Display grouped pieces */ -}} {{- range $groupKey, $groupedItems := $groupedPieces -}}
{{- /* Use first piece for display text with linking */ -}} {{ template "_piece_link" (dict "Piece" (index $groupedItems 0) "DisplayMode" "search" "ShowUnifiedEntry" true "LongForm" true) }} {{- /* Show all citations from all pieces in this group inline with commas */ -}} {{ " " }}{{- range $groupIndex, $groupItem := $groupedItems -}} {{- range $issueIndex, $issue := $groupItem.IssueRefs -}} {{- if or (gt $groupIndex 0) (gt $issueIndex 0) }}, {{ end -}} {{- template "_citation" $issue -}}{{- end -}} {{- end -}} {{- /* Add "Ganzer Beitrag" link if piece spans multiple issues */ -}} {{- $firstGroupItem := index $groupedItems 0 -}} {{- if gt (len $firstGroupItem.IssueRefs) 1 -}} {{ " " }} {{- end }}
{{- end -}}
{{ else }}

Keine Beiträge gefunden.

{{ end }}