more bugs fixed, more bugs created

This commit is contained in:
Simon Martens
2025-02-20 17:16:57 +01:00
parent 37a65ec902
commit cdf8d74cf7
9 changed files with 97 additions and 53 deletions

View File

@@ -27,6 +27,7 @@ type ReihePage struct {
pagemodels.Page pagemodels.Page
} }
// TODO: data richtig seutzen, damit die Reihe mit dem template _reihe angezeigt wird
func (p *ReihePage) Setup(router *router.Router[*core.RequestEvent], app core.App, engine *templating.Engine) error { func (p *ReihePage) Setup(router *router.Router[*core.RequestEvent], app core.App, engine *templating.Engine) error {
router.GET(URL_REIHE, func(e *core.RequestEvent) error { router.GET(URL_REIHE, func(e *core.RequestEvent) error {
id := e.Request.PathValue("id") id := e.Request.PathValue("id")

View File

@@ -150,6 +150,10 @@ func (p *ReihenPage) PlaceRequest(app core.App, engine *templating.Engine, e *co
return p.Get(e, engine, data) return p.Get(e, engine, data)
} }
// BUG: Umlaute werden nicht korrekt gesucht
// BUG: alternative treffer haben keine relations
// TODO: Suche nach Musenalm-ID
// TODO: Suchverhalten bei gefilterten Personen, Orten und Jahren
func (p *ReihenPage) SearchRequest(app core.App, engine *templating.Engine, e *core.RequestEvent) error { func (p *ReihenPage) SearchRequest(app core.App, engine *templating.Engine, e *core.RequestEvent) error {
search := e.Request.URL.Query().Get(PARAM_SEARCH) search := e.Request.URL.Query().Get(PARAM_SEARCH)
data := map[string]interface{}{} data := map[string]interface{}{}

View File

@@ -2,19 +2,19 @@ var _ = (i) => {
throw TypeError(i); throw TypeError(i);
}; };
var g = (i, r, t) => r.has(i) || _("Cannot " + t); var g = (i, r, t) => r.has(i) || _("Cannot " + t);
var c = (i, r, t) => (g(i, r, "read from private field"), t ? t.call(i) : r.get(i)), a = (i, r, t) => r.has(i) ? _("Cannot add the same private member more than once") : r instanceof WeakSet ? r.add(i) : r.set(i, t), o = (i, r, t, e) => (g(i, r, "write to private field"), e ? e.call(i, t) : r.set(i, t), t), f = (i, r, t) => (g(i, r, "access private method"), t); var c = (i, r, t) => (g(i, r, "read from private field"), t ? t.call(i) : r.get(i)), l = (i, r, t) => r.has(i) ? _("Cannot add the same private member more than once") : r instanceof WeakSet ? r.add(i) : r.set(i, t), o = (i, r, t, e) => (g(i, r, "write to private field"), e ? e.call(i, t) : r.set(i, t), t), d = (i, r, t) => (g(i, r, "access private method"), t);
const v = "script[xslt-onload]", m = "xslt-template", A = "xslt-transformed", F = "filter-list", d = "filter-list-list", I = "filter-list-item", w = "filter-list-input", E = "filter-list-searchable"; const v = "script[xslt-onload]", m = "xslt-template", A = "xslt-transformed", F = "filter-list", f = "filter-list-list", w = "filter-list-item", I = "filter-list-input", E = "filter-list-searchable";
var l, p, x; var a, p, b;
class $ { class $ {
constructor() { constructor() {
a(this, p); l(this, p);
a(this, l); l(this, a);
o(this, l, /* @__PURE__ */ new Map()); o(this, a, /* @__PURE__ */ new Map());
} }
setup() { setup() {
let r = htmx.findAll(v); let r = htmx.findAll(v);
for (let t of r) for (let t of r)
f(this, p, x).call(this, t); d(this, p, b).call(this, t);
} }
hookupHTMX() { hookupHTMX() {
htmx.on("htmx:load", (r) => { htmx.on("htmx:load", (r) => {
@@ -22,27 +22,27 @@ class $ {
}); });
} }
} }
l = new WeakMap(), p = new WeakSet(), x = function(r) { a = new WeakMap(), p = new WeakSet(), b = function(r) {
if (r.getAttribute(A) === "true" || !r.hasAttribute(m)) if (r.getAttribute(A) === "true" || !r.hasAttribute(m))
return; return;
let t = "#" + r.getAttribute(m), e = c(this, l).get(t); let t = "#" + r.getAttribute(m), e = c(this, a).get(t);
if (!e) { if (!e) {
let u = htmx.find(t); let u = htmx.find(t);
if (u) { if (u) {
let b = u.innerHTML ? new DOMParser().parseFromString(u.innerHTML, "application/xml") : u.contentDocument; let S = u.innerHTML ? new DOMParser().parseFromString(u.innerHTML, "application/xml") : u.contentDocument;
e = new XSLTProcessor(), e.importStylesheet(b), c(this, l).set(t, e); e = new XSLTProcessor(), e.importStylesheet(S), c(this, a).set(t, e);
} else } else
throw new Error("Unknown XSLT template: " + t); throw new Error("Unknown XSLT template: " + t);
} }
let s = new DOMParser().parseFromString(r.innerHTML, "application/xml"), L = e.transformToFragment(s, document), S = new XMLSerializer().serializeToString(L); let s = new DOMParser().parseFromString(r.innerHTML, "application/xml"), L = e.transformToFragment(s, document), x = new XMLSerializer().serializeToString(L);
r.outerHTML = S; r.outerHTML = x;
}; };
var n, h, T; var n, h, T;
class k extends HTMLElement { class k extends HTMLElement {
constructor() { constructor() {
super(); super();
a(this, h); l(this, h);
a(this, n, !1); l(this, n, !1);
this._items = [], this._url = "", this._filterstart = !1, this._placeholder = "Liste filtern...", this.render(); this._items = [], this._url = "", this._filterstart = !1, this._placeholder = "Liste filtern...", this.render();
} }
static get observedAttributes() { static get observedAttributes() {
@@ -84,7 +84,7 @@ class k extends HTMLElement {
mark() { mark() {
if (typeof Mark != "function") if (typeof Mark != "function")
return; return;
let t = this.querySelector("#" + d); let t = this.querySelector("#" + f);
if (!t) if (!t)
return; return;
let e = new Mark(t.querySelectorAll("." + E)); let e = new Mark(t.querySelectorAll("." + E));
@@ -127,19 +127,19 @@ class k extends HTMLElement {
return e === "" ? "" : `<span class="${E}">${e}</span>`; return e === "" ? "" : `<span class="${E}">${e}</span>`;
} }
renderList() { renderList() {
let t = this.querySelector("#" + d); let t = this.querySelector("#" + f);
t && (t.outerHTML = this.List()), this.mark(); t && (t.outerHTML = this.List()), this.mark();
} }
render() { render() {
this.innerHTML = ` this.innerHTML = `
<div class="font-serif text-base"> <div class="font-serif text-base shadow-inner border border-stone-100">
${this.Input()} ${this.Input()}
${this.List()} ${this.List()}
</div> </div>
`; `;
} }
ActiveDot(t) { ActiveDot(t) {
return f(this, h, T).call(this, t), ""; return d(this, h, T).call(this, t), "";
} }
NoItems(t) { NoItems(t) {
return t.length === 0 ? '<div class="px-2 py-0.5 italic text-gray-500">Keine Einträge gefunden</div>' : ""; return t.length === 0 ? '<div class="px-2 py-0.5 italic text-gray-500">Keine Einträge gefunden</div>' : "";
@@ -147,12 +147,12 @@ class k extends HTMLElement {
Input() { Input() {
return ` return `
<div class="flex w-full py-0.5 border-b border-zinc-600 bg-stone-50"> <div class="flex w-full py-0.5 border-b border-zinc-600 bg-stone-50">
<i class="ri-arrow-right-s-line mr-1 pl-2"></i> <i class="ri-arrow-right-s-line pl-2"></i>
<div class="grow"> <div class="grow">
<input <input
type="text" type="text"
placeholder="${this._placeholder}" placeholder="${this._placeholder}"
class="${w} w-full placeholder:italic px-2 py-0.5" /> class="${I} w-full placeholder:italic px-2 py-0.5" />
</div> </div>
</div> </div>
`; `;
@@ -167,13 +167,13 @@ class k extends HTMLElement {
t = this._items.filter((s) => e.every((L) => this.getSearchText(s).toLowerCase().includes(L.toLowerCase()))); t = this._items.filter((s) => e.every((L) => this.getSearchText(s).toLowerCase().includes(L.toLowerCase())));
} }
return ` return `
<div id="${d}" class="${d} pt-1 min-h-72 max-h-60 overflow-auto border-b border-zinc-300 bg-stone-50 ${c(this, n) ? "hidden" : ""}"> <div id="${f}" class="${f} pt-1 min-h-[19rem] max-h-60 overflow-auto border-b border-zinc-300 bg-stone-50 ${c(this, n) ? "hidden" : ""}">
${t.map( ${t.map(
(e, s) => ` (e, s) => `
<a <a
href="${this._url}${this.getHREF(e)}" href="${this._url}${this.getHREF(e)}"
class="${I} block px-2.5 py-0.5 hover:bg-slate-200 no-underline ${s % 2 === 0 ? "bg-stone-100" : "bg-stone-50"}" class="${w} block px-2.5 py-0.5 hover:bg-slate-200 no-underline ${s % 2 === 0 ? "bg-stone-100" : "bg-stone-50"}"
${f(this, h, T).call(this, e) ? 'aria-current="page"' : ""}> ${d(this, h, T).call(this, e) ? 'aria-current="page"' : ""}>
${this.ActiveDot(e)} ${this.ActiveDot(e)}
${this.getLinkText(e)} ${this.getLinkText(e)}
</a> </a>

File diff suppressed because one or more lines are too long

View File

@@ -37,9 +37,10 @@
name="search" name="search"
value="{{ $model.search }}" value="{{ $model.search }}"
x-model="search" x-model="search"
placeholder="Almanach-Nr od. Suchbegriff" placeholder="Almanach-Nr oder Suchbegriff"
hx-get="" hx-get=""
hx-trigger="input changed delay:=200ms, keyup[key=='Enter']" hx-trigger="input changed delay=1000ms, keyup[key=='Enter']"
hx-sync="this:replace"
hx-select="#searchcontent" hx-select="#searchcontent"
hx-target="#searchcontent" hx-target="#searchcontent"
autocomplete="off" /> autocomplete="off" />

View File

@@ -1,26 +1,40 @@
{{ $model := index . 0 }} {{ $model := index . 0 }}
{{ $r := index . 1 }} {{ $r := index . 1 }}
{{ $bds := index $model.relations $r.Id }}
<div class="flex flex-row mb-1.5"> <div class="flex flex-row mb-1.5">
<div class="grow-0 shrink-0 w-[12rem] flex flex-col"> <div class="grow-0 shrink-0 w-[12rem] flex flex-col">
{{ if $r.References }} {{ if $r.References }}
<div class="text-sm font-sans px-2 py-1 bg-stone-100">{{ $r.References }}</div> <div class="text-sm font-sans px-2 py-1 bg-stone-100">{{ $r.References }}</div>
{{ end }} {{ end }}
{{ if $model.musenalmid }}
{{ range $_, $rel := $bds }}
<div class="font-sans text-sm px-2 py-1 bg-stone-100 searchable my-0.5">
Almanach-Nr.
{{ (index $model.entries
$rel.Entry).MusenalmID
}}
</div>
{{ end }}
{{ end }}
<div class="font-sans py-0.5 text-xs"> <div class="font-sans py-0.5 text-xs">
<a href="/reihe/?={{ $r.Id }}" class="no-underline rounded bg-stone-100 px-1.5"> <a href="/reihe/{{ $r.MusenalmID }}" class="no-underline rounded bg-stone-100 px-1.5">
<i class="ri-links-line"></i> Permalink <i class="ri-links-line"></i> Permalink
</a> </a>
</div> </div>
</div> </div>
<div class="grow-0 ml-8 -indent-3"> <div class="grow-0 ml-8 -indent-3">
<span class="font-bold">{{ $r.Title }}</span> <div class="reihen-text contents">
{{ if $r.Annotation }} <span class="font-bold">{{ $r.Title }}</span>
<span>&ensp;&middot;&ensp;</span> {{ if $r.Annotation }}
<span class="">{{ Safe $r.Annotation }}</span> <span>&ensp;&middot;&ensp;</span>
{{ end }} <span class="">{{ Safe $r.Annotation }}</span>
{{ end }}
</div>
<div></div>
<div class="ml-3"> <div class="ml-3">
{{ $bds := index $model.relations $r.Id }}
{{ if $bds }} {{ if $bds }}
{{ range $_, $rel := $bds }} {{ range $_, $rel := $bds }}
{{ $bd := index $model.entries $rel.Entry }} {{ $bd := index $model.entries $rel.Entry }}

View File

@@ -1,9 +1,10 @@
{{ $model := . }} {{ $model := . }}
<div <div
class="min-w-[32rem] max-w-[32rem] float-right ml-6 flex flex-col gap-y-8 [&>*]:py-12 class="min-w-[32rem] max-w-[32rem] float-right ml-6 flex flex-col gap-y-8 [&>*]:pb-12
[&>*]:px-12 -mr-36 [&>*]:bg-slate-100"> [&>*]:px-12 [&>*]:pt-8 -mr-36 [&>*]:bg-slate-100">
{{ if .agents }} {{ if .agents }}
<div class=""> <div class="">
<h2 class="mb-6">Personen, Verlage &amp; Druckereien</h2>
<filter-list <filter-list
id="agent-list" id="agent-list"
data-url="/reihen/?agent=" data-url="/reihen/?agent="
@@ -32,6 +33,7 @@
{{ if .places }} {{ if .places }}
<div> <div>
<h2 class="mb-6">Erscheinungsorte</h2>
<filter-list <filter-list
id="place-list" id="place-list"
data-url="/reihen/?place=" data-url="/reihen/?place="
@@ -45,11 +47,12 @@
{{ if .years }} {{ if .years }}
<div> <div>
<h2 class="mb-6">Geltungsjahre</h2>
<filter-list <filter-list
id="year-list" id="year-list"
data-url="/reihen/?year=" data-url="/reihen/?year="
data-filterstart="true" data-filterstart="true"
data-placeholder="Erscheinungsjahr filtern..."></filter-list> data-placeholder="Nach Geltungsjahren filtern..."></filter-list>
</div> </div>
<script type="module"> <script type="module">
let yearList = document.getElementById("year-list"); let yearList = document.getElementById("year-list");

View File

@@ -13,22 +13,43 @@
</div> </div>
<div id="searchcontent" class="font-serif"> <div id="searchcontent" class="font-serif">
<div class="-ml-16"> {{ if $model.search }}
{{ if or .series .altseries }} <script type="module">
<div class="mb-1 max-w-[60rem] hyphens-auto"> let elements = document.querySelectorAll('.reihen-text');
{{ range $id, $r := .series }} let mark_instance = new Mark(elements);
{{ template "_reihe" (Arr $model $r) }} // INFO: we wait a little bit before marking, to settle everything
{{ end }} setTimeout(() => {
</div> mark_instance.mark('{{ $model.search }}', {
</div> "seperateWordSearch": true,
});
}, 200);
</script>
{{ end }}
{{ if .search }} {{ if or .series .altseries }}
<div class="mt-8 max-w-96"> <div class="-ml-16">
{{ range $id, $r := .altseries }} <div class="mb-1 max-w-[60rem] hyphens-auto">
{{ template "_reihe" (Arr $model $r) }} {{ range $id, $r := .series }}
{{ template "_reihe" (Arr $model $r) }}
{{ end }} {{ end }}
</div> </div>
{{ end }}
{{ if and .search .altseries }}
{{ if .series }}
<div class="border-b text-xs font-sans text-right pb-0.5">
Treffer in Reihentiteln &uarr;
</div>
{{ end }}
<div class="border-t mb-1.5 text-xs font-sans text-right pt-0.5">
Treffer in Anmerkungen, Verweisen etc. &darr;
</div>
<div class="mb-1 max-w-[60rem] hyphens-auto">
{{ range $id, $r := .altseries }}
{{ template "_reihe" (Arr $model $r) }}
{{ end }}
</div>
{{ end }}
</div>
{{ else }} {{ else }}
<div class="mt-8"> <div class="mt-8">
Keine Reihen Keine Reihen

View File

@@ -285,7 +285,7 @@ class FilterList extends HTMLElement {
render() { render() {
this.innerHTML = ` this.innerHTML = `
<div class="font-serif text-base"> <div class="font-serif text-base shadow-inner border border-stone-100">
${this.Input()} ${this.Input()}
${this.List()} ${this.List()}
</div> </div>
@@ -309,7 +309,7 @@ class FilterList extends HTMLElement {
Input() { Input() {
return ` return `
<div class="flex w-full py-0.5 border-b border-zinc-600 bg-stone-50"> <div class="flex w-full py-0.5 border-b border-zinc-600 bg-stone-50">
<i class="ri-arrow-right-s-line mr-1 pl-2"></i> <i class="ri-arrow-right-s-line pl-2"></i>
<div class="grow"> <div class="grow">
<input <input
type="text" type="text"
@@ -338,7 +338,7 @@ class FilterList extends HTMLElement {
} }
return ` return `
<div id="${FILTER_LIST_LIST}" class="${FILTER_LIST_LIST} pt-1 min-h-72 max-h-60 overflow-auto border-b border-zinc-300 bg-stone-50 ${this.#hiddenlist ? "hidden" : ""}"> <div id="${FILTER_LIST_LIST}" class="${FILTER_LIST_LIST} pt-1 min-h-[19rem] max-h-60 overflow-auto border-b border-zinc-300 bg-stone-50 ${this.#hiddenlist ? "hidden" : ""}">
${filtereditems ${filtereditems
.map( .map(
(item, index) => ` (item, index) => `