This commit is contained in:
Robert Janetzko 2022-04-28 19:24:55 +00:00
parent 1c26cd2183
commit eca66b0e5f
17 changed files with 374 additions and 16 deletions

View File

@ -114,6 +114,7 @@ func New{{ $obj.Name }}() *{{ $obj.Name }} {
{{- if $obj.Id }} {{- if $obj.Id }}
func (x *{{ $obj.Name }}) Id() int { return x.Id_ } func (x *{{ $obj.Name }}) Id() int { return x.Id_ }
func (x *{{ $obj.Name }}) setId(id int) { x.Id_ = id }
{{- end }} {{- end }}
{{- if $obj.Named }} {{- if $obj.Named }}
func (x *{{ $obj.Name }}) Name() string { return x.Name_ } func (x *{{ $obj.Name }}) Name() string { return x.Name_ }

View File

@ -229,7 +229,7 @@ func (c *Context) feature(x *Feature) string {
case FeatureType_Storytelling: case FeatureType_Storytelling:
if x.Reference != -1 { if x.Reference != -1 {
if e, ok := c.World.HistoricalEvents[x.Reference]; ok { if e, ok := c.World.HistoricalEvents[x.Reference]; ok {
return "a telling of the story of " + e.Details.Html(&Context{Story: true}) + " in " + Time(e.Year, e.Seconds72) return "a telling of the story of " + e.Details.Html(&Context{World: c.World, Story: true}) + " in " + Time(e.Year, e.Seconds72)
} }
} }
return "a story recital" return "a story recital"
@ -249,7 +249,7 @@ func (c *Context) schedule(x *Schedule) string {
case ScheduleType_Storytelling: case ScheduleType_Storytelling:
if x.Reference != -1 { if x.Reference != -1 {
if e, ok := c.World.HistoricalEvents[x.Reference]; ok { if e, ok := c.World.HistoricalEvents[x.Reference]; ok {
return "the story of " + e.Details.Html(&Context{Story: true}) + " in " + Time(e.Year, e.Seconds72) return "the story of " + e.Details.Html(&Context{World: c.World, Story: true}) + " in " + Time(e.Year, e.Seconds72)
} }
} }
return "a story recital" return "a story recital"

View File

@ -48,6 +48,10 @@ func (w *DfWorld) EventsMatching(f func(HistoricalEventDetails) bool) []*Histori
return list return list
} }
func (e *Artifact) Type() string {
return e.ItemType
}
func (e *Entity) Type() string { func (e *Entity) Type() string {
return e.Type_.String() return e.Type_.String()
} }
@ -121,6 +125,34 @@ func (x *Honor) Requirement() string {
return " after " + andList(list) return " after " + andList(list)
} }
func (r *Region) Type() string {
return r.Type_.String()
}
func (s *Site) Type() string {
return s.Type_.String()
}
func (w *WorldConstruction) Type() string {
return w.Type_.String()
}
func (w *WrittenContent) Name() string { func (w *WrittenContent) Name() string {
return w.Title return w.Title
} }
func (w *WrittenContent) Type() string {
return w.Type_.String()
}
func (w *DanceForm) Type() string {
return "dance form"
}
func (w *MusicalForm) Type() string {
return "musical form"
}
func (w *PoeticForm) Type() string {
return "poetic form"
}

View File

