diff options
author | Vladimir Panteleev <CyberShadow@users.noreply.github.com> | 2019-05-24 10:52:05 +0300 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2019-05-24 10:52:05 +0300 |
commit | a98e085031bedb53a9776031afde7073af81feaf (patch) | |
tree | 3e460d74b7fec8729c8c7422799d485cb7c908ad /modules/templates | |
parent | d5a98a29690e13f717fb72e8635fbea57e58f546 (diff) | |
download | gitea-a98e085031bedb53a9776031afde7073af81feaf.tar.gz gitea-a98e085031bedb53a9776031afde7073af81feaf.zip |
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 <lauris@nix.lv>
Diffstat (limited to 'modules/templates')
-rw-r--r-- | modules/templates/helper.go | 12 |
1 files changed, 12 insertions, 0 deletions
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 |