From a98e085031bedb53a9776031afde7073af81feaf Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Fri, 24 May 2019 10:52:05 +0300 Subject: Show git-notes (#6984) * Show git-notes * Make git-notes heading text localizable * Refactor git-notes data fetching to a separate function * Display the author and time of git notes * Move note bubble inside the commit bubble * Revert "Move note bubble inside the commit bubble" This reverts commit c0951fe0e3b4dea38064515546b1825c1bcf19e1. * Add test for git-notes * testing ui * Polish CSS * Apply suggestions from code review Co-Authored-By: Lauris BH --- modules/templates/helper.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'modules/templates') diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 24a383252b..098a642556 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -125,6 +125,7 @@ func NewFuncMap() []template.FuncMap { "RenderCommitMessage": RenderCommitMessage, "RenderCommitMessageLink": RenderCommitMessageLink, "RenderCommitBody": RenderCommitBody, + "RenderNote": RenderNote, "IsMultilineCommitMessage": IsMultilineCommitMessage, "ThemeColorMetaTag": func() string { return setting.UI.ThemeColorMetaTag @@ -392,6 +393,17 @@ func RenderCommitBody(msg, urlPrefix string, metas map[string]string) template.H return template.HTML(strings.Join(body[1:], "\n")) } +// RenderNote renders the contents of a git-notes file as a commit message. +func RenderNote(msg, urlPrefix string, metas map[string]string) template.HTML { + cleanMsg := template.HTMLEscapeString(msg) + fullMessage, err := markup.RenderCommitMessage([]byte(cleanMsg), urlPrefix, "", metas) + if err != nil { + log.Error("RenderNote: %v", err) + return "" + } + return template.HTML(string(fullMessage)) +} + // IsMultilineCommitMessage checks to see if a commit message contains multiple lines. func IsMultilineCommitMessage(msg string) bool { return strings.Count(strings.TrimSpace(msg), "\n") >= 1 -- cgit v1.2.3