Skip to content

Commit d541431

Browse files
authored
Merge branch 'main' into lunny/models
2 parents dbd002d + 462306e commit d541431

File tree

13 files changed

+96
-27
lines changed

13 files changed

+96
-27
lines changed

modules/templates/helper.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -911,13 +911,13 @@ func TrN(lang string, cnt interface{}, key1, keyN string) string {
911911
return keyN
912912
}
913913

914-
// MigrationIcon returns a Font Awesome name matching the service an issue/comment was migrated from
914+
// MigrationIcon returns a SVG name matching the service an issue/comment was migrated from
915915
func MigrationIcon(hostname string) string {
916916
switch hostname {
917917
case "github.com":
918-
return "fa-github"
918+
return "octicon-mark-github"
919919
default:
920-
return "fa-git-alt"
920+
return "gitea-git"
921921
}
922922
}
923923

options/license/Verbatim-man-pages

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Copyright (c) 0000, Obelix the Gaul <[email protected]>.
2+
3+
Permission is granted to make and distribute verbatim copies of this
4+
manual provided the copyright notice and this permission notice are
5+
preserved on all copies.
6+
7+
Permission is granted to copy and distribute modified versions of
8+
this manual under the conditions for verbatim copying, provided that
9+
the entire resulting derived work is distributed under the terms of
10+
a permission notice identical to this one.
11+
12+
Since the Linux kernel and libraries are constantly changing, this
13+
manual page may be incorrect or out-of-date. The author(s) assume
14+
no responsibility for errors or omissions, or for damages resulting
15+
from the use of the information contained herein. The author(s) may
16+
not have taken the same level of care in the production of this
17+
manual, which is licensed free of charge, as they might when working
18+
professionally.
19+
20+
Formatted or processed versions of this manual, if unaccompanied by
21+
the source, must acknowledge the copyright and authors of this work.

public/img/svg/gitea-git.svg

+1-1
Loading

services/webhook/dingtalk.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package webhook
66

77
import (
88
"fmt"
9+
"net/url"
910
"strings"
1011

1112
"code.gitea.io/gitea/models"
@@ -175,7 +176,10 @@ func createDingtalkPayload(title, text, singleTitle, singleURL string) *Dingtalk
175176
Title: strings.TrimSpace(title),
176177
HideAvatar: "0",
177178
SingleTitle: singleTitle,
178-
SingleURL: singleURL,
179+
180+
// https://developers.dingtalk.com/document/app/message-link-description
181+
// to open the link in browser, we should use this URL, otherwise the page is displayed inside DingTalk client, very difficult to visit non-public URLs.
182+
SingleURL: "dingtalk://dingtalkclient/page/link?pc_slide=false&url=" + url.QueryEscape(singleURL),
179183
},
180184
}
181185
}

services/webhook/dingtalk_test.go

+23-12
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package webhook
66