@ -11,6 +11,14 @@ var LinkHf = func(w *DfWorld, id int) template.HTML { return template.HTML((&Con
var LinkEntity = func(w *DfWorld, id int) template.HTML { return template.HTML((&Context{World: w}).entity(id)) } var LinkEntity = func(w *DfWorld, id int) template.HTML { return template.HTML((&Context{World: w}).entity(id)) }
var LinkSite = func(w *DfWorld, id int) template.HTML { return template.HTML((&Context{World: w}).site(id, "")) } var LinkSite = func(w *DfWorld, id int) template.HTML { return template.HTML((&Context{World: w}).site(id, "")) }
var LinkRegion = func(w *DfWorld, id int) template.HTML { return template.HTML((&Context{World: w}).region(id)) } var LinkRegion = func(w *DfWorld, id int) template.HTML { return template.HTML((&Context{World: w}).region(id)) }
var LinkWorldConstruction = func(w *DfWorld, id int) template.HTML {
return template.HTML((&Context{World: w}).worldConstruction(id))
}
var LinkArtifact = func(w *DfWorld, id int) template.HTML { return template.HTML((&Context{World: w}).artifact(id)) }
var LinkDanceForm = func(w *DfWorld, id int) template.HTML { return template.HTML((&Context{World: w}).danceForm(id)) }
var LinkMusicalForm = func(w *DfWorld, id int) template.HTML { return template.HTML((&Context{World: w}).musicalForm(id)) }
var LinkPoeticForm = func(w *DfWorld, id int) template.HTML { return template.HTML((&Context{World: w}).poeticForm(id)) }
var LinkWrittenContent = func(w *DfWorld, id int) template.HTML { return template.HTML((&Context{World: w}).writtenContent(id)) }
func andList(list []string) string { func andList(list []string) string {
if len(list) > 1 { if len(list) > 1 {

View File

@ -1148,6 +1148,7 @@ func NewArtifact() *Artifact {
} }
} }
func (x *Artifact) Id() int { return x.Id_ } func (x *Artifact) Id() int { return x.Id_ }
func (x *Artifact) setId(id int) { x.Id_ = id }
func (x *Artifact) Name() string { return x.Name_ } func (x *Artifact) Name() string { return x.Name_ }
func (x *Artifact) RelatedToEntity(id int) bool { return false } func (x *Artifact) RelatedToEntity(id int) bool { return false }
func (x *Artifact) RelatedToHf(id int) bool { return x.HolderHfid == id } func (x *Artifact) RelatedToHf(id int) bool { return x.HolderHfid == id }
@ -1511,6 +1512,7 @@ func NewDanceForm() *DanceForm {
} }
} }
func (x *DanceForm) Id() int { return x.Id_ } func (x *DanceForm) Id() int { return x.Id_ }
func (x *DanceForm) setId(id int) { x.Id_ = id }
func (x *DanceForm) Name() string { return x.Name_ } func (x *DanceForm) Name() string { return x.Name_ }
func (x *DanceForm) RelatedToEntity(id int) bool { return false } func (x *DanceForm) RelatedToEntity(id int) bool { return false }
func (x *DanceForm) RelatedToHf(id int) bool { return false } func (x *DanceForm) RelatedToHf(id int) bool { return false }
@ -1993,6 +1995,7 @@ func NewEntity() *Entity {
} }
} }
func (x *Entity) Id() int { return x.Id_ } func (x *Entity) Id() int { return x.Id_ }
func (x *Entity) setId(id int) { x.Id_ = id }
func (x *Entity) Name() string { return x.Name_ } func (x *Entity) Name() string { return x.Name_ }
func (x *Entity) RelatedToEntity(id int) bool { return false } func (x *Entity) RelatedToEntity(id int) bool { return false }
func (x *Entity) RelatedToHf(id int) bool { return containsInt(x.HistfigId, id) } func (x *Entity) RelatedToHf(id int) bool { return containsInt(x.HistfigId, id) }
@ -2196,6 +2199,7 @@ func NewEntityPopulation() *EntityPopulation {
} }
} }
func (x *EntityPopulation) Id() int { return x.Id_ } func (x *EntityPopulation) Id() int { return x.Id_ }
func (x *EntityPopulation) setId(id int) { x.Id_ = id }
func (x *EntityPopulation) RelatedToEntity(id int) bool { return x.CivId == id } func (x *EntityPopulation) RelatedToEntity(id int) bool { return x.CivId == id }
func (x *EntityPopulation) RelatedToHf(id int) bool { return false } func (x *EntityPopulation) RelatedToHf(id int) bool { return false }
func (x *EntityPopulation) RelatedToArtifact(id int) bool { return false } func (x *EntityPopulation) RelatedToArtifact(id int) bool { return false }
@ -2233,6 +2237,7 @@ func NewEntityPosition() *EntityPosition {
} }
} }
func (x *EntityPosition) Id() int { return x.Id_ } func (x *EntityPosition) Id() int { return x.Id_ }
func (x *EntityPosition) setId(id int) { x.Id_ = id }
func (x *EntityPosition) Name() string { return x.Name_ } func (x *EntityPosition) Name() string { return x.Name_ }
func (x *EntityPosition) RelatedToEntity(id int) bool { return false } func (x *EntityPosition) RelatedToEntity(id int) bool { return false }
func (x *EntityPosition) RelatedToHf(id int) bool { return false } func (x *EntityPosition) RelatedToHf(id int) bool { return false }
@ -2273,6 +2278,7 @@ func NewEntityPositionAssignment() *EntityPositionAssignment {
} }
} }
func (x *EntityPositionAssignment) Id() int { return x.Id_ } func (x *EntityPositionAssignment) Id() int { return x.Id_ }
func (x *EntityPositionAssignment) setId(id int) { x.Id_ = id }
func (x *EntityPositionAssignment) RelatedToEntity(id int) bool { return false } func (x *EntityPositionAssignment) RelatedToEntity(id int) bool { return false }
func (x *EntityPositionAssignment) RelatedToHf(id int) bool { return x.Histfig == id } func (x *EntityPositionAssignment) RelatedToHf(id int) bool { return x.Histfig == id }
func (x *EntityPositionAssignment) RelatedToArtifact(id int) bool { return false } func (x *EntityPositionAssignment) RelatedToArtifact(id int) bool { return false }
@ -2798,6 +2804,7 @@ func NewHistoricalEvent() *HistoricalEvent {
} }
} }
func (x *HistoricalEvent) Id() int { return x.Id_ } func (x *HistoricalEvent) Id() int { return x.Id_ }
func (x *HistoricalEvent) setId(id int) { x.Id_ = id }
func (x *HistoricalEvent) RelatedToEntity(id int) bool { return false } func (x *HistoricalEvent) RelatedToEntity(id int) bool { return false }
func (x *HistoricalEvent) RelatedToHf(id int) bool { return false } func (x *HistoricalEvent) RelatedToHf(id int) bool { return false }
func (x *HistoricalEvent) RelatedToArtifact(id int) bool { return false } func (x *HistoricalEvent) RelatedToArtifact(id int) bool { return false }
@ -5803,6 +5810,7 @@ func NewHistoricalEventCollection() *HistoricalEventCollection {
} }
} }
func (x *HistoricalEventCollection) Id() int { return x.Id_ } func (x *HistoricalEventCollection) Id() int { return x.Id_ }
func (x *HistoricalEventCollection) setId(id int) { x.Id_ = id }
func (x *HistoricalEventCollection) RelatedToEntity(id int) bool { return false } func (x *HistoricalEventCollection) RelatedToEntity(id int) bool { return false }
func (x *HistoricalEventCollection) RelatedToHf(id int) bool { return false } func (x *HistoricalEventCollection) RelatedToHf(id int) bool { return false }
func (x *HistoricalEventCollection) RelatedToArtifact(id int) bool { return false } func (x *HistoricalEventCollection) RelatedToArtifact(id int) bool { return false }
@ -16372,6 +16380,7 @@ func NewHistoricalFigure() *HistoricalFigure {
} }
} }
func (x *HistoricalFigure) Id() int { return x.Id_ } func (x *HistoricalFigure) Id() int { return x.Id_ }
func (x *HistoricalFigure) setId(id int) { x.Id_ = id }
func (x *HistoricalFigure) Name() string { return x.Name_ } func (x *HistoricalFigure) Name() string { return x.Name_ }
func (x *HistoricalFigure) RelatedToEntity(id int) bool { func (x *HistoricalFigure) RelatedToEntity(id int) bool {
return containsInt(x.UsedIdentityId, id) || x.CurrentIdentityId == id return containsInt(x.UsedIdentityId, id) || x.CurrentIdentityId == id
@ -16700,6 +16709,7 @@ func NewHonor() *Honor {
} }
} }
func (x *Honor) Id() int { return x.Id_ } func (x *Honor) Id() int { return x.Id_ }
func (x *Honor) setId(id int) { x.Id_ = id }
func (x *Honor) Name() string { return x.Name_ } func (x *Honor) Name() string { return x.Name_ }
func (x *Honor) RelatedToEntity(id int) bool { return false } func (x *Honor) RelatedToEntity(id int) bool { return false }
func (x *Honor) RelatedToHf(id int) bool { return false } func (x *Honor) RelatedToHf(id int) bool { return false }
@ -16904,6 +16914,7 @@ func NewIdentity() *Identity {
} }
} }
func (x *Identity) Id() int { return x.Id_ } func (x *Identity) Id() int { return x.Id_ }
func (x *Identity) setId(id int) { x.Id_ = id }
func (x *Identity) Name() string { return x.Name_ } func (x *Identity) Name() string { return x.Name_ }
func (x *Identity) RelatedToEntity(id int) bool { return x.EntityId == id } func (x *Identity) RelatedToEntity(id int) bool { return x.EntityId == id }
func (x *Identity) RelatedToHf(id int) bool { return x.HistfigId == id } func (x *Identity) RelatedToHf(id int) bool { return x.HistfigId == id }
@ -17409,6 +17420,7 @@ func NewLandmass() *Landmass {
} }
} }
func (x *Landmass) Id() int { return x.Id_ } func (x *Landmass) Id() int { return x.Id_ }
func (x *Landmass) setId(id int) { x.Id_ = id }
func (x *Landmass) Name() string { return x.Name_ } func (x *Landmass) Name() string { return x.Name_ }
func (x *Landmass) RelatedToEntity(id int) bool { return false } func (x *Landmass) RelatedToEntity(id int) bool { return false }
func (x *Landmass) RelatedToHf(id int) bool { return false } func (x *Landmass) RelatedToHf(id int) bool { return false }
@ -17445,6 +17457,7 @@ func NewMountainPeak() *MountainPeak {
} }
} }
func (x *MountainPeak) Id() int { return x.Id_ } func (x *MountainPeak) Id() int { return x.Id_ }
func (x *MountainPeak) setId(id int) { x.Id_ = id }
func (x *MountainPeak) Name() string { return x.Name_ } func (x *MountainPeak) Name() string { return x.Name_ }
func (x *MountainPeak) RelatedToEntity(id int) bool { return false } func (x *MountainPeak) RelatedToEntity(id int) bool { return false }
func (x *MountainPeak) RelatedToHf(id int) bool { return false } func (x *MountainPeak) RelatedToHf(id int) bool { return false }
@ -17481,6 +17494,7 @@ func NewMusicalForm() *MusicalForm {
} }
} }
func (x *MusicalForm) Id() int { return x.Id_ } func (x *MusicalForm) Id() int { return x.Id_ }
func (x *MusicalForm) setId(id int) { x.Id_ = id }
func (x *MusicalForm) Name() string { return x.Name_ } func (x *MusicalForm) Name() string { return x.Name_ }
func (x *MusicalForm) RelatedToEntity(id int) bool { return false } func (x *MusicalForm) RelatedToEntity(id int) bool { return false }
func (x *MusicalForm) RelatedToHf(id int) bool { return false } func (x *MusicalForm) RelatedToHf(id int) bool { return false }
@ -17515,6 +17529,7 @@ func NewOccasion() *Occasion {
} }
} }
func (x *Occasion) Id() int { return x.Id_ } func (x *Occasion) Id() int { return x.Id_ }
func (x *Occasion) setId(id int) { x.Id_ = id }
func (x *Occasion) Name() string { return x.Name_ } func (x *Occasion) Name() string { return x.Name_ }
func (x *Occasion) RelatedToEntity(id int) bool { return false } func (x *Occasion) RelatedToEntity(id int) bool { return false }
func (x *Occasion) RelatedToHf(id int) bool { return false } func (x *Occasion) RelatedToHf(id int) bool { return false }
@ -17624,6 +17639,7 @@ func NewPoeticForm() *PoeticForm {
} }
} }
func (x *PoeticForm) Id() int { return x.Id_ } func (x *PoeticForm) Id() int { return x.Id_ }
func (x *PoeticForm) setId(id int) { x.Id_ = id }
func (x *PoeticForm) Name() string { return x.Name_ } func (x *PoeticForm) Name() string { return x.Name_ }
func (x *PoeticForm) RelatedToEntity(id int) bool { return false } func (x *PoeticForm) RelatedToEntity(id int) bool { return false }
func (x *PoeticForm) RelatedToHf(id int) bool { return false } func (x *PoeticForm) RelatedToHf(id int) bool { return false }
@ -17752,6 +17768,7 @@ func NewReference() *Reference {
} }
} }
func (x *Reference) Id() int { return x.Id_ } func (x *Reference) Id() int { return x.Id_ }
func (x *Reference) setId(id int) { x.Id_ = id }
func (x *Reference) RelatedToEntity(id int) bool { return false } func (x *Reference) RelatedToEntity(id int) bool { return false }
func (x *Reference) RelatedToHf(id int) bool { return false } func (x *Reference) RelatedToHf(id int) bool { return false }
func (x *Reference) RelatedToArtifact(id int) bool { return false } func (x *Reference) RelatedToArtifact(id int) bool { return false }
@ -17897,6 +17914,7 @@ func NewRegion() *Region {
} }
} }
func (x *Region) Id() int { return x.Id_ } func (x *Region) Id() int { return x.Id_ }
func (x *Region) setId(id int) { x.Id_ = id }
func (x *Region) Name() string { return x.Name_ } func (x *Region) Name() string { return x.Name_ }
func (x *Region) RelatedToEntity(id int) bool { return false } func (x *Region) RelatedToEntity(id int) bool { return false }
func (x *Region) RelatedToHf(id int) bool { return false } func (x *Region) RelatedToHf(id int) bool { return false }
@ -18034,6 +18052,7 @@ func NewRelationshipProfileHfIdentity() *RelationshipProfileHfIdentity {
} }
} }
func (x *RelationshipProfileHfIdentity) Id() int { return x.Id_ } func (x *RelationshipProfileHfIdentity) Id() int { return x.Id_ }
func (x *RelationshipProfileHfIdentity) setId(id int) { x.Id_ = id }
func (x *RelationshipProfileHfIdentity) RelatedToEntity(id int) bool { return false } func (x *RelationshipProfileHfIdentity) RelatedToEntity(id int) bool { return false }
func (x *RelationshipProfileHfIdentity) RelatedToHf(id int) bool { return false } func (x *RelationshipProfileHfIdentity) RelatedToHf(id int) bool { return false }
func (x *RelationshipProfileHfIdentity) RelatedToArtifact(id int) bool { return false } func (x *RelationshipProfileHfIdentity) RelatedToArtifact(id int) bool { return false }
@ -18490,6 +18509,7 @@ func NewSchedule() *Schedule {
} }
} }
func (x *Schedule) Id() int { return x.Id_ } func (x *Schedule) Id() int { return x.Id_ }
func (x *Schedule) setId(id int) { x.Id_ = id }
func (x *Schedule) RelatedToEntity(id int) bool { return false } func (x *Schedule) RelatedToEntity(id int) bool { return false }
func (x *Schedule) RelatedToHf(id int) bool { return false } func (x *Schedule) RelatedToHf(id int) bool { return false }
func (x *Schedule) RelatedToArtifact(id int) bool { return false } func (x *Schedule) RelatedToArtifact(id int) bool { return false }
@ -18667,6 +18687,7 @@ func NewSite() *Site {
} }
} }
func (x *Site) Id() int { return x.Id_ } func (x *Site) Id() int { return x.Id_ }
func (x *Site) setId(id int) { x.Id_ = id }
func (x *Site) Name() string { return x.Name_ } func (x *Site) Name() string { return x.Name_ }
func (x *Site) RelatedToEntity(id int) bool { return x.CivId == id } func (x *Site) RelatedToEntity(id int) bool { return x.CivId == id }
func (x *Site) RelatedToHf(id int) bool { return false } func (x *Site) RelatedToHf(id int) bool { return false }
@ -18848,6 +18869,7 @@ func NewSiteSiteProperty() *SiteSiteProperty {
} }
} }
func (x *SiteSiteProperty) Id() int { return x.Id_ } func (x *SiteSiteProperty) Id() int { return x.Id_ }
func (x *SiteSiteProperty) setId(id int) { x.Id_ = id }
func (x *SiteSiteProperty) RelatedToEntity(id int) bool { return false } func (x *SiteSiteProperty) RelatedToEntity(id int) bool { return false }
func (x *SiteSiteProperty) RelatedToHf(id int) bool { return x.OwnerHfid == id } func (x *SiteSiteProperty) RelatedToHf(id int) bool { return x.OwnerHfid == id }
func (x *SiteSiteProperty) RelatedToArtifact(id int) bool { return false } func (x *SiteSiteProperty) RelatedToArtifact(id int) bool { return false }
@ -19026,6 +19048,7 @@ func NewStructure() *Structure {
} }
} }
func (x *Structure) Id() int { return x.Id_ } func (x *Structure) Id() int { return x.Id_ }
func (x *Structure) setId(id int) { x.Id_ = id }
func (x *Structure) Name() string { return x.Name_ } func (x *Structure) Name() string { return x.Name_ }
func (x *Structure) RelatedToEntity(id int) bool { return x.EntityId == id } func (x *Structure) RelatedToEntity(id int) bool { return x.EntityId == id }
func (x *Structure) RelatedToHf(id int) bool { return x.WorshipHfid == id } func (x *Structure) RelatedToHf(id int) bool { return x.WorshipHfid == id }
@ -19162,6 +19185,7 @@ func NewUndergroundRegion() *UndergroundRegion {
} }
} }
func (x *UndergroundRegion) Id() int { return x.Id_ } func (x *UndergroundRegion) Id() int { return x.Id_ }
func (x *UndergroundRegion) setId(id int) { x.Id_ = id }
func (x *UndergroundRegion) RelatedToEntity(id int) bool { return false } func (x *UndergroundRegion) RelatedToEntity(id int) bool { return false }
func (x *UndergroundRegion) RelatedToHf(id int) bool { return false } func (x *UndergroundRegion) RelatedToHf(id int) bool { return false }
func (x *UndergroundRegion) RelatedToArtifact(id int) bool { return false } func (x *UndergroundRegion) RelatedToArtifact(id int) bool { return false }
@ -19288,6 +19312,7 @@ func NewWorldConstruction() *WorldConstruction {
} }
} }
func (x *WorldConstruction) Id() int { return x.Id_ } func (x *WorldConstruction) Id() int { return x.Id_ }
func (x *WorldConstruction) setId(id int) { x.Id_ = id }
func (x *WorldConstruction) Name() string { return x.Name_ } func (x *WorldConstruction) Name() string { return x.Name_ }
func (x *WorldConstruction) RelatedToEntity(id int) bool { return false } func (x *WorldConstruction) RelatedToEntity(id int) bool { return false }
func (x *WorldConstruction) RelatedToHf(id int) bool { return false } func (x *WorldConstruction) RelatedToHf(id int) bool { return false }
@ -19630,6 +19655,7 @@ func NewWrittenContent() *WrittenContent {
} }
} }
func (x *WrittenContent) Id() int { return x.Id_ } func (x *WrittenContent) Id() int { return x.Id_ }
func (x *WrittenContent) setId(id int) { x.Id_ = id }
func (x *WrittenContent) RelatedToEntity(id int) bool { return false } func (x *WrittenContent) RelatedToEntity(id int) bool { return false }
func (x *WrittenContent) RelatedToHf(id int) bool { return x.AuthorHfid == id } func (x *WrittenContent) RelatedToHf(id int) bool { return x.AuthorHfid == id }
func (x *WrittenContent) RelatedToArtifact(id int) bool { return false } func (x *WrittenContent) RelatedToArtifact(id int) bool { return false }

