Personen Verbesserungen

This commit is contained in:
Simon Martens
2025-02-25 12:16:39 +01:00
parent 24f1e4fd55
commit f35c738cee
13 changed files with 81 additions and 23 deletions

View File

@@ -165,7 +165,7 @@ func LettersForAgents(app core.App, filter string) ([]string, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
} else if filter == "autor" { } else if filter == "text" {
err := app.RecordQuery(AGENTS_TABLE). err := app.RecordQuery(AGENTS_TABLE).
Select("upper(substr(" + AGENTS_NAME_FIELD + ", 1, 1)) AS id"). Select("upper(substr(" + AGENTS_NAME_FIELD + ", 1, 1)) AS id").
Distinct(true). Distinct(true).

View File

@@ -3,6 +3,9 @@ package functions
import ( import (
"html/template" "html/template"
"strings" "strings"
"golang.org/x/text/cases"
"golang.org/x/text/language"
) )
func Safe(s string) template.HTML { func Safe(s string) template.HTML {
@@ -15,3 +18,20 @@ func Safe(s string) template.HTML {
func ReplaceSlashParen(s string) string { func ReplaceSlashParen(s string) string {
return strings.ReplaceAll(s, "/)", "<p>") return strings.ReplaceAll(s, "/)", "<p>")
} }
func Lower(s string) string {
return cases.Lower(language.German).String(s)
}
func Upper(s string) string {
return cases.Upper(language.German).String(s)
}
func First(s string) string {
r := []rune(s)
if len(r) == 0 {
return ""
}
return string(r[0])
}

View File

@@ -71,7 +71,7 @@ func (p *PersonenPage) FilterRequest(app core.App, engine *templating.Engine, e
agents, err = dbmodels.AgentsForProfession(app, "Musik", letter) agents, err = dbmodels.AgentsForProfession(app, "Musik", letter)
} }
if filter == "autor" { if filter == "text" {
agents, err = dbmodels.AgentsForProfession(app, "Text", letter) agents, err = dbmodels.AgentsForProfession(app, "Text", letter)
} }

View File

@@ -61,6 +61,9 @@ func (e *Engine) funcs() error {
e.AddFunc("Len", functions.Length) e.AddFunc("Len", functions.Length)
// String Functions // String Functions
e.AddFunc("Lower", functions.Lower)
e.AddFunc("Upper", functions.Upper)
e.AddFunc("First", functions.First)
e.AddFunc("ReplaceSlashParen", functions.ReplaceSlashParen) e.AddFunc("ReplaceSlashParen", functions.ReplaceSlashParen)
// Time & Date Functions // Time & Date Functions

File diff suppressed because one or more lines are too long

View File

@@ -50,6 +50,22 @@
<scroll-button></scroll-button> <scroll-button></scroll-button>
{{ block "scripts" . }}
<!-- Default scripts... -->
{{ end }}
<script type="module">
const hash = window.location.hash;
if (hash) {
const stripped = hash.slice(1);
const element = document.getElementById(stripped);
if (element) {
element.setAttribute("aria-current", "location");
}
}
</script>
</div> </div>
</body> </body>
</html> </html>

View File

@@ -43,6 +43,12 @@
</div> </div>
{{ end }} {{ end }}
<h1 class="text-3xl font-bold">{{ $model.result.Agent.Name }}</h1> <h1 class="text-3xl font-bold">{{ $model.result.Agent.Name }}</h1>
{{- if $model.result.Agent.Pseudonyms -}}
<p class="italic">
auch:
<span class="">{{ $model.result.Agent.Pseudonyms }}</span>
</p>
{{- end -}}
<div> <div>
<span class=""> <span class="">
{{ $model.result.Agent.BiographicalData }} {{ $model.result.Agent.BiographicalData }}
@@ -51,10 +57,12 @@
{{- $arr := $model.result.Agent.ProfessionArray -}} {{- $arr := $model.result.Agent.ProfessionArray -}}
{{- if $arr -}} {{- if $arr -}}
{{- range $i, $p := $arr -}} {{- range $i, $p := $arr -}}
<div <a
class="inline-block align-middle bg-slate-200 px-2 font-sans text-sm py-0.5 rounded mx-1"> href="/personen/?letter={{- Upper (First $model.result.Agent.Name) -}}&filter={{ Lower $p }}#{{- $model.result.Agent.Id -}}"
class="inline-block align-middle bg-slate-200 px-2 font-sans text-sm py-0.5 rounded mx-1
hover:text-slate-900 no-underline">
{{- $p -}} {{- $p -}}
</div> </a>
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
</span> </span>

View File

@@ -17,7 +17,7 @@
<div id="personheader" class="border-t border-r border-zinc-300 relative w-full"> <div id="personheader" class="border-t border-r border-zinc-300 relative w-full">
{{ template "heading" . }} {{ template "heading" . }}
<div class="flex flex-row justify-end mt-12 items-end"> <div class="flex flex-row justify-end mt-12 items-end">
{{ template "notifier" . }} {{ template "notifier" . }}
{{ template "professionselectbox" . }} {{ template "professionselectbox" . }}
{{ template "searchbox" . }} {{ template "searchbox" . }}
</div> </div>
@@ -29,8 +29,10 @@
{{ if .agents }} {{ if .agents }}
<div class="w-full flex flex-col"> <div class="w-full flex flex-col">
{{ range $count, $agent := .agents }} {{ range $count, $agent := .agents }}
<div class="flex flex-row odd:bg-stone-100 even:bg-stone-50 px-3 py-0.5"> <div
<div class="grow"> class="flex flex-row odd:bg-stone-100 even:bg-stone-50 px-3 py-0.5"
id="personlist">
<div class="grow" id="{{- $agent.Id -}}">
<a href="/person/{{ $agent.Id }}" class="search-result font-bold"> <a href="/person/{{ $agent.Id }}" class="search-result font-bold">
{{ $agent.Name }} {{ $agent.Name }}
</a> </a>
@@ -61,11 +63,12 @@
{{- $parr := $agent.ProfessionArray -}} {{- $parr := $agent.ProfessionArray -}}
{{- if $parr -}} {{- if $parr -}}
{{- range $i, $p := $parr -}} {{- range $i, $p := $parr -}}
<div <a
class="inline-block px-2 py-0.5 text-sm font-sans href="/personen/?letter={{- Upper (First $agent.Name) -}}&filter={{ Lower $p }}"
bg-slate-200 rounded ml-2"> class="inline-block px-2 py-0.5 text-sm font-sans no-underline
hover:text-slate-950 bg-slate-200 rounded ml-2">
{{ $p }} {{ $p }}
</div> </a>
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
@@ -79,8 +82,6 @@
</div> </div>
{{ end }} {{ end }}
{{ if .altagents }}
{{ end }}
{{ else }} {{ else }}
<p>Keine Personen gefunden.</p> <p>Keine Personen gefunden.</p>
{{ end }} {{ end }}

View File

@@ -1,6 +1,8 @@
{{ $model := . }} {{ $model := . }}
{{ $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")) }} {{ $isPerson := and $model.filter (or (eq $model.filter "noorg") (eq $model.filter "musik") (eq
$model.filter "text") (eq $model.filter "graphik") (eq $model.filter "hrsg"))
}}
{{ $isNoOrg := and $model.filter (eq $model.filter "noorg") }} {{ $isNoOrg := and $model.filter (eq $model.filter "noorg") }}

View File

@@ -1,6 +1,8 @@
{{ $model := . }} {{ $model := . }}
{{ $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")) }} {{ $isPerson := and $model.filter (or (eq $model.filter "noorg") (eq $model.filter "musik") (eq
$model.filter "text") (eq $model.filter "graphik") (eq $model.filter "hrsg"))
}}
{{ $isOrg := and $model.filter (eq $model.filter "org") }} {{ $isOrg := and $model.filter (eq $model.filter "org") }}

