FTS5-Suche

This commit is contained in:
Simon Martens
2025-02-22 19:08:36 +01:00
parent 29576ec7a0
commit 3d54725283
28 changed files with 795 additions and 77 deletions

View File

@@ -52,7 +52,7 @@
hx-boost="false">
<i class="ri-links-line"></i
></a>
<div class="data-tip">Permalink zu dieser Suchanfrage</div>
<div class="data-tip">Link zu dieser Suchanfrage</div>
</tool-tip>
</div>
</div>

View File

@@ -2,7 +2,8 @@
{{ $entries := index . 1 }}
{{ $relations := index . 2 }}
{{ $showidseries := index . 3 }}
{{ $markar := index . 4 }}
{{ $marka := index . 4 }}
{{ $markr := index . 5 }}
{{ $bds := index $relations $r.Id }}
@@ -10,7 +11,7 @@
<div class="flex flex-col lg:flex-row mb-1.5">
<div class="grow-0 shrink-0 w-[12rem] flex flex-col">
{{ if $r.References }}
<div class="text-sm font-sans px-2 py-1 bg-stone-100 {{ if $markar }}reihen-text{{ end }}">
<div class="text-sm font-sans px-2 py-1 bg-stone-100 {{ if $markr }}reihen-text{{ end }}">
{{ $r.References }}
</div>
{{ end }}
@@ -37,7 +38,7 @@
<span class="font-bold reihen-text">{{ $r.Title }}</span>
{{ if $r.Annotation }}
<span>&ensp;&middot;&ensp;</span>
<span class="{{ if $markar }}reihen-text{{ end }}">{{ Safe $r.Annotation }}</span>
<span class="{{ if $marka }}reihen-text{{ end }}">{{ Safe $r.Annotation }}</span>
{{ end }}
</div>
<div></div>

View File

@@ -1,4 +1,6 @@
<h1>Die Seite konnte nicht gefunden werden!</h1>
{{ if .Error }}
<p>{{ .Error }}</p>
{{ end }}
<div class="container-normal">
<h1>Die Seite konnte nicht gefunden werden!</h1>
{{ if .Error }}
<p>{{ .Error }}</p>
{{ end }}
</div>

View File

@@ -13,16 +13,16 @@
<img src="{{ .record.ImagePath }}" />
</div>
</div>
<div class="absolute top-0 right-0 p-4">
<div class="absolute top-0 right-0 m-4 mr-8">
<tool-tip position="left">
<div class="data-tip">Hinweis schließen</div>
<button
@click="open = false"
class="text-xl p-2 text-stone-500 opacity-85 hover:opacity-100 transition-opacity
duration-200 hover:text-stone-900
class="text-3xl text-stone-500 opacity-85 hover:opacity-100 transition-opacity
duration-200 hover:text-stone-900 leading-none
hover:cursor-pointer">
<i class="ri-close-circle-fill"></i>
</button>
<div class="data-tip">Hinweis schließen</div>
</tool-tip>
</div>
</div>
@@ -138,7 +138,7 @@
{{ if and .search .idseries }}
<div class="mb-1 max-w-[60rem] hyphens-auto">
{{ range $id, $r := .idseries }}
{{ template "_reihe" (Arr $r $model.entries $model.relations true false) }}
{{ template "_reihe" (Arr $r $model.entries $model.relations true false false) }}
{{ end }}
</div>
{{ end }}
@@ -146,7 +146,9 @@
{{ if .series }}
<div class="mb-1 max-w-[60rem] hyphens-auto">
{{ range $id, $r := .series }}
{{ template "_reihe" (Arr $r $model.entries $model.relations false false) }}
{{ template "_reihe" (Arr $r $model.entries $model.relations false false
false)
}}
{{ end }}
</div>
{{ end }}
@@ -171,11 +173,11 @@
</div>
{{ end }}
<div class="border-t mb-1.5 text-sm font-sans text-right pt-0.5">
Treffer in allen Feldern (Anmerkungen, Verweisen etc.) &darr;
Treffer in allen Feldern (inkl. Anmerkungen &amp; Verweise) &darr;
</div>
<div class="mb-1 max-w-[60rem] hyphens-auto">
{{ range $id, $r := .altseries }}
{{ template "_reihe" (Arr $r $model.entries $model.relations false true) }}
{{ template "_reihe" (Arr $r $model.entries $model.relations false true true) }}
{{ end }}
</div>
{{ end }}

