appview/pages: special-case for sub-second times in timeAgo formats #568

merged
opened by oppi.li targeting master from push-wsxnywmtsnrp

when time is formatted in "timeago" formats, it can be displayed as "edited now ago" when the time is sub-second. this case is now specialized to omit the "ago" to result in "edited now".

Signed-off-by: oppiliappan me@oppi.li

Changed files
+6 -1
appview
pages
templates
repo
fragments
+6 -1
appview/pages/templates/repo/fragments/shortTimeAgo.html
···
{{ define "repo/fragments/shortTimeAgo" }}
-
{{ template "repo/fragments/timeWrapper" (dict "Time" . "Content" (print (. | shortRelTimeFmt) " ago")) }}
+
{{ $formatted := shortRelTimeFmt . }}
+
{{ $content := printf "%s ago" $formatted }}
+
{{ if eq $formatted "now" }}
+
{{ $content = "now" }}
+
{{ end }}
+
{{ template "repo/fragments/timeWrapper" (dict "Time" . "Content" $content) }}
{{ end }}