mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-29 09:15:33 +00:00
personen anfang
This commit is contained in:
@@ -103,16 +103,64 @@ func AgentsForContents(app core.App, contents []*Content) (map[string]*Agent, Ag
|
||||
return agentsMap, relationMap, nil
|
||||
}
|
||||
|
||||
func LettersForAgents(app core.App) ([]string, error) {
|
||||
func LettersForAgents(app core.App, filter string) ([]string, error) {
|
||||
letters := []core.Record{}
|
||||
ids := []string{}
|
||||
|
||||
err := app.RecordQuery(AGENTS_TABLE).
|
||||
Select("upper(substr(" + AGENTS_NAME_FIELD + ", 1, 1)) AS id").
|
||||
Distinct(true).
|
||||
All(&letters)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if filter == "" || filter == "noorg" {
|
||||
err := app.RecordQuery(AGENTS_TABLE).
|
||||
Select("upper(substr(" + AGENTS_NAME_FIELD + ", 1, 1)) AS id").
|
||||
Distinct(true).
|
||||
Where(dbx.HashExp{AGENTS_CORP_FIELD: false}).
|
||||
All(&letters)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else if filter == "org" {
|
||||
err := app.RecordQuery(AGENTS_TABLE).
|
||||
Select("upper(substr(" + AGENTS_NAME_FIELD + ", 1, 1)) AS id").
|
||||
Distinct(true).
|
||||
Where(dbx.HashExp{AGENTS_CORP_FIELD: true}).
|
||||
All(&letters)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else if filter == "musik" {
|
||||
err := app.RecordQuery(AGENTS_TABLE).
|
||||
Select("upper(substr(" + AGENTS_NAME_FIELD + ", 1, 1)) AS id").
|
||||
Distinct(true).
|
||||
Where(dbx.Like(AGENTS_PROFESSION_FIELD, "Musik").Match(true, true)).
|
||||
All(&letters)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else if filter == "autor" {
|
||||
err := app.RecordQuery(AGENTS_TABLE).
|
||||
Select("upper(substr(" + AGENTS_NAME_FIELD + ", 1, 1)) AS id").
|
||||
Distinct(true).
|
||||
Where(dbx.Like(AGENTS_PROFESSION_FIELD, "Text").Match(true, true)).
|
||||
All(&letters)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else if filter == "graphik" {
|
||||
err := app.RecordQuery(AGENTS_TABLE).
|
||||
Select("upper(substr(" + AGENTS_NAME_FIELD + ", 1, 1)) AS id").
|
||||
Distinct(true).
|
||||
Where(dbx.Like(AGENTS_PROFESSION_FIELD, "Graphik").Match(true, true)).
|
||||
All(&letters)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else if filter == "hrsg" {
|
||||
err := app.RecordQuery(AGENTS_TABLE).
|
||||
Select("upper(substr(" + AGENTS_NAME_FIELD + ", 1, 1)) AS id").
|
||||
Distinct(true).
|
||||
Where(dbx.Like(AGENTS_PROFESSION_FIELD, "Hrsg").Match(true, true)).
|
||||
All(&letters)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
for _, l := range letters {
|
||||
|
||||
@@ -32,22 +32,14 @@ func (p *PersonenPage) Setup(router *router.Router[*core.RequestEvent], app core
|
||||
if e.Request.URL.Query().Get(PARAM_SEARCH) != "" {
|
||||
return p.SearchRequest(app, engine, e)
|
||||
}
|
||||
if e.Request.URL.Query().Get(PARAM_FILTER) != "" {
|
||||
return p.FilterRequest(app, engine, e)
|
||||
}
|
||||
|
||||
return p.LetterRequest(app, engine, e)
|
||||
return p.FilterRequest(app, engine, e)
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *PersonenPage) CommonData(app core.App, data map[string]interface{}) error {
|
||||
letters, err := dbmodels.LettersForAgents(app)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data["letters"] = letters
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -58,6 +50,11 @@ func (p *PersonenPage) FilterRequest(app core.App, engine *templating.Engine, e
|
||||
if letter == "" {
|
||||
letter = "A"
|
||||
}
|
||||
|
||||
if filter == "" {
|
||||
filter = "noorg"
|
||||
}
|
||||
|
||||
data := map[string]interface{}{}
|
||||
|
||||
var err error = nil
|
||||
@@ -94,6 +91,13 @@ func (p *PersonenPage) FilterRequest(app core.App, engine *templating.Engine, e
|
||||
data["filter"] = filter
|
||||
data["letter"] = letter
|
||||
|
||||
letters, err := dbmodels.LettersForAgents(app, filter)
|
||||
if err != nil {
|
||||
return engine.Response404(e, err, data)
|
||||
}
|
||||
|
||||
data["letters"] = letters
|
||||
|
||||
return p.Get(e, engine, data)
|
||||
}
|
||||
|
||||
@@ -116,24 +120,6 @@ func (p *PersonenPage) SearchRequest(app core.App, engine *templating.Engine, e
|
||||
return p.Get(e, engine, data)
|
||||
}
|
||||
|
||||
func (p *PersonenPage) LetterRequest(app core.App, engine *templating.Engine, e *core.RequestEvent) error {
|
||||
letter := e.Request.URL.Query().Get(PARAM_LETTER)
|
||||
if letter == "" {
|
||||
letter = "A"
|
||||
}
|
||||
data := map[string]interface{}{}
|
||||
data["letter"] = letter
|
||||
|
||||
agents, err := dbmodels.AgentsForLetter(app, letter)
|
||||
if err != nil {
|
||||
return engine.Response404(e, err, data)
|
||||
}
|
||||
dbmodels.SortAgentsByName(agents)
|
||||
data["agents"] = agents
|
||||
|
||||
return p.Get(e, engine, data)
|
||||
}
|
||||
|
||||
func (p *PersonenPage) Get(request *core.RequestEvent, engine *templating.Engine, data map[string]interface{}) error {
|
||||
err := p.CommonData(request.App, data)
|
||||
if err != nil {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,88 +1,203 @@
|
||||
{{ $model := . }}
|
||||
|
||||
{{ template "_alphabet" Dict "active" .letter "letters" .letters }}
|
||||
{{ $isPerson := and $model.filter (or (eq $model.filter "noorg") (eq $model.filter "musik") (eq $model.filter "autor") (eq $model.filter "graphik") (eq $model.filter "hrsg")) }}
|
||||
|
||||
{{ $isNoOrg := and $model.filter (eq $model.filter "noorg") }}
|
||||
|
||||
{{ $isOrg := and $model.filter (eq $model.filter "org") }}
|
||||
|
||||
{{ $isMusik := and $model.filter (eq $model.filter "musik") }}
|
||||
|
||||
{{ $isAutor := and $model.filter (eq $model.filter "autor") }}
|
||||
|
||||
{{ $isGraphik := and $model.filter (eq $model.filter "graphik") }}
|
||||
|
||||
{{ $isHrsg := and $model.filter (eq $model.filter "hrsg") }}
|
||||
|
||||
|
||||
<input
|
||||
class="form-control"
|
||||
type="search"
|
||||
name="search"
|
||||
placeholder="Suche"
|
||||
hx-get="/personen"
|
||||
hx-trigger="input changed delay:200ms, keyup[key=='Enter']"
|
||||
hx-select="#agents"
|
||||
hx-target="#agents" />
|
||||
<div class="container-normal mt-4" x-data="{ search : '{{ $model.search }}'}">
|
||||
{{- if not $model.search -}}
|
||||
<div
|
||||
id="persontype"
|
||||
class="flex flex-row justify-end align-right text-right mr-4 gap-x-3"
|
||||
:class="search ? 'inactive' : ''">
|
||||
<a
|
||||
href="/personen{{ if .letter }}?letter={{ .letter }}{{ end }}"
|
||||
{{ if $isPerson -}}aria-current="page"{{- end -}}
|
||||
>Personen</a
|
||||
>
|
||||
|
||||
<div>
|
||||
<a href="/personen{{ if .letter }}?letter={{ .letter }}{{ end }}">Alle</a>
|
||||
<a href="/personen?filter=org{{ if .letter }}&letter={{ .letter }}{{ end }}"
|
||||
>Verlage u. Druckereien</a
|
||||
>
|
||||
<a href="/personen?filter=noorg{{ if .letter }}&letter={{ .letter }}{{ end }}">Personen</a>
|
||||
<a href="/personen?filter=musik{{ if .letter }}&letter={{ .letter }}{{ end }}">Musiker:innen</a>
|
||||
<a href="/personen?filter=autor{{ if .letter }}&letter={{ .letter }}{{ end }}">Autor:innen</a>
|
||||
<a href="/personen?filter=graphik{{ if .letter }}&letter={{ .letter }}{{ end }}"
|
||||
>Graphiker:innen</a
|
||||
>
|
||||
<a href="/personen?filter=hrsg{{ if .letter }}&letter={{ .letter }}{{ end }}"
|
||||
>Herausgeber:innen</a
|
||||
>
|
||||
</div>
|
||||
<a
|
||||
href="/personen?filter=org{{ if .letter }}&letter={{ .letter }}{{ end }}"
|
||||
{{ if $isOrg -}}aria-current="page"{{- end -}}
|
||||
>Verlage, Druckereien & Vertriebe</a
|
||||
>
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
||||
<div id="agents">
|
||||
{{ if or .agents .altagents }}
|
||||
{{ if .agents }}
|
||||
<table class="w-full [&_td]:!align-top">
|
||||
{{ range $count, $agent := .agents }}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/person/{{ $agent.Id }}">
|
||||
{{ $agent.Name }}
|
||||
{{ if $agent.Pseudonyms }}
|
||||
<br />
|
||||
({{ $agent.Pseudonyms }})
|
||||
|
||||
<div class="flex flex-row">
|
||||
{{- if and $model.letters (not $model.search) -}}
|
||||
<div id="personalphabet" class="flex flex-col text-xl pt-8 relative">
|
||||
{{- range $id, $r := .letters -}}
|
||||
<a
|
||||
class="odd:bg-stone-100 even:bg-zinc-100 mb-1 border-zinc-300 border-y border-l [&>a[aria-current='page']]:font-bold
|
||||
px-2 no-underline transition-all duration-75
|
||||
{{ if not $model.letter -}}inactive{{- end -}}"
|
||||
:class="search ? 'inactive' : 'active'"
|
||||
href="?letter={{ $r }}{{- if $model.filter }}&filter={{ $model.filter }}{{- end -}}"
|
||||
{{ if eq $model.letter $r }}aria-current="page"{{ end }}
|
||||
hx-select="main"
|
||||
hx-target="main"
|
||||
hx-swap="outerHTML scroll:#pageheading:top"
|
||||
>{{ $r }}</a
|
||||
>
|
||||
{{- end -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
||||
|
||||
<div class="w-full">
|
||||
<div id="personheader" class="border-t border-r border-zinc-300 relative w-full">
|
||||
<h1
|
||||
class="text-3xl font-bold px-3 relative -translate-y-[55%] w-min whitespace-nowrap bg-stone-50 ml-24 z-20">
|
||||
<span x-show="!search">
|
||||
{{- if $isPerson -}}
|
||||
Personen
|
||||
{{- else if $isOrg -}}
|
||||
Verlage, Druckereien & Vertriebe
|
||||
{{- end -}}
|
||||
</span>
|
||||
<span x-show="search"> Suche · Alle Personen & Körperschaften </span>
|
||||
</h1>
|
||||
|
||||
<div class="flex flex-row justify-between">
|
||||
<div class="w-[60%] shrink-0 grow-0">
|
||||
<div class="min-w-[22.5rem] max-w-96 flex flex-row relative mt-9 ml-auto">
|
||||
<div class="">
|
||||
<i class="ri-search-line"></i
|
||||
><i class="-ml-0.5 inline-block ri-arrow-right-s-line"></i>
|
||||
</div>
|
||||
<div class="pb-0 border-b-4 border-zinc-300 grow">
|
||||
<input
|
||||
class="px-1.5 font-serif placeholder:italic w-full"
|
||||
type="search"
|
||||
name="search"
|
||||
value="{{ $model.search }}"
|
||||
placeholder="Suchbegriff"
|
||||
x-model="search"
|
||||
hx-get=""
|
||||
hx-trigger="input changed delay=500ms, keyup[key=='Enter']"
|
||||
hx-sync="this:replace"
|
||||
hx-select="#searchresults"
|
||||
hx-target="#searchresults"
|
||||
autocomplete="off"
|
||||
{{ if $model.active }}autofocus="true"{{ end }}
|
||||
{{ if $model.search }}disabled="true"{{ end }} />
|
||||
</div>
|
||||
<div id="permalink" class="font-serif ml-3 min-w-7 pb-1">
|
||||
<tool-tip position="right" x-show="search">
|
||||
<a
|
||||
:href="'/personen/?search=' + search"
|
||||
x-show="search"
|
||||
class="inline-block px-1
|
||||
text-white no-underline bg-stone-700 hover:bg-stone-900 rounded"
|
||||
hx-boost="false">
|
||||
<i class="ri-links-line"></i
|
||||
></a>
|
||||
<div class="data-tip">Link zu dieser Suchanfrage</div>
|
||||
</tool-tip>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{- if $isPerson -}}
|
||||
<div x-show="!search" class="flex flex-row gap-x-3 font-serif mr-6 items-end">
|
||||
<label
|
||||
for="filter"
|
||||
class="align-bottom h-min self-end pb-1 text-sm font-sans text-stone-700"
|
||||
>Anzeige:</label
|
||||
>
|
||||
<select
|
||||
class="h-min pb-1 border-b-4 border-zinc-300 px-1.5"
|
||||
name="filter"
|
||||
id="filter"
|
||||
hx-get="/personen{{- if .letter -}}?letter={{ .letter }}{{- end -}}"
|
||||
trigger="change"
|
||||
hx-push-url="true"
|
||||
hx-select="main"
|
||||
hx-target="main">
|
||||
<option value="noorg" {{ if $isNoOrg }}selected{{ end }}>Alle Personen</option>
|
||||
<option value="musik" {{ if $isMusik }}selected{{ end }}>Musiker:innen</option>
|
||||
<option value="autor" {{ if $isAutor }}selected{{ end }}>Autor:innen</option>
|
||||
<option value="graphik" {{ if $isGraphik }}selected{{ end }}>
|
||||
Graphiker:innen
|
||||
</option>
|
||||
<option value="hrsg" {{ if $isHrsg }}selected{{ end }}>Herausgeber:innen</option>
|
||||
</select>
|
||||
</div>
|
||||
{{- end -}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 ml-4 font-serif font-lg" id="searchresults">
|
||||
{{ if or .agents .altagents }}
|
||||
{{ if .agents }}
|
||||
<table class="w-full [&_td]:!align-top">
|
||||
{{ range $count, $agent := .agents }}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/person/{{ $agent.Id }}" class="font-bold">
|
||||
{{ $agent.Name }}
|
||||
{{ if $agent.Pseudonyms }}
|
||||
<br />
|
||||
({{ $agent.Pseudonyms }})
|
||||
{{ end }}
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ if $agent.CorporateBody }}
|
||||
Körperschaft
|
||||
{{ else }}
|
||||
{{ $agent.Profession }},
|
||||
{{ $agent.BiographicalData }}
|
||||
{{ end }}
|
||||
</td>
|
||||
<td>{{ $agent.References }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ if $agent.CorporateBody }}
|
||||
Körperschaft
|
||||
{{ else }}
|
||||
{{ $agent.Profession }},
|
||||
{{ $agent.BiographicalData }}
|
||||
{{ end }}
|
||||
</td>
|
||||
<td>{{ $agent.References }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
|
||||
</table>
|
||||
{{ end }}
|
||||
{{ if .altagents }}
|
||||
<table class="w-full mt-6">
|
||||
{{ range $count, $agent := .altagents }}
|
||||
<tr>
|
||||
<td>
|
||||
{{ $agent.Name }}
|
||||
{{ if $agent.Pseudonyms }}
|
||||
<br />
|
||||
({{ $agent.Pseudonyms }})
|
||||
{{ end }}
|
||||
</td>
|
||||
<td>
|
||||
{{ if $agent.CorporateBody }}
|
||||
Körperschaft
|
||||
{{ else }}
|
||||
{{ $agent.Profession }},
|
||||
{{ $agent.BiographicalData }}
|
||||
{{ end }}
|
||||
</td>
|
||||
<td>{{ $agent.References }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
</table>
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
<p>Keine Personen gefunden.</p>
|
||||
{{ end }}
|
||||
</table>
|
||||
{{ end }}
|
||||
{{ if .altagents }}
|
||||
<table class="w-full mt-6">
|
||||
{{ range $count, $agent := .altagents }}
|
||||
<tr>
|
||||
<td>
|
||||
{{ $agent.Name }}
|
||||
{{ if $agent.Pseudonyms }}
|
||||
<br />
|
||||
({{ $agent.Pseudonyms }})
|
||||
{{ end }}
|
||||
</td>
|
||||
<td>
|
||||
{{ if $agent.CorporateBody }}
|
||||
Körperschaft
|
||||
{{ else }}
|
||||
{{ $agent.Profession }},
|
||||
{{ $agent.BiographicalData }}
|
||||
{{ end }}
|
||||
</td>
|
||||
<td>{{ $agent.References }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
</table>
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
<p>Keine Personen gefunden.</p>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
<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>
|
||||
<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"
|
||||
@@ -15,13 +19,13 @@
|
||||
href="/suche/baende"
|
||||
class="block no-underline"
|
||||
{{ if eq $model.type "baende" }}aria-current="page"{{- end -}}
|
||||
>Bände</a
|
||||
>Bänden</a
|
||||
>
|
||||
<a
|
||||
href="/suche/beitraege"
|
||||
class="block no-underline"
|
||||
{{ if eq $model.type "beitraege" }}aria-current="page"{{- end -}}
|
||||
>Beiträge</a
|
||||
>Beiträgen</a
|
||||
>
|
||||
<a
|
||||
href="/suche/personen"
|
||||
|
||||
@@ -34,16 +34,6 @@
|
||||
{{- 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"
|
||||
@@ -54,6 +44,16 @@
|
||||
{{- end -}} />
|
||||
<label for="references">Nachweise</label>
|
||||
</div>
|
||||
<div class="selectgroup-option">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="annotations"
|
||||
id="annotations"
|
||||
{{ if $includeAnnotations -}}
|
||||
checked
|
||||
{{- end -}} />
|
||||
<label for="annotations">Anmerkungen</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
{{ template "infotextsimple" false }}
|
||||
</div>
|
||||
@@ -79,14 +79,14 @@
|
||||
<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>
|
||||
<div class="selectgroup-option">
|
||||
<input type="checkbox" name="annotations" id="annotations" checked />
|
||||
<label for="annotations">Anmerkungen</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
{{ template "infotextsimple" false }}
|
||||
</div>
|
||||
|
||||
@@ -199,7 +199,7 @@
|
||||
}
|
||||
|
||||
#searchnav > a:nth-of-type(1) {
|
||||
@apply ml-12;
|
||||
@apply ml-6;
|
||||
}
|
||||
|
||||
#searchnav > a {
|
||||
@@ -251,4 +251,26 @@
|
||||
#searchform .selectgroup .selectgroup-option label {
|
||||
@apply whitespace-nowrap;
|
||||
}
|
||||
|
||||
#searchform .selectgroup input:not(:checked) + label {
|
||||
@apply decoration-slate-900 line-through;
|
||||
}
|
||||
|
||||
#persontype a {
|
||||
@apply px-1.5 border-b-[5px] border-zinc-300 no-underline font-serif mx-2.5;
|
||||
}
|
||||
|
||||
#persontype a[aria-current="page"]:not(#persontype.inactive a) {
|
||||
@apply font-bold;
|
||||
}
|
||||
|
||||
#personheader:before {
|
||||
content: "";
|
||||
@apply bg-zinc-300 w-[50%] absolute bottom-0 left-[50%] h-[1px];
|
||||
}
|
||||
|
||||
#personalphabet:after {
|
||||
content: "";
|
||||
@apply absolute right-0 top-0 h-[44em] border-r border-zinc-300;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user