{{ $a := . }} {{ $works := slice }} {{ if eq $a.ID "anonym" }} {{ $anonymWorks := LookupAnonymWorks }} {{ range $_, $work := $anonymWorks }} {{ $works = append $works (dict "Item" $work) }} {{ end }} {{ else }} {{ $works = LookupWorks $a }} {{ end }} {{ if ne (len $works) 0 }}

Werke

{{ range $_, $w := $works }}
{{- if ne (len $w.Item.Citation.InnerXML ) 0 -}}
{{- /* Get other associated persons for this work */ -}} {{- $otherAuthors := slice -}} {{- $otherTranslators := slice -}} {{- $otherEditors := slice -}} {{- range $workAgentRef := $w.Item.AgentRefs -}} {{- if ne $workAgentRef.Ref $a.ID -}} {{- if or (eq $workAgentRef.Category "") (eq $workAgentRef.Category "autor") -}} {{- $otherAuthors = append $otherAuthors $workAgentRef.Ref -}} {{- else if eq $workAgentRef.Category "übersetzer" -}} {{- $otherTranslators = append $otherTranslators $workAgentRef.Ref -}} {{- else if eq $workAgentRef.Category "herausgeber" -}} {{- $otherEditors = append $otherEditors $workAgentRef.Ref -}} {{- end -}} {{- end -}} {{- end -}} {{- /* Display other associated persons before the work citation */ -}} {{- $hasAssociatedPersons := or (gt (len $otherAuthors) 0) (gt (len $otherTranslators) 0) (gt (len $otherEditors) 0) -}} {{- if $hasAssociatedPersons -}} {{ "mit " }} {{- range $i, $authorID := $otherAuthors -}} {{- if gt $i 0 }}, {{ end }} {{- $agent := GetAgent $authorID -}} {{- if and $agent (gt (len $agent.Names) 0) -}} {{ index $agent.Names 0 }} {{- end -}} {{- end -}} {{- /* Display translators with (Übers.) */ -}} {{- range $i, $translatorID := $otherTranslators -}} {{- if or (gt (len $otherAuthors) 0) (gt $i 0) }}, {{ end }} {{- $agent := GetAgent $translatorID -}} {{- if and $agent (gt (len $agent.Names) 0) -}} {{ index $agent.Names 0 }} (Übers.) {{- end -}} {{- end -}} {{- /* Display editors with (Hrsg.) */ -}} {{- range $i, $editorID := $otherEditors -}} {{- if or (gt (len $otherAuthors) 0) (gt (len $otherTranslators) 0) (gt $i 0) }}, {{ end }} {{- $agent := GetAgent $editorID -}} {{- if and $agent (gt (len $agent.Names) 0) -}} {{ index $agent.Names 0 }} (Hrsg.) {{- end -}} {{- end -}} : {{ end -}} {{- /* Check current person's role in this work for display after citation */ -}} {{- $personRole := "" -}} {{- range $workAgentRef := $w.Item.AgentRefs -}} {{- if eq $workAgentRef.Ref $a.ID -}} {{- if eq $workAgentRef.Category "übersetzer" -}} {{- $personRole = "(Übers.) " -}} {{- else if eq $workAgentRef.Category "herausgeber" -}} {{- $personRole = "(Hrsg.) " -}} {{- end -}} {{- break -}} {{- end -}} {{- end -}} {{- Safe $personRole -}}{{- Safe $w.Item.Citation.HTML -}} {{- range $_, $url := $w.Item.URLs -}} {{ $url.Chardata }} {{- end -}}
{{- end -}} {{- /* Find all pieces that reference this work */ -}} {{ $workPieces := LookupPieces $w.Item }} {{ 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 "Rezensiert" -}} {{- 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 (excluding current person) */ -}} {{- $pieceAuthors := slice -}} {{- $pieceTranslators := slice -}} {{- $pieceEditors := slice -}} {{- range $agentref := $p.Item.AgentRefs -}} {{- if and (or (eq $agentref.Category "") (eq $agentref.Category "autor")) (ne $agentref.Ref $a.ID) -}} {{- $pieceAuthors = append $pieceAuthors $agentref.Ref -}} {{- else if and (eq $agentref.Category "übersetzer") (ne $agentref.Ref $a.ID) -}} {{- $pieceTranslators = append $pieceTranslators $agentref.Ref -}} {{- else if and (eq $agentref.Category "herausgeber") (ne $agentref.Ref $a.ID) -}} {{- $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 "Rezensiert" -}} {{- $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 }}
{{ end }}