View File

@@ -1,8 +1,8 @@
{{ $model := . }} {{ $model := . }}
{{ $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")) }} {{ $isPerson := and $model.filter (or (eq $model.filter "noorg") (eq $model.filter "musik") (eq $model.filter "text") (eq $model.filter "graphik") (eq $model.filter "hrsg")) }}
{{ $isProfession := and $model.filter (or (eq $model.filter "musik") (eq $model.filter "autor") (eq $model.filter "graphik") (eq $model.filter "hrsg")) }} {{ $isProfession := and $model.filter (or (eq $model.filter "musik") (eq $model.filter "text") (eq $model.filter "graphik") (eq $model.filter "hrsg")) }}
{{ $isNoOrg := and $model.filter (eq $model.filter "noorg") }} {{ $isNoOrg := and $model.filter (eq $model.filter "noorg") }}
@@ -10,7 +10,7 @@
{{ $isMusik := and $model.filter (eq $model.filter "musik") }} {{ $isMusik := and $model.filter (eq $model.filter "musik") }}
{{ $isAutor := and $model.filter (eq $model.filter "autor") }} {{ $isAutor := and $model.filter (eq $model.filter "text") }}
{{ $isGraphik := and $model.filter (eq $model.filter "graphik") }} {{ $isGraphik := and $model.filter (eq $model.filter "graphik") }}

View File

@@ -1,6 +1,8 @@
{{ $model := . }} {{ $model := . }}
{{ $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")) }} {{ $isPerson := and $model.filter (or (eq $model.filter "noorg") (eq $model.filter "musik") (eq
$model.filter "text") (eq $model.filter "graphik") (eq $model.filter "hrsg"))
}}
{{ $isNoOrg := and $model.filter (eq $model.filter "noorg") }} {{ $isNoOrg := and $model.filter (eq $model.filter "noorg") }}
@@ -8,7 +10,7 @@
{{ $isMusik := and $model.filter (eq $model.filter "musik") }} {{ $isMusik := and $model.filter (eq $model.filter "musik") }}
{{ $isAutor := and $model.filter (eq $model.filter "autor") }} {{ $isAutor := and $model.filter (eq $model.filter "text") }}
{{ $isGraphik := and $model.filter (eq $model.filter "graphik") }} {{ $isGraphik := and $model.filter (eq $model.filter "graphik") }}
@@ -32,7 +34,7 @@
hx-target="main"> hx-target="main">
<option value="noorg" {{ if $isNoOrg }}selected{{ end }}>Alle</option> <option value="noorg" {{ if $isNoOrg }}selected{{ end }}>Alle</option>
<option value="musik" {{ if $isMusik }}selected{{ end }}>Musiker:innen</option> <option value="musik" {{ if $isMusik }}selected{{ end }}>Musiker:innen</option>
<option value="autor" {{ if $isAutor }}selected{{ end }}>Autor:innen</option> <option value="text" {{ if $isAutor }}selected{{ end }}>Autor:innen</option>
<option value="graphik" {{ if $isGraphik }}selected{{ end }}>Graphiker:innen</option> <option value="graphik" {{ if $isGraphik }}selected{{ end }}>Graphiker:innen</option>
<option value="hrsg" {{ if $isHrsg }}selected{{ end }}>Herausgeber:innen</option> <option value="hrsg" {{ if $isHrsg }}selected{{ end }}>Herausgeber:innen</option>
</select> </select>

View File

@@ -340,6 +340,10 @@
@apply text-gray-400; @apply text-gray-400;
} }
#personlist [aria-current="location"] a {
@apply !text-red-700;
}
#entrydata .fieldlabel { #entrydata .fieldlabel {
@apply font-bold text-base font-sans whitespace-nowrap min-w-48 grow-0 shrink-0 pt-0.5; @apply font-bold text-base font-sans whitespace-nowrap min-w-48 grow-0 shrink-0 pt-0.5;
} }