identity page

This commit is contained in:
Robert Janetzko 2022-05-07 19:17:05 +00:00
parent 3ee0264c22
commit e5cd5bd3c2
16 changed files with 244 additions and 6 deletions

View File

@ -143,6 +143,7 @@ func (x *{{ $obj.Name }}) RelatedToDanceForm(id int) bool { return {{ $obj.Relat
func (x *{{ $obj.Name }}) RelatedToMusicalForm(id int) bool { return {{ $obj.RelatedToMusicalForm }} }
func (x *{{ $obj.Name }}) RelatedToPoeticForm(id int) bool { return {{ $obj.RelatedToPoeticForm }} }
func (x *{{ $obj.Name }}) RelatedToMountain(id int) bool { return {{ $obj.RelatedToMountain }} }
func (x *{{ $obj.Name }}) RelatedToIdentity(id int) bool { return {{ $obj.RelatedToIdentity }} }
{{- end }}
func (x *{{ $obj.Name }}) CheckFields() {
@ -473,6 +474,7 @@ var structureRegex, _ = regexp.Compile("(structure(_id)?)$")
var regionRegex, _ = regexp.Compile("(region_id|srid)$")
var worldConstructionRegex, _ = regexp.Compile("(wcid)$")
var writtenContentRegex, _ = regexp.Compile("^wc_id$")
var identityRegex, _ = regexp.Compile("identity")
var noRegex, _ = regexp.Compile("^XXXXX$")
@ -512,6 +514,9 @@ func (obj Object) RelatedToPoeticForm() string {
func (obj Object) RelatedToMountain() string {
return obj.Related("mountain", noRegex, "")
}
func (obj Object) RelatedToIdentity() string {
return obj.Related("identity", identityRegex, "")
}
func (obj Object) Related(relation string, regex *regexp.Regexp, init string) string {
var list []string

View File

@ -190,6 +190,12 @@
"Name": "Parts",
"Type": "[]int"
}
],
"River": [
{
"Name": "Id",
"Type": "int"
}
]
}
}

View File

@ -19,6 +19,7 @@ type HistoricalEventDetails interface {
RelatedToMusicalForm(int) bool
RelatedToPoeticForm(int) bool
RelatedToMountain(int) bool
RelatedToIdentity(int) bool
Html(*Context) string
Type() string
}
@ -68,6 +69,8 @@ func NewEventList(world *DfWorld, obj any) *EventList {
el.Events = world.EventsMatching(func(d HistoricalEventDetails) bool { return d.RelatedToPoeticForm(x.Id()) })
case *MountainPeak:
el.Events = world.EventsMatching(func(d HistoricalEventDetails) bool { return d.RelatedToMountain(x.Id()) })
case *Identity:
el.Events = world.EventsMatching(func(d HistoricalEventDetails) bool { return d.RelatedToIdentity(x.Id()) })
case []*HistoricalEvent:
el.Events = x
case []int:

View File

@ -274,3 +274,7 @@ func (r *Reference) Html(c *Context) template.HTML {
}
return template.HTML(r.Type_.String())
}
func (r *River) Id() int {
return r.Id_
}

View File

@ -31,6 +31,7 @@ var LinkCollection = func(w *DfWorld, id int) template.HTML { return template.HT
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 LinkIdentity = func(w *DfWorld, id int) template.HTML { return template.HTML((&Context{World: w}).identity(id)) }
var AddMapLandmass = func(w *DfWorld, id int) template.HTML {
if x, ok := w.Landmasses[id]; ok {

File diff suppressed because it is too large Load Diff

View File

@ -10,6 +10,10 @@ import (
)
func (w *DfWorld) process() {
for id, r := range w.Rivers {
r.Id_ = id
}
w.addRelationshipEvents()
// set site in structure
@ -140,6 +144,12 @@ func (w *DfWorld) processEvents() {
structure.Ruin = true
}
}
case *HistoricalEventAssumeIdentity:
if hf, ok := w.HistoricalFigures[d.TricksterHfid]; ok {
if id, ok := w.Identities[d.IdentityId]; ok {
id.HistfigId = hf.Id_
}
}
}
}
}

View File

@ -115,6 +115,10 @@ func StartServer(config *Config, world *model.DfWorld, static embed.FS) error {
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("/identities", "identities.html", func(p Parms) any { return srv.context.world.Identities })
srv.RegisterWorldResourcePage("/identity/{id}", "identity.html", func(id int) any { return srv.context.world.Identities[id] })
srv.RegisterWorldResourcePage("/popover/identity/{id}", "popoverIdentity.html", func(id int) any { return srv.context.world.Identities[id] })
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] })

