From 96153381fb08de5b940ebbeb525eda14d5ad959a Mon Sep 17 00:00:00 2001 From: Simon Martens Date: Thu, 13 Mar 2025 13:45:48 +0100 Subject: [PATCH] =?UTF-8?q?=C3=9Cbernahme=20Suchbegriff=20und=20Typsuche?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/suche.go | 33 ++++++++++++------- pages/suche_parameters.go | 2 +- views/routes/suche/baende/body.gohtml | 1 + views/routes/suche/components/_heading.gohtml | 12 +++++-- .../suche/components/_searchboxsimple.gohtml | 2 +- views/routes/suche/reihen/body.gohtml | 9 +++-- 6 files changed, 40 insertions(+), 19 deletions(-) diff --git a/pages/suche.go b/pages/suche.go index b6a9382..3d7395a 100644 --- a/pages/suche.go +++ b/pages/suche.go @@ -18,12 +18,13 @@ type SuchePage struct { } const ( - URL_SUCHE = "/suche/{type}" - URL_SUCHE_ALT = "/suche/{$}" - DEFAULT_SUCHE = "/suche/baende" - PARAM_EXTENDED = "extended" - TEMPLATE_SUCHE = "/suche/" - PARAM_QUERY = "q" + URL_SUCHE = "/suche/{type}" + URL_SUCHE_ALT = "/suche/{$}" + DEFAULT_SUCHE = "/suche/baende" + PARAM_EXTENDED = "extended" + TEMPLATE_SUCHE = "/suche/" + PARAM_QUERY = "q" + PARAM_PLACEHOLDER = "p" ) 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") type Parameters struct { - Extended bool - Collection string - Query string + Extended bool + Collection string + Query string + Placeholder string } func NewParameters(e *core.RequestEvent) (*Parameters, error) { @@ -122,10 +124,17 @@ func NewParameters(e *core.RequestEvent) (*Parameters, error) { extended = true } + query := e.Request.URL.Query().Get(PARAM_QUERY) + placeholder := query + if query == "" { + placeholder = e.Request.URL.Query().Get(PARAM_PLACEHOLDER) + } + return &Parameters{ - Collection: collection, - Extended: extended, - Query: e.Request.URL.Query().Get(PARAM_QUERY), + Collection: collection, + Extended: extended, + Query: query, + Placeholder: placeholder, }, nil } diff --git a/pages/suche_parameters.go b/pages/suche_parameters.go index 9a207ba..d5af3e9 100644 --- a/pages/suche_parameters.go +++ b/pages/suche_parameters.go @@ -303,7 +303,7 @@ func (p SearchParameters) ToQueryParamsBaende() string { } 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 { diff --git a/views/routes/suche/baende/body.gohtml b/views/routes/suche/baende/body.gohtml index 33a9e71..a952adc 100644 --- a/views/routes/suche/baende/body.gohtml +++ b/views/routes/suche/baende/body.gohtml @@ -26,6 +26,7 @@ type Parameters struct { Query string Collection string + Placeholder sting Extended bool } type SearchResultBaende struct { diff --git a/views/routes/suche/components/_heading.gohtml b/views/routes/suche/components/_heading.gohtml index b1fe88a..2f7dcbe 100644 --- a/views/routes/suche/components/_heading.gohtml +++ b/views/routes/suche/components/_heading.gohtml @@ -15,13 +15,21 @@ > --> Bänden Beiträgen +