hot reload, search refactor begin

This commit is contained in:
Simon Martens
2025-02-25 19:23:00 +01:00
parent f35c738cee
commit 4d65b71563
24 changed files with 706 additions and 202 deletions

62
views/.air.toml Normal file
View File

@@ -0,0 +1,62 @@
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"
[build]
args_bin = []
full_bin = ""
cmd = "npm run build"
delay = 400
exclude_dir = [
"assets",
"node_modules",
"tmp",
"vendor",
"testdata",
"data_git",
"cache_gnd",
"cache_geonames",
"pb_data",
"Almanach-Bilder",
"Static-Bilder",
]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html", "gohtml", "js", "css", "xsl"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
post_cmd = []
pre_cmd = [""]
rerun = false
rerun_delay = 250
send_interrupt = true
stop_on_error = true
[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"
[log]
main_only = false
time = false
[misc]
clean_on_exit = true
[proxy]
app_port = 8090
enabled = false
proxy_port = 8081
[screen]
clear_on_rebuild = true
keep_scroll = true

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,4 @@
{{ $model := . }}
{{ if and .startpage .record }}
{{ template "hero" . }}
{{ end }}
@@ -17,7 +16,7 @@
{{ template "alphabet" Dict "active" .letter "letters" .letters "search" .search }}
</div>
{{ else }}
<div class="mt-2 border-b border-zinc-300 w-full"></div>
<div class="mt-2 border-b w-full"></div>
{{ end }}
</div>
@@ -42,7 +41,6 @@
{{ end }}
</div>
{{ end }}
{{ if .series }}
<div class="mb-1 max-w-[60rem] hyphens-auto">
{{ range $id, $r := .series }}

View File

@@ -0,0 +1,61 @@
{{ $model := . }}
<div id="searchcontrol" class="container-normal">
{{- template "_heading" $model.parameters.Parameters -}}
<div id="" class="border-l border-zinc-300 px-8 py-10 relative">
{{- if not $model.parameters.Extended -}}
<form
id="searchform"
class="w-full font-serif"
method="get"
action="/suche/baende"
autocomplete="off">
<div class="searchformcolumn">
{{- $q := "" }}
{{- if $model.parameters.Query -}}
{{- q = $model.parameters.Query -}}
{{- end -}}
{{ template "_searchboxsimple" Arr $model.parameters.Parameters true $q }}
<fieldset class="selectgroup">
<div class="selectgroup-option">
<input type="checkbox" name="alm" id="alm" checked />
<label for="alm">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="persons" id="persons" checked />
<label for="persons">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>
</form>
</div>
</div>
{{- template "_fieldscript" -}}

View File

@@ -0,0 +1 @@
<title>{{ .site.title }}: Suche &ndash; Bände</title>

View File

@@ -0,0 +1,48 @@
{{ $model := . }}
<div id="searchcontrol" class="container-normal">
{{- template "_heading" $model.parameters.Parameters -}}
<div id="" class="border-l border-zinc-300 px-8 py-10 relative">
{{- if not $model.parameters.Extended -}}
<form
id="searchform"
class="w-full font-serif"
method="get"
action="/suche/baende"
autocomplete="off">
<div class="searchformcolumn">
{{- $q := "" }}
{{- if $model.parameters.Query -}}
{{- q = $model.parameters.Query -}}
{{- end -}}
{{ template "_searchboxsimple" Arr $model.parameters.Parameters true $q }}
<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>
</form>
</div>
</div>
{{- template "_fieldscript" -}}

View File

@@ -0,0 +1 @@
<title>{{ .site.title }}: Suche &ndash; Beiträge</title>

View File

@@ -0,0 +1,17 @@
<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,53 @@
{{- $model := . -}}
<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 text-lg h-min self-end pb-0.5 italic font-bold
text-zinc-800">
Suche nach:
</div>
<!--
<a
href="/suche/reihen"
class="block no-underline"
{{ if eq $model.Collection "reihen" }}aria-current="page"{{- end -}}
>Reihen</a
>
-->
<a
href="/suche/baende"
class="block no-underline"
{{ if eq $model.Collection "baende" }}aria-current="page"{{- end -}}
>Bänden</a
>
<a
href="/suche/beitraege"
class="block no-underline"
{{ if eq $model.Collection "beitraege" }}aria-current="page"{{- end -}}
>Beiträgen</a
>
<!--
<a
href="/suche/personen"
class="block no-underline"
{{ if eq $model.Collection "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.Collection "reihen" -}}
Reihen
{{- else if eq $model.Collection "personen" -}}
Personen &amp; Körperschaften
{{- else if eq $model.Collection "baende" -}}
Bände
{{- else if eq $model.Collection "beitraege" -}}
Beiträge
{{- end -}}
</span>
</h1>
</div>

View File

@@ -1,10 +1,11 @@
{{ $model := index . 0 }}
{{ $parameters := index . 0 }}
{{ $extendable := index . 1 }}
{{ $q := index . 2 }}
<label for="q" class="hidden">Suchbegriffe</label>
<input
{{ if $model.q }}value="{{ $model.q }}"{{- end -}}
{{ if $q }}value="{{ $q }}"{{- end -}}
type="search"
name="q"
minlength="3"
@@ -16,7 +17,7 @@
{{ if $extendable }}
<a
href="/suche/{{ $model.type }}?extended=true"
href="/suche/{{ $parameters.Collection }}?extended=true"
class="whitespace-nowrap self-end block col-span-2">
<i class="ri-arrow-right-long-line"></i> Erweiterte Suche
</a>

View File

@@ -97,44 +97,6 @@
{{- 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 -}}
@@ -144,28 +106,6 @@
{{- 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 -}}
@@ -173,21 +113,3 @@
{{- 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

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

View File

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

View File

@@ -295,6 +295,10 @@
@apply decoration-slate-900 line-through;
}
#searchform .searchformcolumn {
@apply grid grid-cols-12 gap-y-3 w-full gap-x-4;
}
#persontype a {
@apply px-1.5 border-b-[5px] border-transparent hover:border-zinc-200 no-underline font-serif mx-2.5;
}