mirror of
				https://github.com/Theodor-Springmann-Stiftung/kgpz_web.git
				synced 2025-10-31 09:55:30 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			159 lines
		
	
	
		
			6.8 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			159 lines
		
	
	
		
			6.8 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| {{ $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 }}
 | |
| 	<div class="mt-4 akteur-werke-section">
 | |
| 		<div class="py-1 rounded-lg mb-1">
 | |
| 			<h2 class="font-bold">
 | |
| 				<i class="ri-book-line mr-2"></i><u class="decoration underline-offset-3">Werke</u>
 | |
| 			</h2>
 | |
| 		</div>
 | |
| 		<div class="">
 | |
| 		{{ range $_, $w := $works }}
 | |
| 			<div class="mb-2 break-inside-avoid max-w-[95ch]">
 | |
| 				{{- if ne (len $w.Item.Citation.InnerXML ) 0 -}}
 | |
| 					<div class="indent-6">
 | |
| 						{{- Safe $w.Item.Citation.HTML -}}
 | |
| 						{{- range $_, $url := $w.Item.URLs -}}
 | |
| 							<span class="ml-1 whitespace-nowrap">
 | |
| 								<a href="{{ $url.Address }}" target="_blank" class="text-blue-600 hover:text-blue-800 text-sm">
 | |
| 									{{ $url.Chardata }} <i class="ri-external-link-line text-xs"></i>
 | |
| 								</a>
 | |
| 							</span>
 | |
| 						{{- end -}}
 | |
| 					</div>
 | |
| 				{{- end -}}
 | |
| 
 | |
| 				{{- /* Find all pieces that reference this work */ -}}
 | |
| 				{{ $workPieces := LookupPieces $w.Item }}
 | |
| 				{{ if len $workPieces }}
 | |
| 					<div class="">
 | |
| 						{{- /* 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 for this piece (excluding current person) */ -}}
 | |
| 							{{- $pieceAuthors := 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 -}}
 | |
| 								{{- end -}}
 | |
| 							{{- end -}}
 | |
| 							{{- $sortedAuthors := sortStrings $pieceAuthors -}}
 | |
| 
 | |
| 							{{- /* Create group key: categories + authors */ -}}
 | |
| 							{{- $sortedCategories := sortStrings $categories -}}
 | |
| 							{{- $groupKey := printf "%s|%s" (joinWithUnd $sortedCategories) (joinWithUnd $sortedAuthors) -}}
 | |
| 
 | |
| 							{{- /* 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 -}}
 | |
| 							<div class="mb-1 text-gray-600">
 | |
| 								{{- /* Extract categories and authors from group key */ -}}
 | |
| 								{{- $keyParts := split $groupKey "|" -}}
 | |
| 								{{- $categoryName := index $keyParts 0 -}}
 | |
| 								{{- $authorPart := index $keyParts 1 -}}
 | |
| 
 | |
| 								{{- /* 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 ne $authorPart "" }} von {{ range $i, $authorID := (split $authorPart " und ") }}{{- if gt $i 0 }} und {{ end }}{{- $agent := GetAgent $authorID -}}{{- if and $agent (gt (len $agent.Names) 0) -}}<a href="/akteure/{{ $authorID }}" class="text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600">{{ index $agent.Names 0 }}</a>{{- 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 -}}
 | |
| 										<span class="text-blue-600 hover:text-blue-700 underline decoration-dotted hover:decoration-solid [&>a]:text-blue-600 [&>a:hover]:text-blue-700">{{- template "_citation" $issue -}}</span>
 | |
| 									{{- end -}}
 | |
| 									{{- /* Add "Ganzer Beitrag" link if piece spans multiple issues */ -}}
 | |
| 									{{- if gt (len $p.Item.IssueRefs) 1 -}}
 | |
| 										{{ " " }}<div class="inline-flex items-center gap-1 px-2 py-1 bg-blue-50 hover:bg-blue-100 text-blue-700 hover:text-blue-800 border border-blue-200 hover:border-blue-300 rounded text-xs font-medium transition-colors duration-200">
 | |
| 											<i class="ri-file-copy-2-line text-xs"></i>
 | |
| 											<a href="{{ GetPieceURL $p.Item.ID }}" class="">
 | |
| 												Ganzer Beitrag
 | |
| 											</a>
 | |
| 										</div>
 | |
| 									{{- end -}}
 | |
| 								{{- end -}}
 | |
| 							</div>
 | |
| 						{{- end -}}
 | |
| 					</div>
 | |
| 				{{ end }}
 | |
| 			</div>
 | |
| 		{{ end }}
 | |
| 
 | |
| 		</div>
 | |
| 	</div>
 | |
| {{ end }} | 
