Files
musenalm/views/routes/suche/beitraege/body.gohtml
2025-03-02 19:59:44 +01:00

251 lines
7.5 KiB
Plaintext

{{ $model := . }}
{{/* .result:
type SearchResultBeitraege struct {
Queries []dbmodels.FTS5QueryRequest
// these are the sorted IDs for hits
Hits []string
Entries map[string]*dbmodels.Entry // <- Key: Entry ID
Agents map[string]*dbmodels.Agent // <- Key: Agent IDs
Contents map[string][]*dbmodels.Content // <- Key: Entry ID, or year
ContentsAgents map[string][]*dbmodels.RContentsAgents // <- Key: Content ID
}
.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
}
.filters
type BeitraegeFilterParameters struct {
Agent string
Type string
Year string
OnlyScans bool
}
*/}}
{{ $isAlm := false }}
{{ $isTitle := false }}
{{ $isYear := false }}
{{ $isPerson := false }}
{{ $isAnnotation := false }}
{{ $isIncipit := false }}
{{ $isEntry := false }}
{{- $isAlm = $model.parameters.AlmString -}}
{{- $isTitle = or $model.parameters.Title $model.parameters.TitleString -}}
{{- $isYear = or $model.parameters.Year $model.parameters.YearString -}}
{{- $isPerson = or $model.parameters.Persons $model.parameters.PersonsString -}}
{{- $isAnnotation = or $model.parameters.Annotations $model.parameters.AnnotationsString -}}
{{- $isIncipit = or $model.parameters.Incipit $model.parameters.IncipitString -}}
{{- $isEntry = or $model.parameters.Entry $model.parameters.EntryString -}}
{{- $isBase := not (or $isTitle $isYear $isPerson $isAnnotation $isIncipit $isEntry) -}}
<div id="searchcontrol" class="container-normal">
{{- template "_heading" $model.parameters -}}
<div id="searchform" class="border-l border-zinc-300 px-8 py-10 relative">
{{- if not $model.parameters.Extended -}}
{{- template "_musenalmidbox" Arr $model.parameters.AlmString "beitraege" -}}
{{- end -}}
<form
id="simplesearchform"
class="w-full font-serif"
method="get"
hx-indicator="body"
action="/suche/beitraege"
autocomplete="off">
{{- if not $model.parameters.Extended -}}
<div class="searchformcolumn">
{{- $q := "" }}
{{- if $model.parameters.Query -}}
{{- $q = $model.parameters.Query -}}
{{- end -}}
{{ template "_searchboxsimple" Arr $model.parameters true $q }}
<fieldset class="selectgroup">
<div class="selectgroup-option">
<input
type="checkbox"
name="title"
id="title"
{{ if or $isBase $isTitle -}}checked{{- end -}} />
<label for="title">Titel</label>
</div>
<div class="selectgroup-option">
<input
type="checkbox"
name="incipit"
id="incipit"
{{ if or $isBase $isIncipit -}}checked{{- end -}} />
<label for="incipit">Incipit</label>
</div>
<div class="selectgroup-option">
<input
type="checkbox"
name="persons"
id="persons"
{{ if or $isBase $isPerson -}}checked{{- end -}} />
<label for="person">Personen &amp; Pseudonyme</label>
</div>
<div class="selectgroup-option">
<input
type="checkbox"
name="entry"
id="entry"
{{ if or $isBase $isEntry -}}checked{{- end -}} />
<label for="entry">Bandtitel</label>
</div>
<div class="selectgroup-option">
<input
type="checkbox"
name="year"
id="year"
{{ if or $isBase $isYear -}}checked{{- end -}} />
<label for="year">Jahr</label>
</div>
<div class="selectgroup-option">
<input
type="checkbox"
name="annotations"
id="annotations"
{{ if or $isBase $isAnnotation -}}checked{{- end -}} />
<label for="annotations">Anmerkungen</label>
</div>
</fieldset>
{{ template "_infotextsimple" true }}
</div>
{{- else -}}
<div id="extendedsearchcolumn" class="">
<input type="hidden" name="extended" value="true" />
<label for="titlestring">Titel</label>
<input
type="search"
name="titlestring"
id="titlestring"
value="{{ $model.parameters.TitleString }}" />
<label for="incipitstring">Incipit</label>
<input
type="search"
name="incipitstring"
id="incipitstring"
value="{{ $model.parameters.IncipitString }}" />
<label for="personsstring">Personen &amp; Verlage</label>
<input
type="search"
name="personsstring"
id="personsstring"
value="{{ $model.parameters.PersonsString }}" />
<label for="entrystring">Bandtitel</label>
<input
type="search"
name="entrystring"
id="entrystring"
value="{{ $model.parameters.PlacesString }}" />
<label for="yearstring">Jahr</label>
<input
type="search"
name="yearstring"
id="yearstring"
value="{{ $model.parameters.YearString }}" />
<label for="annotationsstring">Anmerkungen</label>
<input
type="search"
name="annotationsstring"
id="annotationsstring"
value="{{ $model.parameters.AnnotationsString }}" />
<button id="submitbutton" type="submit" class="">Suchen</button>
<a href="/suche/beitraege" class="whitespace-nowrap"
><i class="ri-arrow-left-long-line"></i> Zurück zur einfachen Suche</a
>
</div>
{{- end -}}
</form>
</div>
</div>
{{- template "_fieldscript" -}}
{{- if $model.parameters.IsBeitraegeSearch -}}
<div class="cotents" id="searchresults">
{{- $isFiltered := or $model.filters.Agent $model.filters.Year $model.filters.Type -}}
{{- if and $model.result.Hits (not $isFiltered) -}}
{{ template "_filterlist" $model }}
{{- end -}}
<div class="container-normal flex flex-col h-full" id="subresults">
{{ template "tablehead" $model }}
{{ template "pills" $model }}
{{- if $model.result.Hits -}}
<div class="mt-8" id="almanachcontents">
{{- range $_, $hit := $model.result.Hits -}}
{{- $e := index $model.result.Entries $hit -}}
{{- $contents := index $model.result.Contents $e.Id -}}
<div
class="font-serif flex flex-row justify-between text-stone-800
font-bold border-b pb-0.5 mb-2 tab-list-head items-end">
<div>
{{ $e.PreferredTitle }}
</div>
<div
class="inline-block font-sans bg-slate-800 text-white h-max text-sm px-1.5 rounded">
{{- len $contents -}}
</div>
</div>
<div class="mb-7 tab-list-panel">
{{- range $i, $c := $contents -}}
{{- $rels := index $model.result.ContentsAgents $c.Id -}}
{{- template "_content" Arr $c $e $rels $model.result.Agents false true
$model.parameters
-}}
{{- end -}}
</div>
{{- end -}}
</div>
{{- end -}}
{{- if $model.result.Hits -}}
<div class="flex flex-row justify-end items-start border-t border-zinc-300 pt-4">
{{- template "pagination" $model -}}
</div>
{{- else -}}
<div class="mt-4">Kein Beitrag gefunden.</div>
{{- end -}}
<script type="module">
let elements = document.querySelectorAll('.search-text');
let mark_instance = new Mark(elements);
// INFO: we wait a little bit before marking, to settle everything
setTimeout(() => {
mark_instance.mark('{{ $model.parameters.AllSearchTermsBeitraege }}', {
"seperateWordSearch": true,
});
}, 200);
</script>
</div>
</div>
{{- end -}}