event page
This commit is contained in:
parent
7310cf7872
commit
849349b7fd
|
@ -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 {
|
func replaceDescription[T NamedIdentifiable](s, prefix, suffix string, input map[int]T, namer func(T) string, mapper func(int) string) string {
|
||||||
r := "(" + prefix + `)([^.]+?)(` + suffix + ")"
|
r := "(" + prefix + `)([^.]+?)(` + suffix + ")"
|
||||||
fmt.Println(">", r)
|
|
||||||
reg := regexp.MustCompile(r)
|
reg := regexp.MustCompile(r)
|
||||||
res := reg.FindStringSubmatch(s)
|
res := reg.FindStringSubmatch(s)
|
||||||
if res == nil {
|
if res == nil {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(strings.Join(res, " / "))
|
|
||||||
|
|
||||||
name := strings.ToLower(res[2])
|
name := strings.ToLower(res[2])
|
||||||
for id, v := range input {
|
for id, v := range input {
|
||||||
if strings.ToLower(namer(v)) == name {
|
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
|
return s
|
||||||
|
|
|
@ -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", "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.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 {
|
srv.RegisterWorldPage("/collections", "collections.html", func(p Parms) any {
|
||||||
return groupBy(srv.context.world.HistoricalEventCollections,
|
return groupBy(srv.context.world.HistoricalEventCollections,
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
{{template "layout.html" .}}
|
||||||
|
|
||||||
|
{{define "title"}}Event {{ .Id }}{{end}}
|
||||||
|
|
||||||
|
{{define "content"}}
|
||||||
|
<h3>Event {{ .Id }}</h3>
|
||||||
|
|
||||||
|
{{ story .Id }}
|
||||||
|
|
||||||
|
<p>{{ json . }}</p>
|
||||||
|
{{- end }}
|
Loading…
Reference in New Issue