From 849349b7fdec3e026e7fe22ae82f4b90499b52bf Mon Sep 17 00:00:00 2001 From: Robert Janetzko Date: Wed, 4 May 2022 04:46:21 +0000 Subject: [PATCH] event page --- backend/model/functions.go | 5 +---- backend/server/server.go | 1 + backend/templates/event.html | 11 +++++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 backend/templates/event.html diff --git a/backend/model/functions.go b/backend/model/functions.go index e29a0b7..5a4b840 100644 --- a/backend/model/functions.go +++ b/backend/model/functions.go @@ -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 diff --git a/backend/server/server.go b/backend/server/server.go index 2ba4ddf..0711f7a 100644 --- a/backend/server/server.go +++ b/backend/server/server.go @@ -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, diff --git a/backend/templates/event.html b/backend/templates/event.html new file mode 100644 index 0000000..3100cbc --- /dev/null +++ b/backend/templates/event.html @@ -0,0 +1,11 @@ +{{template "layout.html" .}} + +{{define "title"}}Event {{ .Id }}{{end}} + +{{define "content"}} +

Event {{ .Id }}

+ +{{ story .Id }} + +

{{ json . }}

+{{- end }} \ No newline at end of file