View File

@ -143,6 +143,10 @@ BaseLoop:
} }
ioutil.WriteFile("same.json", same, 0644) ioutil.WriteFile("same.json", same, 0644)
for _, e := range world.HistoricalEvents {
e.Details.Html(&Context{World: world})
}
return world, nil return world, nil
} }
@ -193,6 +197,7 @@ func parseMapPlus[T Identifiable](p *util.XMLParser, dest *map[int]T, creator fu
log.Fatal(err) log.Fatal(err)
} }
x, err := creator(p, (*dest)[id]) x, err := creator(p, (*dest)[id])
x.setId(id)
if err != nil { if err != nil {
return return
} }

View File

@ -17,6 +17,7 @@ type Named interface {
type Identifiable interface { type Identifiable interface {
Id() int Id() int
setId(int)
} }
type Typed interface { type Typed interface {

View File

@ -48,11 +48,35 @@ 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("/hf/{id}", "hf.html", func(id int) any { return srv.context.world.HistoricalFigures[id] }) 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.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.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.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.RegisterWorldPage("/artforms", "artforms.html", func(p Parms) any {
return struct {
DanceForms map[string][]*model.DanceForm
MusicalForms map[string][]*model.MusicalForm
PoeticForms map[string][]*model.PoeticForm
}{
DanceForms: grouped(srv.context.world.DanceForms),
MusicalForms: grouped(srv.context.world.MusicalForms),
PoeticForms: grouped(srv.context.world.PoeticForms),
}
})
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("/hf/{id}", "hf.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() })
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"]) })

View File

@ -6,6 +6,7 @@ import (
"net/url" "net/url"
humanize "github.com/dustin/go-humanize" humanize "github.com/dustin/go-humanize"
"github.com/iancoleman/strcase"
"github.com/robertjanetzko/LegendsBrowser2/backend/model" "github.com/robertjanetzko/LegendsBrowser2/backend/model"
"github.com/robertjanetzko/LegendsBrowser2/backend/templates" "github.com/robertjanetzko/LegendsBrowser2/backend/templates"
"github.com/robertjanetzko/LegendsBrowser2/backend/util" "github.com/robertjanetzko/LegendsBrowser2/backend/util"
@ -21,6 +22,7 @@ func (srv *DfServer) LoadTemplates() {
return nil return nil
}, },
"title": util.Title, "title": util.Title,
"kebab": func(s string) string { return strcase.ToKebab(s) },
"hf": func(id int) template.HTML { return model.LinkHf(srv.context.world, id) }, "hf": func(id int) template.HTML { return model.LinkHf(srv.context.world, id) },
"getHf": func(id int) *model.HistoricalFigure { return srv.context.world.HistoricalFigures[id] }, "getHf": func(id int) *model.HistoricalFigure { return srv.context.world.HistoricalFigures[id] },
"entity": func(id int) template.HTML { return model.LinkEntity(srv.context.world, id) }, "entity": func(id int) template.HTML { return model.LinkEntity(srv.context.world, id) },
@ -29,6 +31,14 @@ func (srv *DfServer) LoadTemplates() {
"getSite": func(id int) *model.Site { return srv.context.world.Sites[id] }, "getSite": func(id int) *model.Site { return srv.context.world.Sites[id] },
"region": func(id int) template.HTML { return model.LinkRegion(srv.context.world, id) }, "region": func(id int) template.HTML { return model.LinkRegion(srv.context.world, id) },
"getRegion": func(id int) *model.Region { return srv.context.world.Regions[id] }, "getRegion": func(id int) *model.Region { return srv.context.world.Regions[id] },
"worldconstruction": func(id int) template.HTML { return model.LinkWorldConstruction(srv.context.world, id) },
"getWorldconstruction": func(id int) *model.WorldConstruction { return srv.context.world.WorldConstructions[id] },
"artifact": func(id int) template.HTML { return model.LinkArtifact(srv.context.world, id) },
"getArtifact": func(id int) *model.Artifact { return srv.context.world.Artifacts[id] },
"danceForm": func(id int) template.HTML { return model.LinkDanceForm(srv.context.world, id) },
"musicalForm": func(id int) template.HTML { return model.LinkMusicalForm(srv.context.world, id) },
"poeticForm": func(id int) template.HTML { return model.LinkPoeticForm(srv.context.world, id) },
"writtencontent": func(id int) template.HTML { return model.LinkWrittenContent(srv.context.world, id) },
"events": func(obj any) *model.EventList { "events": func(obj any) *model.EventList {
return model.NewEventList(srv.context.world, obj) return model.NewEventList(srv.context.world, obj)
}, },

View File

@ -0,0 +1,76 @@
{{template "layout.html" .}}
{{define "title"}}Artifacts{{end}}
{{define "content"}}
<h3>Artifacts</h3>
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
{{- range $t, $v := .DanceForms }}
<button class="nav-link active" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button" role="tab">{{$t}} ({{
len $v
}})</button>
{{- end}}
{{- range $t, $v := .MusicalForms }}
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button" role="tab">{{$t}} ({{ len $v
}})</button>
{{- end}}
{{- range $t, $v := .PoeticForms }}
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button" role="tab">{{$t}} ({{ len $v
}})</button>
{{- end}}
</div>
</nav>
<div class="tab-content" id="nav-tabContent">
{{- range $t, $v := .DanceForms }}
<div class="tab-pane active" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<table>
<tr>
<th width="100%">Name</th>
<th>Size</th>
</tr>
{{- range $v }}{{- if not (eq .Name "") }}
<tr>
<td>{{ danceForm .Id }}</td>
<td></td>
</tr>
{{- end}}{{- end}}
</table>
</div>
{{- end}}
{{- range $t, $v := .MusicalForms }}
<div class="tab-pane" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<table>
<tr>
<th width="100%">Name</th>
<th>Size</th>
</tr>
{{- range $v }}{{- if not (eq .Name "") }}
<tr>
<td>{{ musicalForm .Id }}</td>
<td></td>
</tr>
{{- end}}{{- end}}
</table>
</div>
{{- end}}
{{- range $t, $v := .PoeticForms }}
<div class="tab-pane" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<table>
<tr>
<th width="100%">Name</th>
<th>Size</th>
</tr>
{{- range $v }}{{- if not (eq .Name "") }}
<tr>
<td>{{ poeticForm .Id }}</td>
<td></td>
</tr>
{{- end}}{{- end}}
</table>
</div>
{{- end}}
</div>
{{- end }}

