diff --git a/appview/pages/funcmap.go b/appview/pages/funcmap.go index 0b5fd2318..0feb7e155 100644 --- a/appview/pages/funcmap.go +++ b/appview/pages/funcmap.go @@ -18,6 +18,7 @@ import ( "reflect" "strings" "time" + "unicode/utf8" "github.com/alecthomas/chroma/v2" chromahtml "github.com/alecthomas/chroma/v2/formatters/html" @@ -333,6 +334,12 @@ func (p *Pages) funcMap() template.FuncMap { "nl2br": func(text string) template.HTML { return template.HTML(strings.ReplaceAll(template.HTMLEscapeString(text), "\n", "
")) }, + "isLongBody": func(text string) bool { + return utf8.RuneCountInString(text) > 800 || + len(strings.Split(text, "\n\n")) > 4 || + strings.Contains(text, "```") || + strings.Contains(text, "![") + }, "unwrapText": func(text string) string { paragraphs := strings.Split(text, "\n\n") diff --git a/appview/pages/templates/fragments/comment/commentBody.html b/appview/pages/templates/fragments/comment/commentBody.html index 3bd7b8c18..a551ffcf6 100644 --- a/appview/pages/templates/fragments/comment/commentBody.html +++ b/appview/pages/templates/fragments/comment/commentBody.html @@ -6,7 +6,7 @@ (dict "Reactions" .Reactions "UserReacted" .UserReacted "ThreadAt" .Comment.FeedCommentAtUri - "HideIfEmpty" true) }} + "ShowPicker" (isLongBody .Comment.Body.Text)) }} {{ else }}
[deleted by author]
{{ end }} diff --git a/appview/pages/templates/repo/fragments/reaction.html b/appview/pages/templates/repo/fragments/reaction.html index cb1f8b485..f85f3081d 100644 --- a/appview/pages/templates/repo/fragments/reaction.html +++ b/appview/pages/templates/repo/fragments/reaction.html @@ -1,6 +1,6 @@ {{ define "repo/fragments/reaction" }}