mirror of
https://github.com/Theodor-Springmann-Stiftung/kgpz_web.git
synced 2025-10-28 08:35:30 +00:00
Suche (cont.)
This commit is contained in:
@@ -76,6 +76,28 @@ func HRDateShort(date string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func HRDateYear(date string) string {
|
||||
xsdt, err := xsdtime.New(date)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
t := xsdt.Type()
|
||||
if t == xsdtime.GYear {
|
||||
return strconv.Itoa(xsdt.Year)
|
||||
}
|
||||
|
||||
if t == xsdtime.GYearMonth {
|
||||
return strconv.Itoa(xsdt.Year)
|
||||
}
|
||||
|
||||
if t == xsdtime.Date {
|
||||
return strconv.Itoa(xsdt.Year)
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func MonthName(i int) Month {
|
||||
if i > 12 || i < 1 {
|
||||
return TRANSLM[0]
|
||||
|
||||
@@ -49,6 +49,7 @@ func (e *Engine) funcs() error {
|
||||
e.AddFunc("MonthName", functions.MonthName)
|
||||
e.AddFunc("WeekdayName", functions.WeekdayName)
|
||||
e.AddFunc("HRDateShort", functions.HRDateShort)
|
||||
e.AddFunc("HRDateYear", functions.HRDateYear)
|
||||
|
||||
// Strings
|
||||
e.AddFunc("FirstLetter", functions.FirstLetter)
|
||||
|
||||
@@ -2,12 +2,14 @@ package viewmodels
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/Theodor-Springmann-Stiftung/kgpz_web/helpers/datatypes"
|
||||
searchprovider "github.com/Theodor-Springmann-Stiftung/kgpz_web/providers/search"
|
||||
"github.com/Theodor-Springmann-Stiftung/kgpz_web/xmlmodels"
|
||||
"github.com/blevesearch/bleve/v2"
|
||||
"github.com/blevesearch/bleve/v2/search/query"
|
||||
"golang.org/x/text/cases"
|
||||
"golang.org/x/text/language"
|
||||
"golang.org/x/text/unicode/norm"
|
||||
@@ -35,7 +37,16 @@ func NewSearchView(search string, kgpz *xmlmodels.Library, sp *searchprovider.Se
|
||||
search = cases.Lower(language.German).String(search)
|
||||
search = norm.NFKD.String(search)
|
||||
|
||||
query := bleve.NewTermQuery(search)
|
||||
searches := strings.Split(search, " ")
|
||||
queries := make([]query.Query, 0, len(searches))
|
||||
for _, s := range searches {
|
||||
if strings.TrimSpace(s) == "" {
|
||||
continue
|
||||
}
|
||||
queries = append(queries, bleve.NewTermQuery(s))
|
||||
}
|
||||
|
||||
query := bleve.NewConjunctionQuery(queries...)
|
||||
request := bleve.NewSearchRequest(query)
|
||||
request.Size = 100
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -54,5 +54,7 @@
|
||||
{{ end }}
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
{{ EmbedXSLT "xslt/transform-citation.xsl" }}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{{ if ne (len .model.Search) 1 }}
|
||||
|
||||
{{ $agent := index $.model.Agents .model.Search }}
|
||||
{{ if not $agent }}
|
||||
<div>Agent nicht gefunden: {{ .model.Search }}</div>
|
||||
@@ -28,5 +27,3 @@
|
||||
{{ template "_akteur" $a }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ EmbedXSLT "xslt/transform-citation.xsl" }}
|
||||
|
||||
@@ -1,22 +1,133 @@
|
||||
{{ $model := .model }}
|
||||
|
||||
|
||||
<div id="results">
|
||||
{{ range $i, $agent := $model.Agents.Items }}
|
||||
<div>
|
||||
{{ $agent.String }}
|
||||
</div>
|
||||
{{ end }}
|
||||
<div
|
||||
id="results"
|
||||
class="pt-4 grid grid-flow-row-dense gap-x-8 gap-y-10 grid-cols-4 [&>div]:bg-slate-100
|
||||
[&>div]:px-4 [&>div]:py-3">
|
||||
<div class="col-span-1 searchresultcontainer">
|
||||
<h3>Personen</h3>
|
||||
{{ if $model.Agents.Items }}
|
||||
{{ range $i, $agent := $model.Agents.Items }}
|
||||
{{ $gnd := GetGND $agent.GND }}
|
||||
<div class="pt-1">
|
||||
{{- index $agent.Names 0 -}}
|
||||
</div>
|
||||
{{ if $gnd }}
|
||||
<div>
|
||||
{{- if and $gnd.DateOfBirth $gnd.DateOfDeath -}}
|
||||
<div>
|
||||
{{- if $gnd.DateOfBirth -}}
|
||||
{{- HRDateYear (index $gnd.DateOfBirth 0) -}}
|
||||
{{- else -}}
|
||||
[?]
|
||||
{{- end -}}
|
||||
 – 
|
||||
{{- if $gnd.DateOfDeath -}}
|
||||
{{- HRDateYear (index $gnd.DateOfDeath 0) -}}
|
||||
{{- else -}}
|
||||
[?]
|
||||
{{- end -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
<div class="pt-1">Keine Personen gefunden.</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
{{ range $i, $work := $model.Works.Items }}
|
||||
<div>
|
||||
{{ $work.String }}
|
||||
</div>
|
||||
{{ end }}
|
||||
<div class="col-span-1 searchresultcontainer">
|
||||
<h3>Orte</h3>
|
||||
{{ if $model.Places.Items }}
|
||||
{{ range $i, $place := $model.Places.Items }}
|
||||
<div class="pt-1">
|
||||
{{- index $place.Names 0 -}}
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
<div class="pt-1">Keine Orte gefunden.</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
{{ range $i, $place := $model.Places.Items }}
|
||||
<div>
|
||||
{{ $place.String }}
|
||||
</div>
|
||||
{{ end }}
|
||||
<div class="col-span-1 searchresultcontainer">
|
||||
<h3>Kategorien</h3>
|
||||
{{ if $model.Categories.Items }}
|
||||
{{ range $i, $category := $model.Categories.Items }}
|
||||
<div class="pt-1">
|
||||
{{- index $category.Names 0 -}}
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
<div class="pt-1">Keine Kategorien gefunden.</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
<div class="col-span-1 searchresultcontainer">
|
||||
<h3>Ausgaben</h3>
|
||||
{{ if $model.Issues.Items }}
|
||||
{{ range $i, $issue := $model.Issues.Items }}
|
||||
<div class="pt-1">
|
||||
KGPZ
|
||||
{{ $issue.Datum.When.Year }}/{{ $issue.Number.No }}
|
||||
({{ HRDateShort
|
||||
$issue.Datum.When.String
|
||||
}})
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
<div class="pt-1">Keine Ausgaben gefunden.</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
<div class="col-span-2 searchresultcontainer">
|
||||
<h3>Werke</h3>
|
||||
{{ if $model.Works.Items }}
|
||||
{{ range $i, $w := $model.Works.Items }}
|
||||
<div class="pt-1">
|
||||
{{- if ne (len $w.Citation.InnerXML ) 0 -}}
|
||||
<script type="application/xml" xslt-template="transform-citation" xslt-onload>
|
||||
<xml>
|
||||
{{- Safe $w.Citation.InnerXML -}}
|
||||
</xml>
|
||||
</script>
|
||||
{{- end -}}
|
||||
{{ range $_, $url := $w.URLs }}
|
||||
<div>
|
||||
<a href="{{ $url.Address }}" target="_blank">{{ $url.Chardata }}</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ $pieces := LookupPieces $w }}
|
||||
{{ if len $pieces }}
|
||||
<div>
|
||||
{{ range $_, $p := $pieces }}
|
||||
{{- range $_, $i := $p.Item.IssueRefs -}}
|
||||
<div>
|
||||
<a href="/{{ $i.When }}/{{ $i.Nr }}">{{ $i.Nr }}/{{ $i.When }}</a>
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
<div class="pt-1">Keine Werke gefunden.</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
<div class="col-span-2 searchresultcontainer">
|
||||
<h3>Beiträge</h3>
|
||||
{{ if $model.Pieces.Items }}
|
||||
{{ range $i, $piece := $model.Pieces.Items }}
|
||||
<div class="pt-1">
|
||||
{{ $piece.String }}
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
<div class="pt-1">Keine Beiträge gefunden.</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user