View File

@ -0,0 +1,35 @@
{{template "layout.html" .}}
{{define "title"}}Artifacts{{end}}
{{define "content"}}
<h3>Artifacts</h3>
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
{{- range $t, $v := .}}
<button class="nav-link{{ ifFirst $ $t " active" }}" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button"
role="tab">{{$t}} ({{ len $v }})</button>
{{- end}}
</div>
</nav>
<div class="tab-content" id="nav-tabContent">
{{- range $t, $v := . }}
<div class="tab-pane{{ ifFirst $ $t " active" }}" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<table>
<tr>
<th width="100%">Name</th>
<th>Size</th>
</tr>
{{- range $v }}{{- if not (eq .Name "") }}
<tr>
<td>{{ artifact .Id }}</td>
<td></td>
</tr>
{{- end}}{{- end}}
</table>
</div>
{{- end}}
</div>
{{- end }}

View File

@ -8,14 +8,14 @@
<nav> <nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist"> <div class="nav nav-tabs" id="nav-tab" role="tablist">
{{- range $t, $v := .}} {{- range $t, $v := .}}
<button class="nav-link{{ ifFirst $ $t " active" }}" data-bs-toggle="tab" data-bs-target="#nav-{{$t}}" type="button" <button class="nav-link{{ ifFirst $ $t " active" }}" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button"
role="tab">{{$t}}</button> role="tab">{{$t}} ({{ len $v }})</button>
{{- end}} {{- end}}
</div> </div>
</nav> </nav>
<div class="tab-content" id="nav-tabContent"> <div class="tab-content" id="nav-tabContent">
{{- range $t, $v := . }} {{- range $t, $v := . }}
<div class="tab-pane{{ ifFirst $ $t " active" }}" id="nav-{{$t}}" role="tabpanel" aria-labelledby="nav-home-tab"> <div class="tab-pane{{ ifFirst $ $t " active" }}" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<table> <table>
<tr> <tr>
<th width="100%">Name</th> <th width="100%">Name</th>