View File

@@ -0,0 +1,88 @@
{{ $model := . }}
<div id="searchcontrol" class="container-normal">
<div id="searchheading" class="flex flex-row justify-between min-h-14 items-end relative">
<nav id="searchnav" class="flex flex-row items-end">
<div class="align-bottom h-min self-end pb-0.5 hidden">Durchsuchen:</div>
<a
href="/suche/reihen"
class="block no-underline"
{{ if eq $model.type "reihen" }}aria-current="page"{{- end -}}
>Reihen</a
>
<a
href="/suche/baende"
class="block no-underline"
{{ if eq $model.type "baende" }}aria-current="page"{{- end -}}
>Bände</a
>
<a
href="/suche/beitraege"
class="block no-underline"
{{ if eq $model.type "beitraege" }}aria-current="page"{{- end -}}
>Beiträge</a
>
<a
href="/suche/personen"
class="block no-underline"
{{ if eq $model.type "personen" }}aria-current="page"{{- end -}}
>Personen</a
>
</nav>
<h1
class="text-3xl font-bold px-3 relative translate-y-[45%] w-min whitespace-nowrap
bg-stone-50 mr-24 z-20">
Suche&nbsp;&middot;&nbsp;<span class="">
{{- if eq $model.type "reihen" -}}
Reihen
{{- else if eq $model.type "personen" -}}
Personen &amp; Körperschaften
{{- else if eq $model.type "baende" -}}
Bände
{{- else if eq $model.type "beitraege" -}}
Beiträge
{{- end -}}
</span>
</h1>
</div>
<div id="" class="border-l border-zinc-300 px-8 py-10 relative">
{{ template "searchform" $model }}
</div>
</div>
{{- if $model.q -}}
<div id="searchresults">
{{- if eq $model.type "reihen" -}}
<!-- INFO: Resultate Reihen -->
<div id="" class="container-normal mt-4">
{{- if $model.series -}}
{{- $includeReferences := index $model.options "references" -}}
{{- $includeAnnotations := index $model.options "annotations" -}}
<div class="mb-1 max-w-[60rem] hyphens-auto">
{{- range $id, $r := $model.series -}}
{{- template "_reihe" (Arr $r $model.entries $model.relations false
$includeAnnotations $includeReferences)
-}}
{{- end -}}
</div>
{{ else }}
{{- end -}}
</div>
<script type="module">
let elements = document.querySelectorAll('.reihen-text');
let mark_instance = new Mark(elements);
// INFO: we wait a little bit before marking, to settle everything
setTimeout(() => {
let word = '{{ $model.q }}';
word = word.replace(/[.,\/#!$%\^&\*;:{}=\-_`~()]/g,"");
mark_instance.mark(word, {
"seperateWordSearch": true,
"ignorePunctuation": [""],
});
}, 200);
</script>
<!-- INFO: Resultate Reihen Ende -->
{{- end -}}
</div>
{{- end -}}

View File

@@ -0,0 +1,17 @@
{{ $extendable := . }}
<div class="col-span-6 flex flex-row text-stone-700 gap-x-2">
<div>
<i class="ri-information-2-fill"></i>
</div>
<div class="font-sans hyphens-auto text-sm pt-1">
Die Suche durchsucht ganze Datensätze nach dem Vorkommen aller eingegebenen Suchbegriffe. Felder
können oben einzeln aus der Suche ausgeschlossen werden. Auch partielle Treffer in Worten werden
angezeigt. Wörter mit weniger als drei Zeichen, Sonderzeichen &ndash; auch Satzzeichen &ndash;
sowie die Groß- und Kleinschreibung werden dabei ignoriert
{{- if $extendable }}
(für mehr Optionen s. die &rarr; <a href="?extended=true">erweiterte Suche</a>)
{{- end -}}.
</div>
</div>

View File

@@ -0,0 +1,45 @@
{{ $model := index . 0 }}
{{ $extendable := index . 1 }}
<label for="q" class="hidden">Suchbegriffe</label>
<input
{{ if $model.q }}value="{{ $model.q }}"{{- end -}}
type="search"
name="q"
autofocus="true"
minlength="3"
required
placeholder="Suchbegriff (min. 3 Zeichen)"
class="w-full col-span-8
placeholder:italic" />
<button id="submitbutton" type="submit" class="col-span-2">Suchen</button>
{{ if $extendable }}
<a
href="/suche/{{ $model.type }}?extended=true"
class="whitespace-nowrap self-end block col-span-2">
<i class="ri-arrow-right-long-line"></i> Erweiterte Suche
</a>
{{ end }}
<script type="module">
const form = document.getElementById("searchform");
const submitBtn = document.getElementById("submitbutton");
function checkValidity() {
if (form.checkValidity()) {
submitBtn.disabled = false;
} else {
submitBtn.disabled = true;
}
}
checkValidity();
if (form && submitBtn) {
form.addEventListener("input", (event) => {
checkValidity();
});
}
</script>

View File

@@ -0,0 +1,193 @@
{{ $model := . }}
{{- $includeReferences := true -}}
{{- $includeAnnotations := true -}}
{{- $includeTitle := true -}}
{{- if eq $model.type "reihen" -}}
{{- if $model.options -}}
{{- $includeReferences = not (and $model.q (not (index $model.options "references"))) -}}
{{- $includeAnnotations = not (and $model.q (not (index $model.options "annotations"))) -}}
{{- $includeTitle = not (and $model.q (not (index $model.options "title"))) -}}
{{- end -}}
{{- end -}}
<form
id="searchform"
class="w-full font-serif"
method="get"
action="/suche/{{- $model.type -}}"
autocomplete="off">
{{- if eq $model.type "reihen" -}}
<!-- INFO: Reihen -->
{{- if not $model.extended -}}
<div class="grid grid-cols-12 gap-y-3 w-full gap-x-4">
{{ template "searchboxsimple" Arr . false }}
<fieldset class="selectgroup">
<div class="selectgroup-option">
<input
type="checkbox"
name="title"
id="title"
{{ if $includeTitle -}}
checked
{{- end -}} />
<label for="title">Titel</label>
</div>
<div class="selectgroup-option">
<input
type="checkbox"
name="annotations"
id="annotations"
{{ if $includeAnnotations -}}
checked
{{- end -}} />
<label for="annotations">Anmerkungen</label>
</div>
<div class="selectgroup-option">
<input
type="checkbox"
name="references"
id="references"
{{ if $includeReferences -}}
checked
{{- end -}} />
<label for="references">Nachweise</label>
</div>
</fieldset>
{{ template "infotextsimple" false }}
</div>
{{- else -}}
Extended search Reihen
{{- end -}}
<!-- INFO: Ende Reihen -->
{{- else if eq $model.type "personen" -}}
<!-- INFO: Personen -->
{{- if not $model.extended -}}
<div class="grid grid-cols-12 gap-y-3 w-full gap-x-4">
{{ template "searchboxsimple" Arr . false }}
<fieldset class="selectgroup">
<div class="selectgroup-option">
<input type="checkbox" name="names" id="names" checked />
<label for="names">Namen &amp; Pseudonyme</label>
</div>
<div class="selectgroup-option">
<input type="checkbox" name="biographical" id="biographical" checked />
<label for="biographical">Lebensdaten</label>
</div>
<div class="selectgroup-option">
<input type="checkbox" name="profession" id="profession" checked />
<label for="profession">Beruf(e)</label>
</div>
<div class="selectgroup-option">
<input type="checkbox" name="annotations" id="annotations" checked />
<label for="annotations">Anmerkungen</label>
</div>
<div class="selectgroup-option">
<input type="checkbox" name="references" id="references" checked />
<label for="references">Nachweise</label>
</div>
</fieldset>
{{ template "infotextsimple" false }}
</div>
{{- else -}}
Extended search Personen
{{- end -}}
<!-- INFO: Ende Personen -->
{{- else if eq $model.type "baende" -}}
<!-- INFO: Bände -->
{{- if not $model.extended -}}
<div class="grid grid-cols-12 gap-y-3 w-full gap-x-4">
{{ template "searchboxsimple" Arr . true }}
<fieldset class="selectgroup">
<div class="selectgroup-option">
<input type="checkbox" name="number" id="number" checked />
<label for="number">Almanach-Nr.</label>
</div>
<div class="selectgroup-option">
<input type="checkbox" name="title" id="title" checked />
<label for="title">Titel</label>
</div>
<div class="selectgroup-option">
<input type="checkbox" name="series" id="series" checked />
<label for="series">Reihentitel</label>
</div>
<div class="selectgroup-option">
<input type="checkbox" name="person" id="person" checked />
<label for="person">Personen &amp; Verlage</label>
</div>
<div class="selectgroup-option">
<input type="checkbox" name="pubdata" id="pubdata" checked />
<label for="pubdata">Orte</label>
</div>
<div class="selectgroup-option">
<input type="checkbox" name="year" id="year" checked />
<label for="year">Jahr</label>
</div>
<div class="selectgroup-option">
<input type="checkbox" name="references" id="references" checked />
<label for="references">Nachweise</label>
</div>
<div class="selectgroup-option">
<input type="checkbox" name="annotations" id="annotations" checked />
<label for="annotations">Anmerkungen</label>
</div>
</fieldset>
{{ template "infotextsimple" true }}
</div>
{{- else -}}
Extended search Bände
{{- end -}}
<!-- INFO: Ende Bände -->
{{- else if eq $model.type "beitraege" -}}
<!-- INFO: Beiträge -->
{{- if not $model.extended -}}
<div class="grid grid-cols-12 gap-y-3 w-full gap-x-4">
{{ template "searchboxsimple" Arr . true }}
<fieldset class="selectgroup">
<div class="selectgroup-option">
<input type="checkbox" name="number" id="number" checked />
<label for="number">Almanach-Nr.</label>
</div>
<div class="selectgroup-option">
<input type="checkbox" name="title" id="title" checked />
<label for="title">Titelinformationen</label>
</div>
<div class="selectgroup-option">
<input type="checkbox" name="entry" id="entry" checked />
<label for="entry">Bandtitel</label>
</div>
<div class="selectgroup-option">
<input type="checkbox" name="person" id="person" checked />
<label for="person">Personen &amp; Pseudonyme</label>
</div>
<div class="selectgroup-option">
<input type="checkbox" name="annotations" id="annotations" checked />
<label for="annotations">Anmerkungen</label>
</div>
</fieldset>
{{ template "infotextsimple" true }}
</div>
{{- else -}}
Extended search Beiträge
{{- end -}}
{{- end -}}
</form>
<script type="module">
let fieldset = document.querySelector("fieldset.selectgroup");
let checkboxes = Array.from(fieldset.querySelectorAll('input[type="checkbox"]'));
fieldset.addEventListener("change", (event) => {
let target = event.target;
if (target.type === "checkbox") {
let name = target.name;
let checked = target.checked;
if (!checked) {
let allchecked = checkboxes.filter((checkbox) => checkbox.checked);
if (allchecked.length === 0) {
target.checked = true;
}
}
}
});
</script>

View File

@@ -0,0 +1 @@
<title>{{ .site.title }}: Suche</title>