|
|
@ -42,36 +42,29 @@ func StartServer(world *model.DfWorld, static embed.FS) {
|
|
|
|
|
|
|
|
|
|
|
|
srv.RegisterWorldPage("/entities", "entities.html", func(p Parms) any { return grouped(srv.context.world.Entities) })
|
|
|
|
srv.RegisterWorldPage("/entities", "entities.html", func(p Parms) any { return grouped(srv.context.world.Entities) })
|
|
|
|
srv.RegisterWorldResourcePage("/entity/{id}", "entity.html", func(id int) any { return srv.context.world.Entities[id] })
|
|
|
|
srv.RegisterWorldResourcePage("/entity/{id}", "entity.html", func(id int) any { return srv.context.world.Entities[id] })
|
|
|
|
|
|
|
|
srv.RegisterWorldResourcePage("/popover/entity/{id}", "popoverEntity.html", func(id int) any { return srv.context.world.Entities[id] })
|
|
|
|
|
|
|
|
|
|
|
|
srv.RegisterWorldPage("/regions", "regions.html", func(p Parms) any { return grouped(srv.context.world.Regions) })
|
|
|
|
srv.RegisterWorldPage("/regions", "regions.html", func(p Parms) any { return grouped(srv.context.world.Regions) })
|
|
|
|
srv.RegisterWorldResourcePage("/region/{id}", "region.html", func(id int) any { return srv.context.world.Regions[id] })
|
|
|
|
srv.RegisterWorldResourcePage("/region/{id}", "region.html", func(id int) any { return srv.context.world.Regions[id] })
|
|
|
|
|
|
|
|
srv.RegisterWorldResourcePage("/popover/region/{id}", "popoverRegion.html", func(id int) any { return srv.context.world.Regions[id] })
|
|
|
|
|
|
|
|
|
|
|
|
srv.RegisterWorldPage("/sites", "sites.html", func(p Parms) any { return grouped(srv.context.world.Sites) })
|
|
|
|
srv.RegisterWorldPage("/sites", "sites.html", func(p Parms) any { return grouped(srv.context.world.Sites) })
|
|
|
|
srv.RegisterWorldResourcePage("/site/{id}", "site.html", func(id int) any { return srv.context.world.Sites[id] })
|
|
|
|
srv.RegisterWorldResourcePage("/site/{id}", "site.html", func(id int) any { return srv.context.world.Sites[id] })
|
|
|
|
|
|
|
|
srv.RegisterWorldResourcePage("/popover/site/{id}", "popoverSite.html", func(id int) any { return srv.context.world.Sites[id] })
|
|
|
|
|
|
|
|
|
|
|
|
srv.RegisterWorldPage("/structures", "structures.html", func(p Parms) any {
|
|
|
|
srv.RegisterWorldPage("/structures", "structures.html", func(p Parms) any {
|
|
|
|
return flatGrouped(srv.context.world.Sites, func(s *model.Site) []*model.Structure { return util.Values(s.Structures) })
|
|
|
|
return flatGrouped(srv.context.world.Sites, func(s *model.Site) []*model.Structure { return util.Values(s.Structures) })
|
|
|
|
})
|
|
|
|
})
|
|
|
|
srv.RegisterWorldPage("/site/{siteId}/structure/{id}", "structure.html", func(p Parms) any {
|
|
|
|
srv.RegisterWorldPage("/site/{siteId}/structure/{id}", "structure.html", srv.findStructure)
|
|
|
|
siteId, err := strconv.Atoi(p["siteId"])
|
|
|
|
srv.RegisterWorldPage("/popover/site/{siteId}/structure/{id}", "popoverStructure.html", srv.findStructure)
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
structureId, err := strconv.Atoi(p["id"])
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if site, ok := srv.context.world.Sites[siteId]; ok {
|
|
|
|
|
|
|
|
return site.Structures[structureId]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
srv.RegisterWorldPage("/worldconstructions", "worldconstructions.html", func(p Parms) any { return grouped(srv.context.world.WorldConstructions) })
|
|
|
|
srv.RegisterWorldPage("/worldconstructions", "worldconstructions.html", func(p Parms) any { return grouped(srv.context.world.WorldConstructions) })
|
|
|
|
srv.RegisterWorldResourcePage("/worldconstruction/{id}", "worldconstruction.html", func(id int) any { return srv.context.world.WorldConstructions[id] })
|
|
|
|
srv.RegisterWorldResourcePage("/worldconstruction/{id}", "worldconstruction.html", func(id int) any { return srv.context.world.WorldConstructions[id] })
|
|
|
|
|
|
|
|
srv.RegisterWorldResourcePage("/popover/worldconstruction/{id}", "popoverWorldconstruction.html", func(id int) any { return srv.context.world.WorldConstructions[id] })
|
|
|
|
|
|
|
|
|
|
|
|
srv.RegisterWorldPage("/artifacts", "artifacts.html", func(p Parms) any { return grouped(srv.context.world.Artifacts) })
|
|
|
|
srv.RegisterWorldPage("/artifacts", "artifacts.html", func(p Parms) any { return grouped(srv.context.world.Artifacts) })
|
|
|
|
srv.RegisterWorldResourcePage("/artifact/{id}", "artifact.html", func(id int) any { return srv.context.world.Artifacts[id] })
|
|
|
|
srv.RegisterWorldResourcePage("/artifact/{id}", "artifact.html", func(id int) any { return srv.context.world.Artifacts[id] })
|
|
|
|
|
|
|
|
srv.RegisterWorldResourcePage("/popover/artifact/{id}", "popoverArtifact.html", func(id int) any { return srv.context.world.Artifacts[id] })
|
|
|
|
|
|
|
|
|
|
|
|
srv.RegisterWorldPage("/artforms", "artforms.html", func(p Parms) any {
|
|
|
|
srv.RegisterWorldPage("/artforms", "artforms.html", func(p Parms) any {
|
|
|
|
return &struct {
|
|
|
|
return &struct {
|
|
|
@ -87,8 +80,10 @@ func StartServer(world *model.DfWorld, static embed.FS) {
|
|
|
|
|
|
|
|
|
|
|
|
srv.RegisterWorldPage("/writtencontents", "writtencontents.html", func(p Parms) any { return grouped(srv.context.world.WrittenContents) })
|
|
|
|
srv.RegisterWorldPage("/writtencontents", "writtencontents.html", func(p Parms) any { return grouped(srv.context.world.WrittenContents) })
|
|
|
|
srv.RegisterWorldResourcePage("/writtencontent/{id}", "writtencontent.html", func(id int) any { return srv.context.world.WrittenContents[id] })
|
|
|
|
srv.RegisterWorldResourcePage("/writtencontent/{id}", "writtencontent.html", func(id int) any { return srv.context.world.WrittenContents[id] })
|
|
|
|
|
|
|
|
srv.RegisterWorldResourcePage("/popover/writtencontent/{id}", "popoverWrittencontent.html", func(id int) any { return srv.context.world.WrittenContents[id] })
|
|
|
|
|
|
|
|
|
|
|
|
srv.RegisterWorldResourcePage("/hf/{id}", "hf.html", func(id int) any { return srv.context.world.HistoricalFigures[id] })
|
|
|
|
srv.RegisterWorldResourcePage("/hf/{id}", "hf.html", func(id int) any { return srv.context.world.HistoricalFigures[id] })
|
|
|
|
|
|
|
|
srv.RegisterWorldResourcePage("/popover/hf/{id}", "popoverHf.html", func(id int) any { return srv.context.world.HistoricalFigures[id] })
|
|
|
|
|
|
|
|
|
|
|
|
srv.RegisterWorldPage("/", "eventTypes.html", func(p Parms) any { return srv.context.world.AllEventTypes() })
|
|
|
|
srv.RegisterWorldPage("/", "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", "eventTypes.html", func(p Parms) any { return srv.context.world.AllEventTypes() })
|
|
|
@ -107,6 +102,21 @@ func StartServer(world *model.DfWorld, static embed.FS) {
|
|
|
|
http.ListenAndServe(":8080", srv.router)
|
|
|
|
http.ListenAndServe(":8080", srv.router)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (srv *DfServer) findStructure(p Parms) any {
|
|
|
|
|
|
|
|
siteId, err := strconv.Atoi(p["siteId"])
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
structureId, err := strconv.Atoi(p["id"])
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if site, ok := srv.context.world.Sites[siteId]; ok {
|
|
|
|
|
|
|
|
return site.Structures[structureId]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type spaHandler struct {
|
|
|
|
type spaHandler struct {
|
|
|
|
server *DfServer
|
|
|
|
server *DfServer
|
|
|
|
staticFS embed.FS
|
|
|
|
staticFS embed.FS
|
|
|
|