Files
musenalm/views/routes/components/_content.gohtml
2025-02-28 22:31:19 +01:00

243 lines
6.8 KiB
Plaintext

{{ $model := . }}
{{/* .1 - *Content
.2 - *Entry
.3 - []*RContentsAgents
.4 - map[string]*Agent
.5 bool SingleView
.6 .parameters:
type SearchParameters struct {
Parameters
Sort string
Annotations bool
Persons bool
Title bool
Series bool
Places bool
Refs bool
Year bool
Entry bool
Incipit bool
AnnotationsString string
PersonsString string
TitleString string
AlmString string
SeriesString string
PlacesString string
RefsString string
YearString string
EntryString string
IncipitString string
}
*/}}
{{- $content := index . 0 -}}
{{- $entry := index . 1 -}}
{{- $rcas := index . 2 -}}
{{- $agents := index . 3 -}}
{{- $singleView := false -}}
{{- if gt (len .) 4 -}}
{{- $singleView = index . 4 -}}
{{- end -}}
{{- $entrySubView := false -}}
{{- if gt (len .) 5 -}}
{{- $entrySubView = index . 5 -}}
{{- end -}}
{{ $isAlm := false }}
{{ $isTitle := false }}
{{ $isYear := false }}
{{ $isPerson := false }}
{{ $isAnnotation := false }}
{{ $isIncipit := false }}
{{ $isEntry := false }}
{{- $searchparameters := false -}}
{{- if gt (len .) 6 -}}
{{- $searchparameters = index . 6 -}}
{{- $isAlm = $searchparameters.AlmString -}}
{{- $isTitle = or $searchparameters.Title $searchparameters.TitleString -}}
{{- $isYear = or $searchparameters.Year $searchparameters.YearString -}}
{{- $isPerson = or $searchparameters.Persons $searchparameters.PersonsString -}}
{{- $isAnnotation = or $searchparameters.Annotations $searchparameters.AnnotationsString -}}
{{- $isIncipit = or $searchparameters.Incipit $searchparameters.IncipitString -}}
{{- $isEntry = or $searchparameters.Entry $searchparameters.EntryString -}}
{{- end -}}
<div
class="content flex flex-row font-serif {{ if or $entrySubView $singleView -}}text-lg{{- end -}}"
id="{{- $content.MusenalmID -}}">
{{- if and (not $singleView) (not $entrySubView) -}}
<div class="w-36 shrink-0 grow-0 flex flex-col items-end columnone">
{{- if $content.Extent -}}
<div>
<span class="font-sans text-sm">S. </span>
<b>{{- $content.Extent -}}</b>
</div>
{{- end -}}
{{- if $content.MusenalmType -}}
<div class="flex flex-col gap-y-1 items-end">
{{- range $_, $t := $content.MusenalmType -}}
<div class="font-sans text-sm bg-stone-100 px-1 py-0.5 rounded w-max">
{{- $t -}}
</div>
{{- end -}}
</div>
{{- end -}}
</div>
{{- end -}}
<div class="grow columntwo">
<div class="fields">
{{- if or $singleView $entrySubView -}}
<div class="fieldlabel">Almanach</div>
<div class="fieldvalue {{ if $isEntry }}search-text{{ end }}">
<a href="/almanach/{{- $entry.MusenalmID -}}#{{- $content.MusenalmID -}}">
{{- $entry.PreferredTitle -}}
</a>
{{- if $content.Extent -}}
, <span class="font-sans text-sm">S. </span>
<b>{{- $content.Extent -}}</b>
{{- end -}}
</div>
{{- end -}}
{{- if $content.TitleStmt -}}
<div class="fieldlabel">Titel</div>
<div class="italic fieldvalue {{ if $isTitle }}search-text{{ end }}">
{{- $content.TitleStmt -}}
</div>
{{- end -}}
{{- if $content.IncipitStmt -}}
<div class="fieldlabel">Incipit</div>
<div class="italic fieldvalue {{ if $isIncipit }}search-text{{ end }}">
{{ $content.IncipitStmt }}…
</div>
{{- end -}}
{{- if $content.ResponsibilityStmt -}}
<div class="fieldlabel">Autorangabe</div>
<div class="fieldvalue italic {{ if $isPerson }}search-text{{ end }}">
{{- $content.ResponsibilityStmt -}}
</div>
{{- end -}}
{{- if $rcas -}}
<div class="fieldlabel">Personen</div>
<div class="fieldvalue">
<div class="flex flex-col">
{{- range $_, $rca := $rcas -}}
{{- $agent := index $agents $rca.Agent -}}
<div class="font-sans text-base bg-stone-100 px-1 py-0.5 rounded w-max">
<a
href="/person/{{- $agent.Id -}}"
class="inline-block {{ if $isPerson }}search-text{{ end }}">
{{- $agent.Name -}}
</a>
({{ $agent.BiographicalData -}})
</div>
{{- end -}}
</div>
</div>
{{- end -}}
{{- if $content.Annotation -}}
{{- $link := printf "%s%s" "/almanach/" $entry.MusenalmIDString -}}
<div class="fieldlabel">Anmerkung</div>
<div class="fieldvalue {{ if $isAnnotation }}search-text{{ end }}">
{{- Safe (LinksAnnotation (ReplaceSlashParen
$content.Annotation) $link)
-}}
</div>
{{- end -}}
</div>
</div>
{{- if not $singleView -}}
{{- $scans := $content.ImagePaths -}}
{{- $slen := len $scans -}}
{{- $double := false -}}
{{- if gt $slen 2 -}}
{{- $double = true -}}
{{- end -}}
<div
class="{{- if $double }}
w-[20rem]
{{- else }}
w-[10rem]
{{- end }} grow-0 shrink-0 columnthree">
{{- if $scans -}}
<div class="{{- if $double -}}grid grid-cols-2{{- end -}}">
{{- range $_, $scan := $scans -}}
<div
class="border-6 hover:border-zinc-400 transition-all duration-75
border-zinc-100 overflow-hidden">
<popup-image data-image-url="{{- $scan -}}">
<img
src="{{- $scan -}}?thumb=300x0"
class="w-36 h-36 object-cover
cursor-pointer" />
</popup-image>
</div>
{{- end -}}
</div>
{{- end -}}
</div>
<div class="w-24 shrink-0 grow-0 items-end flex flex-col gap-y-1 columnfour">
<div class="font-sans text-sm bg-stone-100 px-2 font-bold py-0.5 rounded w-max">
<span class="text-xs font-normal pr-1">NR</span>
<span class="{{ if $isAlm }}search-text{{ end }}">
{{- $content.MusenalmID -}}
</span>
</div>
{{- if $entrySubView -}}
{{- if $content.MusenalmType -}}
<div class="flex flex-col gap-y-1 items-end">
{{- range $_, $t := $content.MusenalmType -}}
<div class="font-sans text-sm bg-stone-100 px-1 py-0.5 rounded w-max font-bold">
{{- $t -}}
</div>
{{- end -}}
</div>
{{- end -}}
{{- end -}}
<div class="font-sans py-0.5 text-sm">
<a
href="/beitrag/{{ $content.MusenalmID }}"
class="no-underline rounded bg-stone-100 px-1.5">
Link <i class="ri-links-line"></i>
</a>
</div>
</div>
{{- end -}}
</div>
{{- if $singleView -}}
{{- $scans := $content.ImagePaths -}}
{{- $slen := len $scans -}}
{{- $double := false -}}
{{- if gt $slen 2 -}}
{{- $double = true -}}
{{- end -}}
<div class="">
{{- if $scans -}}
<div class="flex flex-row row-auto gap-4 mt-6 flex-wrap">
{{- range $i, $scan := $scans -}}
<div
class="transition-all duration-75
border-zinc-100 overflow-hidden">
<popup-image data-image-url="{{- $scan -}}">
<img
src="{{- $scan -}}?thumb=0x1000"
class="max-h-[32rem] border-6 hover:border-zinc-400 object-cover cursor-pointer" />
</popup-image>
</div>
{{- end -}}
</div>
{{- end -}}
</div>
{{- end -}}