{{- $piece := .Piece -}} {{- $currentActorID := .CurrentActorID -}} {{- $categoryFlags := GetCategoryFlags $piece -}} {{- $place := "" -}} {{- if $piece.PlaceRefs -}} {{- $placeObj := GetPlace (index $piece.PlaceRefs 0).Ref -}} {{- if gt (len $placeObj.Names) 0 -}} {{- $place = index $placeObj.Names 0 -}} {{- end -}} {{- end -}} {{- $title := "" -}} {{- if $piece.Title -}} {{- $title = index $piece.Title 0 -}} {{- else if $piece.Incipit -}} {{- $title = index $piece.Incipit 0 -}} {{- end -}} {{- $workTitle := "" -}} {{- $workAuthorName := "" -}} {{- $workAuthorID := "" -}} {{- if $piece.WorkRefs -}} {{- $work := GetWork (index $piece.WorkRefs 0).Ref -}} {{- if $work.PreferredTitle -}} {{- $workTitle = $work.PreferredTitle -}} {{- else if $work.Citation.Title -}} {{- $workTitle = $work.Citation.Title -}} {{- end -}} {{- if $work.AgentRefs -}} {{- range $workAgentRef := $work.AgentRefs -}} {{- if (or (eq $workAgentRef.Category "") (eq $workAgentRef.Category "autor")) -}} {{- $workAgent := GetAgent $workAgentRef.Ref -}} {{- if and $workAgent (gt (len $workAgent.Names) 0) -}} {{- $workAuthorName = index $workAgent.Names 0 -}} {{- $workAuthorID = $workAgentRef.Ref -}} {{- break -}} {{- end -}} {{- end -}} {{- end -}} {{- end -}} {{- end -}} {{- /* Build category list */ -}} {{- $categories := slice -}} {{- if $categoryFlags.Rezension -}} {{- $categories = append $categories "Rezension" -}} {{- end -}} {{- if $categoryFlags.Gedicht -}} {{- $categories = append $categories "Gedicht" -}} {{- end -}} {{- if $categoryFlags.Aufsatz -}} {{- $categories = append $categories "Aufsatz" -}} {{- end -}} {{- if $categoryFlags.Theaterkritik -}} {{- $categories = append $categories "Theaterkritik" -}} {{- end -}} {{- if $categoryFlags.Brief -}} {{- $categories = append $categories "Brief" -}} {{- end -}} {{- if $categoryFlags.Erzaehlung -}} {{- $categories = append $categories "Erzählung" -}} {{- end -}} {{- if $categoryFlags.Kommentar -}} {{- $categories = append $categories "Kommentar" -}} {{- end -}} {{- if $categoryFlags.Uebersetzung -}} {{- $categories = append $categories "Übersetzung" -}} {{- end -}} {{- if $categoryFlags.Auszug -}} {{- $categories = append $categories "Auszug" -}} {{- end -}} {{- if $categoryFlags.Replik -}} {{- $categories = append $categories "Replik" -}} {{- end -}} {{- if $categoryFlags.Lokalnachrichten -}} {{- $categories = append $categories "Lokalnachrichten" -}} {{- end -}} {{- if $categoryFlags.Lotterie -}} {{- $categories = append $categories "Lotterie" -}} {{- end -}} {{- if $categoryFlags.Nachruf -}} {{- $categories = append $categories "Nachruf" -}} {{- end -}} {{- if $categoryFlags.Weltnachrichten -}} {{- $categories = append $categories "Weltnachrichten" -}} {{- end -}} {{- if $categoryFlags.EinkommendeFremde -}} {{- $categories = append $categories "Einkommende Fremde" -}} {{- end -}} {{- if $categoryFlags.Wechselkurse -}} {{- $categories = append $categories "Wechselkurse" -}} {{- end -}} {{- if $categoryFlags.Buecher -}} {{- $categories = append $categories "Bücher" -}} {{- end -}} {{- if $categoryFlags.Lokalanzeigen -}} {{- $categories = append $categories "Lokalanzeigen" -}} {{- end -}} {{- if $categoryFlags.Vorladung -}} {{- $categories = append $categories "Vorladung" -}} {{- end -}} {{- if $categoryFlags.GelehrteNachrichten -}} {{- $categories = append $categories "Gelehrte Nachrichten" -}} {{- end -}} {{- if $categoryFlags.Anzeige -}} {{- $categories = append $categories "Anzeige" -}} {{- end -}} {{- if $categoryFlags.Proklamation -}} {{- $categories = append $categories "Proklamation" -}} {{- end -}} {{- if $categoryFlags.Desertionsliste -}} {{- $categories = append $categories "Desertionsliste" -}} {{- end -}} {{- if $categoryFlags.Notenblatt -}} {{- $categories = append $categories "Notenblatt" -}} {{- end -}} {{- if $categoryFlags.Vorlesungsverzeichnis -}} {{- $categories = append $categories "Vorlesungsverzeichnis" -}} {{- end -}} {{- if $categoryFlags.Abbildung -}} {{- $categories = append $categories "Abbildung" -}} {{- end -}} {{- if $categoryFlags.Ineigenersache -}} {{- $categories = append $categories "In eigener Sache" -}} {{- end -}} {{- if $categoryFlags.Provinienz -}} {{- $categories = append $categories "Provinienz" -}} {{- end -}} {{- /* Display category combination */ -}} {{- $categoryName := "" -}} {{- if eq (len $categories) 0 -}} {{- $categoryName = "Beitrag" -}} {{- else -}} {{- $sortedCategories := sortStrings $categories -}} {{- $categoryName = joinWithUnd $sortedCategories -}} {{- end -}} {{- /* Generate piece descriptions */ -}} {{- if has $categories "Rezension" -}} {{- /* Collect all additional authors (not current actor) */ -}} {{- $additionalAuthors := slice -}} {{- $currentAuthorFound := false -}} {{- range $agentref := $piece.AgentRefs -}} {{- if (or (eq $agentref.Category "") (eq $agentref.Category "autor")) -}} {{- $agent := GetAgent $agentref.Ref -}} {{- if and $agent (gt (len $agent.Names) 0) -}} {{- if ne $agentref.Ref $currentActorID -}} {{- $additionalAuthors = append $additionalAuthors $agent -}} {{- else -}} {{- $currentAuthorFound = true -}} {{- end -}} {{- end -}} {{- end -}} {{- end -}} {{- /* Display review with proper author attribution */ -}} {{- if $additionalAuthors -}} mit {{ range $i, $author := $additionalAuthors }}{{- if gt $i 0 }} und {{ end }}{{ index $author.Names 0 }}{{ end }}, {{ $categoryName }} von: {{- else if $currentAuthorFound -}} {{ $categoryName }} von: {{- else -}} {{ $categoryName }} von: {{- end -}} {{ if $workAuthorName }} {{ $workAuthorName }}, {{ end }} {{ if $workTitle }} {{ $workTitle }} {{ else if $title }} {{ $title }} {{ else }} [Werk unbekannt] {{ end }} {{- else -}} {{- /* Collect all additional authors (not current actor) */ -}} {{- $additionalAuthors := slice -}} {{- $currentAuthorFound := false -}} {{- range $agentref := $piece.AgentRefs -}} {{- if (or (eq $agentref.Category "") (eq $agentref.Category "autor")) -}} {{- $agent := GetAgent $agentref.Ref -}} {{- if and $agent (gt (len $agent.Names) 0) -}} {{- if ne $agentref.Ref $currentActorID -}} {{- $additionalAuthors = append $additionalAuthors $agent -}} {{- else -}} {{- $currentAuthorFound = true -}} {{- end -}} {{- end -}} {{- end -}} {{- end -}} {{- /* Display with proper author attribution */ -}} {{- if $additionalAuthors -}} mit {{ range $i, $author := $additionalAuthors }}{{- if gt $i 0 }} und {{ end }}{{ index $author.Names 0 }}{{ end }}, {{ $categoryName }}{{ if $title }}: {{ $title }}{{ end }} {{- else if $currentAuthorFound -}} {{ $categoryName }}{{ if $title }}: {{ $title }}{{ end }} {{- else -}} {{ $categoryName }}{{ if $title }}: {{ $title }}{{ else if eq $categoryName "Beitrag" }} ohne Titel{{ end }} {{- end -}} {{- end -}}