Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backend/model/model.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion backend/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,15 @@ func StartServer(config *Config, world *model.DfWorld, static embed.FS) error {
})

srv.RegisterWorldResourcePage("/danceform/{id}", "artform.html", func(id int) any { return srv.context.world.DanceForms[id] })
srv.RegisterWorldResourcePage("/popover/danceform/{id}", "popoverDanceForm.html", func(id int) any { return srv.context.world.DanceForms[id] })
srv.RegisterWorldResourcePage("/musicalform/{id}", "artform.html", func(id int) any { return srv.context.world.MusicalForms[id] })
srv.RegisterWorldResourcePage("/popover/musicalform/{id}", "popoverMusicalForm.html", func(id int) any { return srv.context.world.MusicalForms[id] })
srv.RegisterWorldResourcePage("/poeticform/{id}", "artform.html", func(id int) any { return srv.context.world.PoeticForms[id] })
srv.RegisterWorldResourcePage("/popover/poeticform/{id}", "popoverPoeticForm.html", func(id int) any { return srv.context.world.PoeticForms[id] })

srv.RegisterWorldPage("/writtencontents", "writtencontents.html", func(p Parms) any { return groupByType(srv.context.world.WrittenContents) })
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("/popover/writtencontent/{id}", "popoverWrittenContent.html", func(id int) any { return srv.context.world.WrittenContents[id] })

srv.RegisterWorldPage("/hfs", "hfs.html", srv.searchHf)
srv.RegisterWorldResourcePage("/hf/{id}", "hf.html", func(id int) any { return srv.context.world.HistoricalFigures[id] })
Expand Down
4 changes: 2 additions & 2 deletions backend/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@
}).responseText;
}

$('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 () {
$('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,a.artform').each(function () {
var popover = new bootstrap.Popover($(this), { content: loadLinkPopoverData, trigger: "hover", placement: "top", html: true })
})
</script>
</body>

</html>
</html>
2 changes: 2 additions & 0 deletions backend/templates/popoverDanceForm.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{ danceForm .Id }}<br />
{{ .ShortDesc }}
2 changes: 2 additions & 0 deletions backend/templates/popoverMusicalForm.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{ musicalForm .Id }}<br />
{{ .ShortDesc }}
2 changes: 2 additions & 0 deletions backend/templates/popoverPoeticForm.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{ poeticForm .Id }}<br />
{{ .ShortDesc }}
27 changes: 27 additions & 0 deletions backend/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,30 @@ func Strip(html template.HTML) string {
func String(html template.HTML) string {
return string(html)
}

/*
ArtFormShortDesc

Gets a shorter description for the popovers by modifying the description data.

Note there is no way yet to highlight the
author, as that info is not tracked by the XML, and would need a more
intensive patch to the backend (keeping a map of art form -> author in
world context). Probably won't implement this for popovers unless I
get really really bored, as it's a massive pain for minimal gain.
*/
func ArtFormShortDesc(name string, desc string) string {
if len(strings.TrimSpace(desc)) == 0 {
return ""
}

// find where the title (plus "is") ends
i := len(name) + 3

j := strings.Index(desc, ".")
if j == -1 {
return desc // no period found; text is one sentence
}

return strings.TrimSpace(desc[i:j])
}