Add 'Reply' as translatable

Add CODE_COMMENT_LINES setting

Signed-off-by: Jonas Franz <info@jonasfranz.software>
This commit is contained in:
Jonas Franz 2018-05-31 15:23:15 +02:00 committed by Jonas Franz
parent 9a0c3947e0
commit c8c1e704ed
No known key found for this signature in database
GPG Key ID: 506AEEBE80BEDECD
5 changed files with 15 additions and 9 deletions

View File

@ -67,6 +67,8 @@ EXPLORE_PAGING_NUM = 20
ISSUE_PAGING_NUM = 10 ISSUE_PAGING_NUM = 10
; Number of maximum commits displayed in one activity feed ; Number of maximum commits displayed in one activity feed
FEED_MAX_COMMIT_NUM = 5 FEED_MAX_COMMIT_NUM = 5
; Number of line of codes shown for a code comment
CODE_COMMENT_LINES = 4
; Value of `theme-color` meta tag, used by Android >= 5.0 ; Value of `theme-color` meta tag, used by Android >= 5.0
; An invalid color like "none" or "disable" will have the default style ; An invalid color like "none" or "disable" will have the default style
; More info: https://developers.google.com/web/updates/2014/11/Support-for-theme-color-in-Chrome-39-for-Android ; More info: https://developers.google.com/web/updates/2014/11/Support-for-theme-color-in-Chrome-39-for-Android

View File

@ -396,7 +396,7 @@ func (c *Comment) AsDiff() (*Diff, error) {
if len(diff.Files) == 0 { if len(diff.Files) == 0 {
return nil, fmt.Errorf("no file found for comment ID: %d", c.ID) return nil, fmt.Errorf("no file found for comment ID: %d", c.ID)
} }
// Limit to 4 lines around comment line // Limit to CODE_COMMENT_LINES lines around comment line
for _, sec := range diff.Files[0].Sections { for _, sec := range diff.Files[0].Sections {
var searchedLineIdx int var searchedLineIdx int
for lineIdx, line := range sec.Lines { for lineIdx, line := range sec.Lines {
@ -409,9 +409,9 @@ func (c *Comment) AsDiff() (*Diff, error) {
break break
} }
} }
if searchedLineIdx >= 3 { if searchedLineIdx >= setting.UI.CodeCommentLines - 1 {
first := searchedLineIdx-3 first := searchedLineIdx - setting.UI.CodeCommentLines + 1
last := searchedLineIdx+1 last := searchedLineIdx + 1
sec.Lines = sec.Lines[first:last] sec.Lines = sec.Lines[first:last]
diff.Files[0].Sections = []*DiffSection{sec} diff.Files[0].Sections = []*DiffSection{sec}
break break
@ -428,11 +428,12 @@ func (c *Comment) AsDiff() (*Diff, error) {
func (c *Comment) MustAsDiff() *Diff { func (c *Comment) MustAsDiff() *Diff {
diff, err := c.AsDiff() diff, err := c.AsDiff()
if err != nil { if err != nil {
log.Warn( "MustAsDiff: %v", err) log.Warn("MustAsDiff: %v", err)
} }
return diff return diff
} }
// CodeCommentURL returns the url to a comment in code
func (c *Comment) CodeCommentURL() string { func (c *Comment) CodeCommentURL() string {
err := c.LoadIssue() err := c.LoadIssue()
if err != nil { // Silently dropping errors :unamused: if err != nil { // Silently dropping errors :unamused:

View File

@ -270,6 +270,7 @@ var (
IssuePagingNum int IssuePagingNum int
RepoSearchPagingNum int RepoSearchPagingNum int
FeedMaxCommitNum int FeedMaxCommitNum int
CodeCommentLines int
ReactionMaxUserNum int ReactionMaxUserNum int
ThemeColorMetaTag string ThemeColorMetaTag string
MaxDisplayFileSize int64 MaxDisplayFileSize int64
@ -294,6 +295,7 @@ var (
IssuePagingNum: 10, IssuePagingNum: 10,
RepoSearchPagingNum: 10, RepoSearchPagingNum: 10,
FeedMaxCommitNum: 5, FeedMaxCommitNum: 5,
CodeCommentLines: 4,
ReactionMaxUserNum: 10, ReactionMaxUserNum: 10,
ThemeColorMetaTag: `#6cc644`, ThemeColorMetaTag: `#6cc644`,
MaxDisplayFileSize: 8388608, MaxDisplayFileSize: 8388608,

View File

@ -1126,6 +1126,7 @@ diff.comment.markdown_info = Styling with markdown is supported.
diff.comment.add_single_comment = Add single comment diff.comment.add_single_comment = Add single comment
diff.comment.add_review_comment = Add comment diff.comment.add_review_comment = Add comment
diff.comment.start_review = Start review diff.comment.start_review = Start review
diff.comment.reply = Reply
diff.review = Review diff.review = Review
diff.review.header = Submit review diff.review.header = Submit review
diff.review.placeholder = Review comment diff.review.placeholder = Review comment

View File

@ -1,6 +1,6 @@
{{if $.root.SignedUserID}} {{if $.root.SignedUserID}}
{{if $.hidden}} {{if $.hidden}}
<button class="comment-form-reply ui green labeled icon tiny button"><i class="reply icon"></i> Reply</button> <button class="comment-form-reply ui green labeled icon tiny button"><i class="reply icon"></i> {{$.root.i18n.Tr "repo.diff.comment.reply"}}</button>
{{end}} {{end}}
<form class="ui form {{if $.hidden}}hide comment-form{{end}}" action="{{$.root.Issue.HTMLURL}}/files/reviews/comments" method="post"> <form class="ui form {{if $.hidden}}hide comment-form{{end}}" action="{{$.root.Issue.HTMLURL}}/files/reviews/comments" method="post">
{{$.root.CsrfTokenHtml}} {{$.root.CsrfTokenHtml}}