event page

This commit is contained in:
Robert Janetzko 2022-05-04 04:46:21 +00:00
parent 7310cf7872
commit 849349b7fd
3 changed files with 13 additions and 4 deletions

View File

@ -160,19 +160,16 @@ func replacHfDescription(s, prefix, suffix string, input map[int]*HistoricalFigu
func replaceDescription[T NamedIdentifiable](s, prefix, suffix string, input map[int]T, namer func(T) string, mapper func(int) string) string {
r := "(" + prefix + `)([^.]+?)(` + suffix + ")"
fmt.Println(">", r)
reg := regexp.MustCompile(r)
res := reg.FindStringSubmatch(s)
if res == nil {
return s
}
fmt.Println(strings.Join(res, " / "))
name := strings.ToLower(res[2])
for id, v := range input {
if strings.ToLower(namer(v)) == name {
return reg.ReplaceAllString(s, res[1]+mapper(id)+" ("+name+")"+res[3])
return reg.ReplaceAllString(s, res[1]+mapper(id)+res[3])
}
}
return s

View File

@ -97,6 +97,7 @@ func StartServer(world *model.DfWorld, static embed.FS) error {
srv.RegisterWorldPage("/events", "eventTypes.html", func(p Parms) any { return srv.context.world.AllEventTypes() })
srv.RegisterWorldPage("/events/{type}", "eventType.html", func(p Parms) any { return srv.context.world.EventsOfType(p["type"]) })
srv.RegisterWorldResourcePage("/event/{id}", "event.html", func(id int) any { return srv.context.world.HistoricalEvents[id] })
srv.RegisterWorldPage("/collections", "collections.html", func(p Parms) any {
return groupBy(srv.context.world.HistoricalEventCollections,

View File

@ -0,0 +1,11 @@
{{template "layout.html" .}}
{{define "title"}}Event {{ .Id }}{{end}}
{{define "content"}}
<h3>Event {{ .Id }}</h3>
{{ story .Id }}
<p>{{ json . }}</p>
{{- end }}