77
import (
8+
"net/url"
89
"testing"
910

1011
"code.gitea.io/gitea/models"
@@ -15,6 +16,16 @@ import (
1516
)
1617

1718
func TestDingTalkPayload(t *testing.T) {
19+
parseRealSingleURL := func(singleURL string) string {
20+
if u, err := url.Parse(singleURL); err == nil {
21+
assert.Equal(t, "dingtalk", u.Scheme)
22+
assert.Equal(t, "dingtalkclient", u.Host)
23+
assert.Equal(t, "/page/link", u.Path)
24+
return u.Query().Get("url")
25+
}
26+
return ""
27+
}
28+
1829
t.Run("Create", func(t *testing.T) {
1930
p := createTestPayload()
2031

@@ -27,7 +38,7 @@ func TestDingTalkPayload(t *testing.T) {
2738
assert.Equal(t, "[test/repo] branch test created", pl.(*DingtalkPayload).ActionCard.Text)
2839
assert.Equal(t, "[test/repo] branch test created", pl.(*DingtalkPayload).ActionCard.Title)
2940
assert.Equal(t, "view ref test", pl.(*DingtalkPayload).ActionCard.SingleTitle)
30-
assert.Equal(t, "http://localhost:3000/test/repo/src/test", pl.(*DingtalkPayload).ActionCard.SingleURL)
41+
assert.Equal(t, "http://localhost:3000/test/repo/src/test", parseRealSingleURL(pl.(*DingtalkPayload).ActionCard.SingleURL))
3142
})
3243

3344
t.Run("Delete", func(t *testing.T) {
@@ -42,7 +53,7 @@ func TestDingTalkPayload(t *testing.T) {
4253
assert.Equal(t, "[test/repo] branch test deleted", pl.(*DingtalkPayload).ActionCard.Text)
4354
assert.Equal(t, "[test/repo] branch test deleted", pl.(*DingtalkPayload).ActionCard.Title)
4455
assert.Equal(t, "view ref test", pl.(*DingtalkPayload).ActionCard.SingleTitle)
45-
assert.Equal(t, "http://localhost:3000/test/repo/src/test", pl.(*DingtalkPayload).ActionCard.SingleURL)
56+
assert.Equal(t, "http://localhost:3000/test/repo/src/test", parseRealSingleURL(pl.(*DingtalkPayload).ActionCard.SingleURL))
4657
})
4758

4859
t.Run("Fork", func(t *testing.T) {
@@ -57,7 +68,7 @@ func TestDingTalkPayload(t *testing.T) {
5768
assert.Equal(t, "test/repo2 is forked to test/repo", pl.(*DingtalkPayload).ActionCard.Text)
5869
assert.Equal(t, "test/repo2 is forked to test/repo", pl.(*DingtalkPayload).ActionCard.Title)
5970
assert.Equal(t, "view forked repo test/repo", pl.(*DingtalkPayload).ActionCard.SingleTitle)
60-
assert.Equal(t, "http://localhost:3000/test/repo", pl.(*DingtalkPayload).ActionCard.SingleURL)
71+
assert.Equal(t, "http://localhost:3000/test/repo", parseRealSingleURL(pl.(*DingtalkPayload).ActionCard.SingleURL))
6172
})
6273

6374
t.Run("Push", func(t *testing.T) {
@@ -72,7 +83,7 @@ func TestDingTalkPayload(t *testing.T) {
7283
assert.Equal(t, "[2020558](http://localhost:3000/test/repo/commit/2020558fe2e34debb818a514715839cabd25e778) commit message - user1\r\n[2020558](http://localhost:3000/test/repo/commit/2020558fe2e34debb818a514715839cabd25e778) commit message - user1", pl.(*DingtalkPayload).ActionCard.Text)
7384
assert.Equal(t, "[test/repo:test] 2 new commits", pl.(*DingtalkPayload).ActionCard.Title)
7485
assert.Equal(t, "view commit 2020558...2020558", pl.(*DingtalkPayload).ActionCard.SingleTitle)
75-
assert.Equal(t, "http://localhost:3000/test/repo/src/test", pl.(*DingtalkPayload).ActionCard.SingleURL)
86+
assert.Equal(t, "http://localhost:3000/test/repo/src/test", parseRealSingleURL(pl.(*DingtalkPayload).ActionCard.SingleURL))
7687
})
7788

7889
t.Run("Issue", func(t *testing.T) {
@@ -88,7 +99,7 @@ func TestDingTalkPayload(t *testing.T) {
8899
assert.Equal(t, "[test/repo] Issue opened: #2 crash by user1\r\n\r\nissue body", pl.(*DingtalkPayload).ActionCard.Text)
89100
assert.Equal(t, "#2 crash", pl.(*DingtalkPayload).ActionCard.Title)
90101
assert.Equal(t, "view issue", pl.(*DingtalkPayload).ActionCard.SingleTitle)
91-
assert.Equal(t, "http://localhost:3000/test/repo/issues/2", pl.(*DingtalkPayload).ActionCard.SingleURL)
102+
assert.Equal(t, "http://localhost:3000/test/repo/issues/2", parseRealSingleURL(pl.(*DingtalkPayload).ActionCard.SingleURL))
92103

93104
p.Action = api.HookIssueClosed
94105
pl, err = d.Issue(p)
@@ -99,7 +110,7 @@ func TestDingTalkPayload(t *testing.T) {
99110
assert.Equal(t, "[test/repo] Issue closed: #2 crash by user1", pl.(*DingtalkPayload).ActionCard.Text)
100111
assert.Equal(t, "#2 crash", pl.(*DingtalkPayload).ActionCard.Title)
101112
assert.Equal(t, "view issue", pl.(*DingtalkPayload).ActionCard.SingleTitle)
102-
assert.Equal(t, "http://localhost:3000/test/repo/issues/2", pl.(*DingtalkPayload).ActionCard.SingleURL)
113+
assert.Equal(t, "http://localhost:3000/test/repo/issues/2", parseRealSingleURL(pl.(*DingtalkPayload).ActionCard.SingleURL))
103114
})
104115

105116
t.Run("IssueComment", func(t *testing.T) {
@@ -114,7 +125,7 @@ func TestDingTalkPayload(t *testing.T) {
114125
assert.Equal(t, "[test/repo] New comment on issue #2 crash by user1\r\n\r\nmore info needed", pl.(*DingtalkPayload).ActionCard.Text)
115126
assert.Equal(t, "#2 crash", pl.(*DingtalkPayload).ActionCard.Title)
116127
assert.Equal(t, "view issue comment", pl.(*DingtalkPayload).ActionCard.SingleTitle)
117-
assert.Equal(t, "http://localhost:3000/test/repo/issues/2#issuecomment-4", pl.(*DingtalkPayload).ActionCard.SingleURL)
128+
assert.Equal(t, "http://localhost:3000/test/repo/issues/2#issuecomment-4", parseRealSingleURL(pl.(*DingtalkPayload).ActionCard.SingleURL))
118129
})
119130

120131
t.Run("PullRequest", func(t *testing.T) {
@@ -129,7 +140,7 @@ func TestDingTalkPayload(t *testing.T) {
129140
assert.Equal(t, "[test/repo] Pull request opened: #12 Fix bug by user1\r\n\r\nfixes bug #2", pl.(*DingtalkPayload).ActionCard.Text)
130141
assert.Equal(t, "#12 Fix bug", pl.(*DingtalkPayload).ActionCard.Title)
131142
assert.Equal(t, "view pull request", pl.(*DingtalkPayload).ActionCard.SingleTitle)
132-
assert.Equal(t, "http://localhost:3000/test/repo/pulls/12", pl.(*DingtalkPayload).ActionCard.SingleURL)
143+
assert.Equal(t, "http://localhost:3000/test/repo/pulls/12", parseRealSingleURL(pl.(*DingtalkPayload).ActionCard.SingleURL))
133144
})
134145

135146
t.Run("PullRequestComment", func(t *testing.T) {
@@ -144,7 +155,7 @@ func TestDingTalkPayload(t *testing.T) {
144155
assert.Equal(t, "[test/repo] New comment on pull request #12 Fix bug by user1\r\n\r\nchanges requested", pl.(*DingtalkPayload).ActionCard.Text)
145156
assert.Equal(t, "#12 Fix bug", pl.(*DingtalkPayload).ActionCard.Title)
146157
assert.Equal(t, "view issue comment", pl.(*DingtalkPayload).ActionCard.SingleTitle)
147-
assert.Equal(t, "http://localhost:3000/test/repo/pulls/12#issuecomment-4", pl.(*DingtalkPayload).ActionCard.SingleURL)
158+
assert.Equal(t, "http://localhost:3000/test/repo/pulls/12#issuecomment-4", parseRealSingleURL(pl.(*DingtalkPayload).ActionCard.SingleURL))
148159
})
149160

150161
t.Run("Review", func(t *testing.T) {
@@ -160,7 +171,7 @@ func TestDingTalkPayload(t *testing.T) {
160171
assert.Equal(t, "[test/repo] Pull request review approved : #12 Fix bug\r\n\r\ngood job", pl.(*DingtalkPayload).ActionCard.Text)
161172
assert.Equal(t, "[test/repo] Pull request review approved : #12 Fix bug", pl.(*DingtalkPayload).ActionCard.Title)
162173
assert.Equal(t, "view pull request", pl.(*DingtalkPayload).ActionCard.SingleTitle)
163-
assert.Equal(t, "http://localhost:3000/test/repo/pulls/12", pl.(*DingtalkPayload).ActionCard.SingleURL)
174+
assert.Equal(t, "http://localhost:3000/test/repo/pulls/12", parseRealSingleURL(pl.(*DingtalkPayload).ActionCard.SingleURL))
164175
})
165176

166177
t.Run("Repository", func(t *testing.T) {
@@ -175,7 +186,7 @@ func TestDingTalkPayload(t *testing.T) {
175186
assert.Equal(t, "[test/repo] Repository created", pl.(*DingtalkPayload).ActionCard.Text)
176187
assert.Equal(t, "[test/repo] Repository created", pl.(*DingtalkPayload).ActionCard.Title)
177188
assert.Equal(t, "view repository", pl.(*DingtalkPayload).ActionCard.SingleTitle)
178-
assert.Equal(t, "http://localhost:3000/test/repo", pl.(*DingtalkPayload).ActionCard.SingleURL)
189+
assert.Equal(t, "http://localhost:3000/test/repo", parseRealSingleURL(pl.(*DingtalkPayload).ActionCard.SingleURL))
179190
})
180191

181192
t.Run("Release", func(t *testing.T) {
@@ -190,7 +201,7 @@ func TestDingTalkPayload(t *testing.T) {
190201
assert.Equal(t, "[test/repo] Release created: v1.0 by user1", pl.(*DingtalkPayload).ActionCard.Text)
191202
assert.Equal(t, "[test/repo] Release created: v1.0 by user1", pl.(*DingtalkPayload).ActionCard.Title)
192203
assert.Equal(t, "view release", pl.(*DingtalkPayload).ActionCard.SingleTitle)
193-
assert.Equal(t, "http://localhost:3000/api/v1/repos/test/repo/releases/2", pl.(*DingtalkPayload).ActionCard.SingleURL)
204+
assert.Equal(t, "http://localhost:3000/api/v1/repos/test/repo/releases/2", parseRealSingleURL(pl.(*DingtalkPayload).ActionCard.SingleURL))
194205
})
195206
}
196207

templates/repo/diff/comments.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<div class="comment-header-left df ac">
1515
{{if .OriginalAuthor }}
1616
<span class="text black mr-2">
17-
<i class="fa {{MigrationIcon $.root.Repository.GetOriginalURLHostname}}" aria-hidden="true"></i>
17+
{{svg (MigrationIcon $.root.Repository.GetOriginalURLHostname)}}
1818
{{ .OriginalAuthor }}
1919
</span>
2020
<span class="text grey">

templates/repo/issue/view_content.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<div class="comment-header-left df ac">
2525
{{if .Issue.OriginalAuthor }}
2626
<span class="text black">
27-
<i class="fa {{MigrationIcon .Repository.GetOriginalURLHostname}}" aria-hidden="true"></i>
27+
{{svg (MigrationIcon .Repository.GetOriginalURLHostname)}}
2828
{{ .Issue.OriginalAuthor }}
2929
</span>
3030
<span class="text grey">

templates/repo/issue/view_content/comments.tmpl

+19-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<div class="comment-header-left df ac">
2525
{{if .OriginalAuthor }}
2626
<span class="text black mr-2">
27-
<i class="fa {{MigrationIcon $.Repository.GetOriginalURLHostname}}" aria-hidden="true"></i>
27+
{{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}}
2828
{{ .OriginalAuthor }}
2929
</span>
3030
<span class="text grey">
@@ -408,7 +408,12 @@
408408
<span class="badge{{if eq .Review.Type 1}} bg-green text-white{{else if eq .Review.Type 3}} bg-red text-white{{end}}">{{svg (printf "octicon-%s" .Review.Type.Icon)}}</span>
409409
<span class="text grey">
410410
{{if .OriginalAuthor }}
411-
<span class="text black"><i class="fa {{MigrationIcon $.Repository.GetOriginalURLHostname}}" aria-hidden="true"></i> {{ .OriginalAuthor }}</span><span class="text grey"> {{if $.Repository.OriginalURL}}</span><span class="text migrate">({{$.i18n.Tr "repo.migrated_from" $.Repository.OriginalURL $.Repository.GetOriginalURLHostname | Safe }}){{end}}</span>
411+
<span class="text black">
412+
{{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}}
413+
{{ .OriginalAuthor }}
414+
</span>
415+
<span class="text grey"> {{if $.Repository.OriginalURL}}</span>
416+
<span class="text migrate">({{$.i18n.Tr "repo.migrated_from" $.Repository.OriginalURL $.Repository.GetOriginalURLHostname | Safe }}){{end}}</span>
412417
{{else}}
413418
<a class="author"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}>{{.Poster.GetDisplayName}}</a>
414419
{{end}}
@@ -433,7 +438,12 @@
433438
<div class="ui top attached header comment-header df ac sb">
434439
<span class="text grey">
435440
{{if .OriginalAuthor }}
436-
<span class="text black"><i class="fa {{MigrationIcon $.Repository.GetOriginalURLHostname}}" aria-hidden="true"></i> {{ .OriginalAuthor }}</span><span class="text grey"> {{if $.Repository.OriginalURL}}</span><span class="text migrate">({{$.i18n.Tr "repo.migrated_from" $.Repository.OriginalURL $.Repository.GetOriginalURLHostname | Safe }}){{end}}</span>
441+
<span class="text black">
442+
{{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}}
443+
{{ .OriginalAuthor }}
444+
</span>
445+
<span class="text grey"> {{if $.Repository.OriginalURL}}</span>
446+
<span class="text migrate">({{$.i18n.Tr "repo.migrated_from" $.Repository.OriginalURL $.Repository.GetOriginalURLHostname | Safe }}){{end}}</span>
437447
{{else}}
438448
<a class="author"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}>{{.Poster.GetDisplayName}}</a>
439449
{{end}}
@@ -526,7 +536,12 @@
526536
{{end}}
527537
<span class="text grey">
528538
{{if .OriginalAuthor }}
529-
<span class="text black"><i class="fa {{MigrationIcon $.Repository.GetOriginalURLHostname}}" aria-hidden="true"></i> {{ .OriginalAuthor }}</span><span class="text grey"> {{if $.Repository.OriginalURL}}</span><span class="text migrate">({{$.i18n.Tr "repo.migrated_from" $.Repository.OriginalURL $.Repository.GetOriginalURLHostname | Safe }}){{end}}</span>
539+
<span class="text black">
540+
{{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}}
541+
{{ .OriginalAuthor }}
542+
</span>
543+
<span class="text grey"> {{if $.Repository.OriginalURL}}</span>
544+
<span class="text migrate">({{$.i18n.Tr "repo.migrated_from" $.Repository.OriginalURL $.Repository.GetOriginalURLHostname | Safe }}){{end}}</span>
530545
{{else}}
531546
<a class="author"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}>{{.Poster.GetDisplayName}}</a>
532547
{{end}}

templates/repo/issue/view_content/pull.tmpl

+6-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,12 @@
8686
<div class="ui divider"></div>
8787
<div class="review-item">
8888
<div class="review-item-left">
89-
<a href="{{$.Repository.OriginalURL}}" class="ui poping up" data-content="{{$.i18n.Tr "repo.migrated_from_fake" $.Repository.GetOriginalURLHostname | Safe }}"><span class="text black "><i class="fa {{MigrationIcon $.Repository.GetOriginalURLHostname}}" aria-hidden="true"></i> {{ .OriginalAuthor }}</span></a>
89+
<a href="{{$.Repository.OriginalURL}}" class="ui poping up" data-content="{{$.i18n.Tr "repo.migrated_from_fake" $.Repository.GetOriginalURLHostname | Safe }}">
90+
<span class="text black ">
91+
{{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}}
92+
{{ .OriginalAuthor }}
93+
</span>
94+
</a>
9095
</div>
9196
<div class="review-item-right">
9297
<span class="type-icon text {{if eq .Type 1}}green

templates/repo/issue/view_content/sidebar.tmpl

+6-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@
7979
{{end}}
8080
{{range .OriginalReviews}}
8181
<div class="item" style="margin-bottom: 10px;">
82-
<a href="{{$.Repository.OriginalURL}}" class="ui poping up" data-content="{{$.i18n.Tr "repo.migrated_from_fake" $.Repository.GetOriginalURLHostname | Safe }}"><span class="text black "><i class="fa {{MigrationIcon $.Repository.GetOriginalURLHostname}}" aria-hidden="true"></i> {{ .OriginalAuthor }}</span></a>
82+
<a href="{{$.Repository.OriginalURL}}" class="ui poping up" data-content="{{$.i18n.Tr "repo.migrated_from_fake" $.Repository.GetOriginalURLHostname | Safe }}">
83+
<span class="text black">
84+
{{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}}
85+
{{ .OriginalAuthor }}
86+
</span>
87+
</a>
8388
<span class="ui right type-icon text {{if eq .Type 1}}green
8489
{{- else if eq .Type 2}}grey
8590
{{- else if eq .Type 3}}red

web_src/less/_base.less

+5-1
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ a.ui.card:hover,
10411041

10421042
.migrate {
10431043
color: var(--color-text-light-2) !important;
1044-
opacity: .5;
1044+
10451045
a {
10461046
color: var(--color-text-light) !important;
10471047

@@ -1770,6 +1770,10 @@ a.ui.basic.label:hover {
17701770
}
17711771
}
17721772

1773+
.migrate .svg.gitea-git {
1774+
color: #f05133; /* from https://upload.wikimedia.org/wikipedia/commons/e/e0/Git-logo.svg */
1775+
}
1776+
17731777
.ui.popup {
17741778
background-color: var(--color-body);
17751779
color: var(--color-secondary-dark-6);

web_src/less/_repository.less

+4
Original file line numberDiff line numberDiff line change
@@ -1711,6 +1711,10 @@
17111711
}
17121712

17131713
.code-diff-split {
1714+
.tag-code .lines-code code.code-inner {
1715+
padding-left: 10px !important;
1716+
}
1717+
17141718
table,
17151719
tbody {
17161720
width: 100%;

web_src/svg/gitea-git.svg

+1-1
Loading

0 commit comments

Comments
 (0)