View File

@ -34,6 +34,7 @@ func (srv *DfServer) LoadTemplates() {
"hfShort": func(id int) template.HTML { return model.LinkHfShort(srv.context.world, id) },
"getHf": func(id int) *model.HistoricalFigure { return srv.context.world.HistoricalFigures[id] },
"hfList": func(ids []int) template.HTML { return model.LinkHfList(srv.context.world, ids) },
"identity": func(id int) template.HTML { return model.LinkIdentity(srv.context.world, id) },
"entity": func(id int) template.HTML { return model.LinkEntity(srv.context.world, id) },
"getEntity": func(id int) *model.Entity { return srv.context.world.Entities[id] },
"site": func(id int) template.HTML { return model.LinkSite(srv.context.world, id) },

View File

@ -0,0 +1,21 @@
{{template "layout.html" .}}
{{define "title"}}Identities{{end}}
{{define "content"}}
<h3>Identities</h3>
<table class="table table-hover table-sm table-borderless object-table">
<tr>
<th>Name</th>
<th>Used By</th>
</tr>
{{- range . }}{{- if not (eq .Name "") }}
<tr>
<td>{{ identity .Id }}</td>
<td>{{ hf .HistfigId }}</td>
</tr>
{{- end}}{{- end}}
</table>
{{- end }}

View File

@ -0,0 +1,16 @@
{{template "layout.html" .}}
{{define "title"}}{{ title .Name }}{{end}}
{{define "content"}}
<h3>{{ title .Name }}</h3>
<p>
identity used by {{ hf .HistfigId }}
</p>
<h5>Events</h5>
{{ template "events.html" events . }}
<p>{{ json . }}</p>
{{- end }}

View File

@ -42,10 +42,11 @@
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<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="/entities">Entities</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="/hfs">Historical Figures</a></li>
<li><a class="dropdown-item" href="/identities">Identities</a></li>
<li><a class="dropdown-item" href="/worldconstructions">World Constructions</a></li>
<li><a class="dropdown-item" href="/artifacts">Artifacts</a></li>
<li><a class="dropdown-item" href="/artforms">Art Forms</a></li>
@ -100,7 +101,7 @@
}).responseText;
}
$('a.entity,a.hf,a.region,a.site,a.structure,a.worldconstruction,a.artifact,a.writtencontent,a.collection').each(function () {
$('a.entity,a.hf,a.region,a.site,a.structure,a.worldconstruction,a.artifact,a.writtencontent,a.collection,a.landmass,a.mountain,a.identity,a.river').each(function () {
var popover = new bootstrap.Popover($(this), { content: loadLinkPopoverData, trigger: "hover", placement: "top", html: true })
})
</script>

View File

@ -0,0 +1,2 @@
{{ identity .Id }}<br />
identity used by {{ hf .HistfigId }}

View File

@ -1,2 +1,2 @@
{{ region .Id }}<br />
{{ mountain .Id }}<br />
{{ if .IsVolcano }}volcano{{else}}mountain{{end}}

View File

@ -1,2 +1,2 @@
{{ region .Id }}<br />
{{ river .Id }}<br />
river

View File

@ -10,5 +10,11 @@
"path": "backend"
}
],
"settings": {}
"settings": {},
"extensions": {
"recommendations": [
"jinliming2.vscode-go-template",
"golang.go"
]
}
}