summaryrefslogtreecommitdiff
path: root/internal/router
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2025-04-26 15:03:05 +0200
committerLibravatar GitHub <noreply@github.com>2025-04-26 15:03:05 +0200
commitf7323c065a086533ce8c7f0f0cb3f69a80539992 (patch)
treeba1451f4d1c1841bcc0867599673d9527c31f2bf /internal/router
parent[performance] rewrite timelines to rely on new timeline cache type (#3941) (diff)
downloadgotosocial-f7323c065a086533ce8c7f0f0cb3f69a80539992.tar.xz
[feature] Update attachment format, receive + send `focalPoint` prop + use it on the frontend (#4052)
* [feature] Update attachment format, receive + send `focalPoint` prop + use it on the frontend * whoops * boop * restore function signature of ExtractAttachments
Diffstat (limited to 'internal/router')
-rw-r--r--internal/router/template.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/internal/router/template.go b/internal/router/template.go
index 51c0c4960..89b7086b2 100644
--- a/internal/router/template.go
+++ b/internal/router/template.go
@@ -136,6 +136,7 @@ func LoadTemplates(engine *gin.Engine) error {
var funcMap = template.FuncMap{
"add": add,
"acctInstance": acctInstance,
+ "objectPosition": objectPosition,
"demojify": demojify,
"deref": deref,
"emojify": emojify,
@@ -365,3 +366,12 @@ func deref(i any) any {
return vOf.Elem()
}
+
+// objectPosition formats the given focus coordinates to a
+// string suitable for use as a css object-position value.
+func objectPosition(focusX float32, focusY float32) string {
+ const fmts = "%.2f"
+ xPos := ((focusX / 2) + .5) * 100
+ yPos := ((focusY / -2) + .5) * 100
+ return fmt.Sprintf(fmts, xPos) + "%" + " " + fmt.Sprintf(fmts, yPos) + "%"
+}