mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-29 09:15:33 +00:00
Übernahme Suchbegriff und Typsuche
This commit is contained in:
@@ -18,12 +18,13 @@ type SuchePage struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
URL_SUCHE = "/suche/{type}"
|
URL_SUCHE = "/suche/{type}"
|
||||||
URL_SUCHE_ALT = "/suche/{$}"
|
URL_SUCHE_ALT = "/suche/{$}"
|
||||||
DEFAULT_SUCHE = "/suche/baende"
|
DEFAULT_SUCHE = "/suche/baende"
|
||||||
PARAM_EXTENDED = "extended"
|
PARAM_EXTENDED = "extended"
|
||||||
TEMPLATE_SUCHE = "/suche/"
|
TEMPLATE_SUCHE = "/suche/"
|
||||||
PARAM_QUERY = "q"
|
PARAM_QUERY = "q"
|
||||||
|
PARAM_PLACEHOLDER = "p"
|
||||||
)
|
)
|
||||||
|
|
||||||
var availableTypes = []string{"baende", "beitraege"}
|
var availableTypes = []string{"baende", "beitraege"}
|
||||||
@@ -106,9 +107,10 @@ func (p *SuchePage) SearchBaendeRequest(app core.App, engine *templating.Engine,
|
|||||||
var ErrInvalidCollectionType = fmt.Errorf("Invalid collection type")
|
var ErrInvalidCollectionType = fmt.Errorf("Invalid collection type")
|
||||||
|
|
||||||
type Parameters struct {
|
type Parameters struct {
|
||||||
Extended bool
|
Extended bool
|
||||||
Collection string
|
Collection string
|
||||||
Query string
|
Query string
|
||||||
|
Placeholder string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewParameters(e *core.RequestEvent) (*Parameters, error) {
|
func NewParameters(e *core.RequestEvent) (*Parameters, error) {
|
||||||
@@ -122,10 +124,17 @@ func NewParameters(e *core.RequestEvent) (*Parameters, error) {
|
|||||||
extended = true
|
extended = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query := e.Request.URL.Query().Get(PARAM_QUERY)
|
||||||
|
placeholder := query
|
||||||
|
if query == "" {
|
||||||
|
placeholder = e.Request.URL.Query().Get(PARAM_PLACEHOLDER)
|
||||||
|
}
|
||||||
|
|
||||||
return &Parameters{
|
return &Parameters{
|
||||||
Collection: collection,
|
Collection: collection,
|
||||||
Extended: extended,
|
Extended: extended,
|
||||||
Query: e.Request.URL.Query().Get(PARAM_QUERY),
|
Query: query,
|
||||||
|
Placeholder: placeholder,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ func (p SearchParameters) ToQueryParamsBaende() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p SearchParameters) IsBeitraegeSearch() bool {
|
func (p SearchParameters) IsBeitraegeSearch() bool {
|
||||||
return p.Collection == "beitraege" && (p.Query != "" || p.AlmString != "" || p.AnnotationsString != "" || p.PersonsString != "" || p.TitleString != "" || p.YearString != "" || p.EntryString != "" || p.IncipitString != "")
|
return p.Collection == "beitraege" && (p.Query != "" || p.TypeString != "" || p.AlmString != "" || p.AnnotationsString != "" || p.PersonsString != "" || p.TitleString != "" || p.YearString != "" || p.EntryString != "" || p.IncipitString != "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p SearchParameters) IsBaendeSearch() bool {
|
func (p SearchParameters) IsBaendeSearch() bool {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
type Parameters struct {
|
type Parameters struct {
|
||||||
Query string
|
Query string
|
||||||
Collection string
|
Collection string
|
||||||
|
Placeholder sting
|
||||||
Extended bool
|
Extended bool
|
||||||
}
|
}
|
||||||
type SearchResultBaende struct {
|
type SearchResultBaende struct {
|
||||||
|
|||||||
@@ -15,13 +15,21 @@
|
|||||||
>
|
>
|
||||||
-->
|
-->
|
||||||
<a
|
<a
|
||||||
href="/suche/baende"
|
{{ if $model.Placeholder -}}
|
||||||
|
href="/suche/baende?p={{ $model.Placeholder }}"
|
||||||
|
{{- else -}}
|
||||||
|
href="/suche/baende"
|
||||||
|
{{- end -}}
|
||||||
class="block no-underline text-xl"
|
class="block no-underline text-xl"
|
||||||
{{ if eq $model.Collection "baende" }}aria-current="page"{{- end -}}
|
{{ if eq $model.Collection "baende" }}aria-current="page"{{- end -}}
|
||||||
>Bänden</a
|
>Bänden</a
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
href="/suche/beitraege"
|
{{ if $model.Placeholder -}}
|
||||||
|
href="/suche/beitraege?p={{ $model.Placeholder }}"
|
||||||
|
{{- else -}}
|
||||||
|
href="/suche/beitraege"
|
||||||
|
{{- end -}}
|
||||||
class="block no-underline text-xl"
|
class="block no-underline text-xl"
|
||||||
{{ if eq $model.Collection "beitraege" }}aria-current="page"{{- end -}}
|
{{ if eq $model.Collection "beitraege" }}aria-current="page"{{- end -}}
|
||||||
>Beiträgen</a
|
>Beiträgen</a
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<div class="flex flex-row justify-between gap-x-3 w-full">
|
<div class="flex flex-row justify-between gap-x-3 w-full">
|
||||||
<label for="q" class="hidden">Suchbegriffe</label>
|
<label for="q" class="hidden">Suchbegriffe</label>
|
||||||
<input
|
<input
|
||||||
{{ if $q }}value="{{ $q }}"{{- end }}
|
value="{{ $parameters.Placeholder }}"
|
||||||
type="search"
|
type="search"
|
||||||
name="q"
|
name="q"
|
||||||
minlength="3"
|
minlength="3"
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
{{ $model := . }}
|
{{ $model := . }}
|
||||||
|
|
||||||
|
|
||||||
<div id="searchcontrol" class="container-normal">
|
<div
|
||||||
|
id="searchcontrol"
|
||||||
|
class="container-normal"
|
||||||
|
x-data="{ placeholder: '{{ $model.parameters.Placeholder }}'">
|
||||||
<div id="searchheading" class="flex flex-row justify-between min-h-14 items-end relative">
|
<div id="searchheading" class="flex flex-row justify-between min-h-14 items-end relative">
|
||||||
<nav id="searchnav" class="flex flex-row items-end">
|
<nav id="searchnav" class="flex flex-row items-end">
|
||||||
<div
|
<div
|
||||||
@@ -18,13 +21,13 @@
|
|||||||
>
|
>
|
||||||
-->
|
-->
|
||||||
<a
|
<a
|
||||||
href="/suche/baende"
|
:href="'/suche/baende/?p='+placeholder"
|
||||||
class="block no-underline"
|
class="block no-underline"
|
||||||
{{ if eq $model.type "baende" }}aria-current="page"{{- end -}}
|
{{ if eq $model.type "baende" }}aria-current="page"{{- end -}}
|
||||||
>Bänden</a
|
>Bänden</a
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
href="/suche/beitraege"
|
:href="'/suche/beitraege/?p='+placeholder"
|
||||||
class="block no-underline"
|
class="block no-underline"
|
||||||
{{ if eq $model.type "beitraege" }}aria-current="page"{{- end -}}
|
{{ if eq $model.type "beitraege" }}aria-current="page"{{- end -}}
|
||||||
>Beiträgen</a
|
>Beiträgen</a
|
||||||
|
|||||||
Reference in New Issue
Block a user