geography
This commit is contained in:
parent
97cdf624be
commit
bb97b91b7c
|
@ -170,21 +170,34 @@ func (c *Context) place(structureId, siteId int, sitePrefix string, regionId int
|
||||||
|
|
||||||
func (c *Context) mountain(id int) string {
|
func (c *Context) mountain(id int) string {
|
||||||
if x, ok := c.World.MountainPeaks[id]; ok {
|
if x, ok := c.World.MountainPeaks[id]; ok {
|
||||||
return fmt.Sprintf(`<a class="mountain" href="/site/%d">%s</a>`, x.Id(), util.Title(x.Name()))
|
return fmt.Sprintf(`<a class="mountain" href="/mountain/%d"><i class="fa-solid %s"></i> %s</a>`,
|
||||||
|
x.Id(), util.If(x.IsVolcano, "fa-volcano", "fa-mountain"), util.Title(x.Name()))
|
||||||
}
|
}
|
||||||
return "UNKNOWN MOUNTAIN"
|
return "UNKNOWN MOUNTAIN"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Context) landmass(id int) string {
|
||||||
|
if x, ok := c.World.Landmasses[id]; ok {
|
||||||
|
return fmt.Sprintf(`<a class="landmass" href="/landmass/%d">%s</a>`, x.Id(), util.Title(x.Name()))
|
||||||
|
}
|
||||||
|
return "UNKNOWN LANDMASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Context) river(id int) string {
|
||||||
|
x := c.World.Rivers[id]
|
||||||
|
return fmt.Sprintf(`<a class="river" href="/river/%d">%s</a>`, id, util.Title(x.Name()))
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Context) identity(id int) string {
|
func (c *Context) identity(id int) string {
|
||||||
if x, ok := c.World.Identities[id]; ok {
|
if x, ok := c.World.Identities[id]; ok {
|
||||||
return fmt.Sprintf(`<a class="identity" href="/region/%d">%s</a>`, x.Id(), util.Title(x.Name()))
|
return fmt.Sprintf(`<a class="identity" href="/identity/%d">%s</a>`, x.Id(), util.Title(x.Name()))
|
||||||
}
|
}
|
||||||
return "UNKNOWN IDENTITY"
|
return "UNKNOWN IDENTITY"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) fullIdentity(id int) string {
|
func (c *Context) fullIdentity(id int) string {
|
||||||
if x, ok := c.World.Identities[id]; ok {
|
if x, ok := c.World.Identities[id]; ok {
|
||||||
return fmt.Sprintf(`"the %s <a class="identity" href="/region/%d">%s</a> of %s"`, x.Profession.String(), x.Id(), util.Title(x.Name()), c.entity(x.EntityId))
|
return fmt.Sprintf(`"the %s <a class="identity" href="/identity/%d">%s</a> of %s"`, x.Profession.String(), x.Id(), util.Title(x.Name()), c.entity(x.EntityId))
|
||||||
}
|
}
|
||||||
return "UNKNOWN IDENTITY"
|
return "UNKNOWN IDENTITY"
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,10 @@ func (e *Entity) Position(id int) *EntityPosition {
|
||||||
return &EntityPosition{Name_: "UNKNOWN POSITION"}
|
return &EntityPosition{Name_: "UNKNOWN POSITION"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *Entity) PositionByIndex(index int) *EntityPosition {
|
||||||
|
return e.EntityPosition[len(e.EntityPosition)-1-index]
|
||||||
|
}
|
||||||
|
|
||||||
func (p *EntityPosition) GenderName(hf *HistoricalFigure) string {
|
func (p *EntityPosition) GenderName(hf *HistoricalFigure) string {
|
||||||
if hf.Female() && p.NameFemale != "" {
|
if hf.Female() && p.NameFemale != "" {
|
||||||
return p.NameFemale
|
return p.NameFemale
|
||||||
|
|
|
@ -24,6 +24,9 @@ var LinkMusicalForm = func(w *DfWorld, id int) template.HTML { return template.H
|
||||||
var LinkPoeticForm = func(w *DfWorld, id int) template.HTML { return template.HTML((&Context{World: w}).poeticForm(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)) }
|
var LinkWrittenContent = func(w *DfWorld, id int) template.HTML { return template.HTML((&Context{World: w}).writtenContent(id)) }
|
||||||
var LinkCollection = func(w *DfWorld, id int) template.HTML { return template.HTML((&Context{World: w}).collection(id)) }
|
var LinkCollection = func(w *DfWorld, id int) template.HTML { return template.HTML((&Context{World: w}).collection(id)) }
|
||||||
|
var LinkMountain = func(w *DfWorld, id int) template.HTML { return template.HTML((&Context{World: w}).mountain(id)) }
|
||||||
|
var LinkLandmass = func(w *DfWorld, id int) template.HTML { return template.HTML((&Context{World: w}).landmass(id)) }
|
||||||
|
var LinkRiver = func(w *DfWorld, id int) template.HTML { return template.HTML((&Context{World: w}).river(id)) }
|
||||||
|
|
||||||
var AddMapSite = func(w *DfWorld, id int) template.HTML {
|
var AddMapSite = func(w *DfWorld, id int) template.HTML {
|
||||||
if site, ok := w.Sites[id]; ok {
|
if site, ok := w.Sites[id]; ok {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/robertjanetzko/LegendsBrowser2/backend/util"
|
"github.com/robertjanetzko/LegendsBrowser2/backend/util"
|
||||||
|
@ -57,6 +56,21 @@ func (w *DfWorld) processEvents() {
|
||||||
w.addEntitySite(d.SiteCivId, d.SiteId)
|
w.addEntitySite(d.SiteCivId, d.SiteId)
|
||||||
w.addEntitySite(d.SiteCivId, d.SiteId)
|
w.addEntitySite(d.SiteCivId, d.SiteId)
|
||||||
w.Sites[d.SiteId].Ruin = false
|
w.Sites[d.SiteId].Ruin = false
|
||||||
|
case *HistoricalEventAddHfEntityLink:
|
||||||
|
if d.Link == HistoricalEventAddHfEntityLinkLink_Position {
|
||||||
|
if hf, ok := w.HistoricalFigures[d.Hfid]; ok {
|
||||||
|
for _, l := range hf.EntityPositionLink {
|
||||||
|
if l.EntityId == d.CivId && l.StartYear == e.Year {
|
||||||
|
l.PositionProfileId = d.PositionId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, l := range hf.EntityFormerPositionLink {
|
||||||
|
if l.EntityId == d.CivId && l.StartYear == e.Year {
|
||||||
|
l.PositionProfileId = d.PositionId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +158,6 @@ func (w *DfWorld) addEntitySite(entityId, siteId int) {
|
||||||
|
|
||||||
func (w *DfWorld) addRelationshipEvents() {
|
func (w *DfWorld) addRelationshipEvents() {
|
||||||
for _, r := range w.HistoricalEventRelationships {
|
for _, r := range w.HistoricalEventRelationships {
|
||||||
fmt.Println(r)
|
|
||||||
w.HistoricalEvents[r.Event] = &HistoricalEvent{
|
w.HistoricalEvents[r.Event] = &HistoricalEvent{
|
||||||
Id_: r.Event,
|
Id_: r.Event,
|
||||||
Year: r.Year,
|
Year: r.Year,
|
||||||
|
|
|
@ -50,6 +50,22 @@ func StartServer(world *model.DfWorld, static embed.FS) error {
|
||||||
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.RegisterWorldResourcePage("/popover/entity/{id}", "popoverEntity.html", func(id int) any { return srv.context.world.Entities[id] })
|
||||||
|
|
||||||
|
srv.RegisterWorldPage("/geography", "geography.html", func(p Parms) any {
|
||||||
|
return &struct {
|
||||||
|
Regions map[string][]*model.Region
|
||||||
|
Landmasses map[string][]*model.Landmass
|
||||||
|
MountainPeaks map[string][]*model.MountainPeak
|
||||||
|
Rivers map[string][]*model.River
|
||||||
|
}{
|
||||||
|
Regions: singleGroup(srv.context.world.Regions, "region"),
|
||||||
|
Landmasses: singleGroup(srv.context.world.Landmasses, "landmass"),
|
||||||
|
MountainPeaks: singleGroup(srv.context.world.MountainPeaks, "mountain"),
|
||||||
|
Rivers: map[string][]*model.River{
|
||||||
|
"rivers": srv.context.world.Rivers,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
srv.RegisterWorldPage("/regions", "regions.html", func(p Parms) any { return groupByType(srv.context.world.Regions) })
|
srv.RegisterWorldPage("/regions", "regions.html", func(p Parms) any { return groupByType(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.RegisterWorldResourcePage("/popover/region/{id}", "popoverRegion.html", func(id int) any { return srv.context.world.Regions[id] })
|
||||||
|
@ -194,6 +210,10 @@ func flatGrouped[K comparable, U any, V namedTyped](input map[K]U, mapper func(U
|
||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func singleGroup[K comparable, T model.Named](input map[K]T, group string) map[string][]T {
|
||||||
|
return groupBy(input, func(t T) string { return group }, func(t T) bool { return t.Name() != "" }, func(t T) string { return t.Name() })
|
||||||
|
}
|
||||||
|
|
||||||
func groupByType[K comparable, T namedTyped](input map[K]T) map[string][]T {
|
func groupByType[K comparable, T namedTyped](input map[K]T) map[string][]T {
|
||||||
return groupBy(input, func(t T) string { return t.Type() }, func(t T) bool { return t.Name() != "" }, func(t T) string { return t.Name() })
|
return groupBy(input, func(t T) string { return t.Type() }, func(t T) bool { return t.Name() != "" }, func(t T) string { return t.Name() })
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,9 @@ func (srv *DfServer) LoadTemplates() {
|
||||||
"musicalForm": func(id int) template.HTML { return model.LinkMusicalForm(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) },
|
"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) },
|
"writtenContent": func(id int) template.HTML { return model.LinkWrittenContent(srv.context.world, id) },
|
||||||
"landmass": func(id int) template.HTML { return model.LinkWrittenContent(srv.context.world, id) }, // TODO
|
"landmass": func(id int) template.HTML { return model.LinkLandmass(srv.context.world, id) },
|
||||||
"mountain": func(id int) template.HTML { return model.LinkWrittenContent(srv.context.world, id) }, // TODO
|
"mountain": func(id int) template.HTML { return model.LinkMountain(srv.context.world, id) },
|
||||||
|
"river": func(id int) template.HTML { return model.LinkRiver(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)
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,6 +2,10 @@ a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.popover {
|
||||||
|
max-width: fit-content;
|
||||||
|
}
|
||||||
|
|
||||||
.object-table td {
|
.object-table td {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
{{template "layout.html" .}}
|
{{template "layout.html" .}}
|
||||||
|
|
||||||
{{define "title"}}Artifacts{{end}}
|
{{define "title"}}Art Forms{{end}}
|
||||||
|
|
||||||
{{define "content"}}
|
{{define "content"}}
|
||||||
<h3>Artifacts</h3>
|
<h3>Art Forms</h3>
|
||||||
|
|
||||||
<nav>
|
<nav>
|
||||||
<div class="nav nav-tabs" id="nav-tab" role="tablist">
|
<div class="nav nav-tabs" id="nav-tab" role="tablist">
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
{{template "layout.html" .}}
|
||||||
|
|
||||||
|
{{define "title"}}Geography{{end}}
|
||||||
|
|
||||||
|
{{define "content"}}
|
||||||
|
<h3>Geography</h3>
|
||||||
|
|
||||||
|
<nav>
|
||||||
|
<div class="nav nav-tabs" id="nav-tab" role="tablist">
|
||||||
|
{{- range $t, $v := .Regions }}
|
||||||
|
<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 := .Landmasses }}
|
||||||
|
<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 := .MountainPeaks }}
|
||||||
|
<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 := .Rivers }}
|
||||||
|
<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 := .Regions }}
|
||||||
|
<div class="tab-pane active" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
|
||||||
|
<table class="table table-hover table-sm table-borderless">
|
||||||
|
<tr>
|
||||||
|
<th width="100%">Name</th>
|
||||||
|
<th>Type</th>
|
||||||
|
</tr>
|
||||||
|
{{- range $v }}{{- if not (eq .Name "") }}
|
||||||
|
<tr>
|
||||||
|
<td>{{ region .Id }}</td>
|
||||||
|
<td>{{ .Type }}</td>
|
||||||
|
</tr>
|
||||||
|
{{- end}}{{- end}}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{{- end}}
|
||||||
|
{{- range $t, $v := .Landmasses }}
|
||||||
|
<div class="tab-pane" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
|
||||||
|
<table class="table table-hover table-sm table-borderless">
|
||||||
|
<tr>
|
||||||
|
<th width="100%">Name</th>
|
||||||
|
<th>Size</th>
|
||||||
|
</tr>
|
||||||
|
{{- range $v }}{{- if not (eq .Name "") }}
|
||||||
|
<tr>
|
||||||
|
<td>{{ landmass .Id }}</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
{{- end}}{{- end}}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{{- end}}
|
||||||
|
{{- range $t, $v := .MountainPeaks }}
|
||||||
|
<div class="tab-pane" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
|
||||||
|
<table class="table table-hover table-sm table-borderless object-table">
|
||||||
|
<tr>
|
||||||
|
<th width="100%">Name</th>
|
||||||
|
<th>Type</th>
|
||||||
|
</tr>
|
||||||
|
{{- range $v }}{{- if not (eq .Name "") }}
|
||||||
|
<tr>
|
||||||
|
<td>{{ mountain .Id }}</td>
|
||||||
|
<td>{{ if .IsVolcano }}volcano{{else}}mountain{{end}}</td>
|
||||||
|
</tr>
|
||||||
|
{{- end}}{{- end}}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{{- end}}
|
||||||
|
{{- range $t, $v := .Rivers }}
|
||||||
|
<div class="tab-pane" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
|
||||||
|
<table class="table table-hover table-sm table-borderless object-table">
|
||||||
|
<tr>
|
||||||
|
<th width="100%">Name</th>
|
||||||
|
<th>Size</th>
|
||||||
|
</tr>
|
||||||
|
{{- range $i, $r := $v }}{{- if not (eq .Name "") }}
|
||||||
|
<tr>
|
||||||
|
<td>{{ river $i }}</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
{{- end}}{{- end}}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{{- end}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{- end }}
|
|
@ -29,13 +29,14 @@
|
||||||
<ul>
|
<ul>
|
||||||
{{- range $i := .EntityFormerPositionLink }}
|
{{- range $i := .EntityFormerPositionLink }}
|
||||||
<li>
|
<li>
|
||||||
{{ ((getEntity $i.EntityId).Position $i.PositionProfileId).Name }} of {{ entity $i.EntityId }} ({{
|
{{ ((getEntity $i.EntityId).Position $i.PositionProfileId).GenderName $ }} of {{ entity $i.EntityId }} ({{
|
||||||
$i.StartYear }} - {{ $i.EndYear }})
|
$i.StartYear }} - {{ $i.EndYear }})
|
||||||
</li>
|
</li>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- range $i := .EntityPositionLink }}
|
{{- range $i := .EntityPositionLink }}
|
||||||
<li>
|
<li>
|
||||||
of {{ entity $i.EntityId }}
|
{{ ((getEntity $i.EntityId).Position $i.PositionProfileId).GenderName $ }} of {{ entity $i.EntityId }} (since {{
|
||||||
|
$i.StartYear }})
|
||||||
</li>
|
</li>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -41,9 +41,9 @@
|
||||||
Objects
|
Objects
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
|
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||||
<li><a class="dropdown-item" href="/entities">Entities</a></li>
|
<li><a class="dropdown-item" href="/geography">Geography</a></li>
|
||||||
<li><a class="dropdown-item" href="/hfs">Historical Figures</a></li>
|
<li><a class="dropdown-item" href="/hfs">Historical Figures</a></li>
|
||||||
<li><a class="dropdown-item" href="/regions">Regions</a></li>
|
<li><a class="dropdown-item" href="/entities">Entities</a></li>
|
||||||
<li><a class="dropdown-item" href="/sites">Sites</a></li>
|
<li><a class="dropdown-item" href="/sites">Sites</a></li>
|
||||||
<li><a class="dropdown-item" href="/structures">Structures</a></li>
|
<li><a class="dropdown-item" href="/structures">Structures</a></li>
|
||||||
<li><a class="dropdown-item" href="/worldconstructions">World Constructions</a></li>
|
<li><a class="dropdown-item" href="/worldconstructions">World Constructions</a></li>
|
||||||
|
|
|
@ -4,3 +4,20 @@
|
||||||
<i class="fa-solid fa-mars fa-xs"></i>
|
<i class="fa-solid fa-mars fa-xs"></i>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{ .Race }} (*{{ .BirthYear }}{{ if ge .DeathYear 0 }} †{{ .DeathYear }}{{ end }})
|
{{ .Race }} (*{{ .BirthYear }}{{ if ge .DeathYear 0 }} †{{ .DeathYear }}{{ end }})
|
||||||
|
|
||||||
|
{{- if or (ne 0 (len .EntityFormerPositionLink)) (ne 0 (len .EntityPositionLink)) }}
|
||||||
|
<ul class="mb-0">
|
||||||
|
{{- range $i := .EntityPositionLink }}
|
||||||
|
<li>
|
||||||
|
{{ ((getEntity $i.EntityId).Position $i.PositionProfileId).GenderName $ }} of {{ entity $i.EntityId }} (since {{
|
||||||
|
$i.StartYear }})
|
||||||
|
</li>
|
||||||
|
{{- end }}
|
||||||
|
{{- range $i := .EntityFormerPositionLink }}
|
||||||
|
<li>
|
||||||
|
{{ ((getEntity $i.EntityId).Position $i.PositionProfileId).GenderName $ }} of {{ entity $i.EntityId }} ({{
|
||||||
|
$i.StartYear }} - {{ $i.EndYear }})
|
||||||
|
</li>
|
||||||
|
{{- end }}
|
||||||
|
</ul>
|
||||||
|
{{- end }}
|
Loading…
Reference in New Issue