View File

@ -1,7 +1,7 @@
<ul> <ul>
{{- range $event := .Events }} {{- range $event := .Events }}
<li> <li>
[{{ $event.Id }}] In {{ if gt $event.Seconds72 -1 }}{{ season $event.Seconds72 }} of {{ end }}{{ $event.Year }}, {{ [{{ $event.Id }}] In {{ time $event.Year $event.Seconds72 }}, {{
html ($event.Details.Html $.Context) }} {{ json $event.Details }} html ($event.Details.Html $.Context) }} {{ json $event.Details }}
</li> </li>
{{- end}} {{- end}}

View File

@ -0,0 +1,35 @@
{{template "layout.html" .}}
{{define "title"}}Regions{{end}}
{{define "content"}}
<h3>Regions</h3>
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
{{- range $t, $v := .}}
<button class="nav-link{{ ifFirst $ $t " active" }}" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button"
role="tab">{{$t}} ({{ len $v }})</button>
{{- end}}
</div>
</nav>
<div class="tab-content" id="nav-tabContent">
{{- range $t, $v := . }}
<div class="tab-pane{{ ifFirst $ $t " active" }}" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<table>
<tr>
<th width="100%">Name</th>
<th>Size</th>
</tr>
{{- range $v }}{{- if not (eq .Name "") }}
<tr>
<td>{{ region .Id }}</td>
<td></td>
</tr>
{{- end}}{{- end}}
</table>
</div>
{{- end}}
</div>
{{- end }}

