-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expandable commit bodies #2980
Expandable commit bodies #2980
Changes from 2 commits
f4a48d2
67fde4d
524f957
053cc1d
7afb927
23b92b8
7f25cd8
65e6a19
ed572c2
3767880
2856f9e
76e640d
f325cf2
a452635
a47c4c1
8f02f61
63fec45
e521e8a
f55878c
083af01
f7592bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,6 +110,9 @@ func NewFuncMap() []template.FuncMap { | |
}, | ||
"RenderCommitMessage": RenderCommitMessage, | ||
"RenderCommitMessageLink": RenderCommitMessageLink, | ||
"RenderCommitBody": RenderCommitBody, | ||
"RenderCommitBodyLink": RenderCommitBodyLink, | ||
"IsMultilineCommitMessage": IsMultilineCommitMessage, | ||
"ThemeColorMetaTag": func() string { | ||
return setting.UI.ThemeColorMetaTag | ||
}, | ||
|
@@ -278,6 +281,41 @@ func renderCommitMessage(msg string, opts markup.RenderIssueIndexPatternOptions) | |
return template.HTML(msgLines[0]) | ||
} | ||
|
||
func RenderCommitBody(msg, urlPrefix string, metas map[string]string) template.HTML { | ||
return renderCommitBody(msg, markup.RenderIssueIndexPatternOptions{ | ||
URLPrefix: urlPrefix, | ||
Metas: metas, | ||
}) | ||
} | ||
|
||
func RenderCommitBodyLink(msg, urlPrefix string, urlDefault string, metas map[string]string) template.HTML { | ||
return renderCommitMessage(msg, markup.RenderIssueIndexPatternOptions{ | ||
DefaultURL: urlDefault, | ||
URLPrefix: urlPrefix, | ||
Metas: metas, | ||
}) | ||
} | ||
|
||
func renderCommitBody(msg string, opts markup.RenderIssueIndexPatternOptions) template.HTML { | ||
cleanMsg := template.HTMLEscapeString(msg) | ||
fullMessage := string(markup.RenderIssueIndexPattern([]byte(cleanMsg), opts)) | ||
msgLines := strings.Split(strings.TrimSpace(fullMessage), "\n") | ||
if len(msgLines) == 0 { | ||
return template.HTML("") | ||
} | ||
body := msgLines[1:] | ||
return template.HTML(strings.Join(body, "\n")) | ||
} | ||
|
||
func IsMultilineCommitMessage(msg string) bool { | ||
msgLines := strings.Split(strings.TrimSpace(msg), "\n") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just do
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sweet, I was looking for a better way to do that. |
||
if len(msgLines) > 1 { | ||
return true | ||
} else { | ||
return false | ||
} | ||
} | ||
|
||
// Actioner describes an action | ||
type Actioner interface { | ||
GetOpType() models.ActionType | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2016,3 +2016,7 @@ function initFilterBranchTagDropdown(selector) { | |
}); | ||
}); | ||
} | ||
|
||
$(".commit-button").click(function() { | ||
$(this).next().toggle(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not a JS expert, but this seems fragile. What if we add a DOM element between the commit button and the commit body? Perhaps it would be better to select for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried doing $(".commit-button").click(function() {
$("commit-body").toggle(); But that opens and closes all of the commit messages, not just the one selected. All the documentation I could find from both JQuery themselves and online used this method, otherwise I think we'd have to use one of those JQuery-Toggle libraries. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Try: $(".commit-button").on('click', function() {
$(this).parent().find('.commit-body').toggle();
}); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I'll give it a go later today. |
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function does not seems to be used anywhere, so should be dropped
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good! I just copied the
RenderCommit
functions and changed them a tiny bit.