View File

@ -0,0 +1,35 @@
{{template "layout.html" .}}
{{define "title"}}Sites{{end}}
{{define "content"}}
<h3>Sites</h3>
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
{{- range $t, $v := .}}
<button class="nav-link{{ ifFirst $ $t " active" }}" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button"
role="tab">{{$t}} ({{ len $v }})</button>
{{- end}}
</div>
</nav>
<div class="tab-content" id="nav-tabContent">
{{- range $t, $v := . }}
<div class="tab-pane{{ ifFirst $ $t " active" }}" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<table>
<tr>
<th width="100%">Name</th>
<th>Size</th>
</tr>
{{- range $v }}{{- if not (eq .Name "") }}
<tr>
<td>{{ site .Id }}</td>
<td></td>
</tr>
{{- end}}{{- end}}
</table>
</div>
{{- end}}
</div>
{{- end }}

View File

@ -0,0 +1,35 @@
{{template "layout.html" .}}
{{define "title"}}World Constructions{{end}}
{{define "content"}}
<h3>World Constructions</h3>
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
{{- range $t, $v := .}}
<button class="nav-link{{ ifFirst $ $t " active" }}" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button"
role="tab">{{$t}} ({{ len $v }})</button>
{{- end}}
</div>
</nav>
<div class="tab-content" id="nav-tabContent">
{{- range $t, $v := . }}
<div class="tab-pane{{ ifFirst $ $t " active" }}" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<table>
<tr>
<th width="100%">Name</th>
<th>Size</th>
</tr>
{{- range $v }}{{- if not (eq .Name "") }}
<tr>
<td>{{ worldconstruction .Id }}</td>
<td></td>
</tr>
{{- end}}{{- end}}
</table>
</div>
{{- end}}
</div>
{{- end }}

View File

@ -0,0 +1,35 @@
{{template "layout.html" .}}
{{define "title"}}Written Contents{{end}}
{{define "content"}}
<h3>Written Contents</h3>
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
{{- range $t, $v := .}}
<button class="nav-link{{ ifFirst $ $t " active" }}" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button"
role="tab">{{$t}} ({{ len $v }})</button>
{{- end}}
</div>
</nav>
<div class="tab-content" id="nav-tabContent">
{{- range $t, $v := . }}
<div class="tab-pane{{ ifFirst $ $t " active" }}" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
<table>
<tr>
<th width="100%">Name</th>
<th>Size</th>
</tr>
{{- range $v }}{{- if not (eq .Name "") }}
<tr>
<td>{{ writtencontent .Id }}</td>
<td></td>
</tr>
{{- end}}{{- end}}
</table>
</div>
{{- end}}
</div>
{{- end }}