mirror of
https://github.com/go-gitea/gitea.git
synced 2025-12-14 21:15:18 +08:00
Merge e632d98bec into 7190519fb3
This commit is contained in:
commit
59cdd7b952
55
templates/repo/commit_author.tmpl
Normal file
55
templates/repo/commit_author.tmpl
Normal file
@ -0,0 +1,55 @@
|
||||
{{/* Template Attributes:
|
||||
* User: The user associated with the commit, if any
|
||||
* Commit: The commit
|
||||
* Author: The author, currently only the commit page passes this
|
||||
* AvatarSize: Avatar size in pixels
|
||||
* AuthorBold: Whether to render the author as bold text
|
||||
*/}}
|
||||
<div class="flex-text-inline{{if .AuthorBold}} tw-font-semibold{{end}}">
|
||||
{{if .User}}
|
||||
{{ctx.AvatarUtils.Avatar .User .AvatarSize}}
|
||||
{{$username := ""}}
|
||||
{{if and .User.FullName DefaultShowFullName}}
|
||||
{{$username = .User.FullName}}
|
||||
{{else if .User.Name}}
|
||||
{{$username = .User.Name}}
|
||||
{{end}}
|
||||
<a class="muted author-wrapper" href="{{.User.HomeLink}}" data-tooltip-content="{{$username}}">
|
||||
{{$username}}
|
||||
</a>
|
||||
{{else if .Author}}
|
||||
{{$username := ""}}
|
||||
{{if and .Author.FullName DefaultShowFullName}}
|
||||
{{$username = .Author.FullName}}
|
||||
{{else if .Author.Name}}
|
||||
{{$username = .Author.Name}}
|
||||
{{else if .Commit.Author.Name}}
|
||||
{{$username = .Commit.Author.Name}}
|
||||
{{end}}
|
||||
{{ctx.AvatarUtils.AvatarByEmail .Author.Email $username .AvatarSize}}
|
||||
<span{{if ctx.RootData.IsSigned}} title="{{.Author.Email}}"{{end}}>
|
||||
{{if .Author.HomeLink}}
|
||||
<a class="muted author-wrapper" href="{{.Author.HomeLink}}">
|
||||
{{$username}}
|
||||
</a>
|
||||
{{else}}
|
||||
{{$username}}
|
||||
{{end}}
|
||||
</span>
|
||||
{{else}}
|
||||
{{$username := ""}}
|
||||
{{if .Commit.Author.Name}}
|
||||
{{$username = .Commit.Author.Name}}
|
||||
{{else}}
|
||||
{{$username = .Author.Name}}
|
||||
{{end}}
|
||||
{{ctx.AvatarUtils.AvatarByEmail .Commit.Author.Email $username .AvatarSize}}
|
||||
<span class="author-wrapper" {{if ctx.RootData.IsSigned}} title="{{.Commit.Author.Email}}"{{end}}>
|
||||
{{if .Commit.Author.Name}}
|
||||
{{.Commit.Author.Name}}
|
||||
{{else}}
|
||||
{{.Author.Name}}
|
||||
{{end}}
|
||||
</span>
|
||||
{{end}}
|
||||
</div>
|
||||
@ -128,19 +128,12 @@
|
||||
</div>
|
||||
|
||||
<div class="ui bottom attached segment flex-text-block tw-flex-wrap">
|
||||
<div class="flex-text-inline">
|
||||
{{if .Author}}
|
||||
{{ctx.AvatarUtils.Avatar .Author 20}}
|
||||
{{if .Author.FullName}}
|
||||
<a href="{{.Author.HomeLink}}"><strong>{{.Author.FullName}}</strong></a>
|
||||
{{else}}
|
||||
<a href="{{.Author.HomeLink}}"><strong>{{.Commit.Author.Name}}</strong></a>
|
||||
{{end}}
|
||||
{{else}}
|
||||
{{ctx.AvatarUtils.AvatarByEmail .Commit.Author.Email .Commit.Author.Email 20}}
|
||||
<strong>{{.Commit.Author.Name}}</strong>
|
||||
{{end}}
|
||||
</div>
|
||||
{{template "repo/commit_author" (dict
|
||||
"Commit" .Commit
|
||||
"Author" .Author
|
||||
"AvatarSize" 20
|
||||
"AuthorBold" true
|
||||
)}}
|
||||
|
||||
<span class="text grey">{{DateUtils.TimeSince .Commit.Author.When}}</span>
|
||||
|
||||
|
||||
@ -15,16 +15,11 @@
|
||||
<tr>
|
||||
<td class="author">
|
||||
<div class="tw-flex">
|
||||
{{$userName := .Author.Name}}
|
||||
{{if .User}}
|
||||
{{if and .User.FullName DefaultShowFullName}}
|
||||
{{$userName = .User.FullName}}
|
||||
{{end}}
|
||||
{{ctx.AvatarUtils.Avatar .User 28 "tw-mr-2"}}<a class="muted author-wrapper" href="{{.User.HomeLink}}">{{$userName}}</a>
|
||||
{{else}}
|
||||
{{ctx.AvatarUtils.AvatarByEmail .Author.Email .Author.Name 28 "tw-mr-2"}}
|
||||
<span class="author-wrapper">{{$userName}}</span>
|
||||
{{end}}
|
||||
{{template "repo/commit_author" (dict
|
||||
"Commit" .
|
||||
"User" .User
|
||||
"AvatarSize" 28
|
||||
)}}
|
||||
</div>
|
||||
</td>
|
||||
<td class="sha">
|
||||
|
||||
@ -2,20 +2,12 @@
|
||||
{{if not .LatestCommit}}
|
||||
…
|
||||
{{else}}
|
||||
{{if .LatestCommitUser}}
|
||||
{{ctx.AvatarUtils.Avatar .LatestCommitUser 24}}
|
||||
{{if and .LatestCommitUser.FullName DefaultShowFullName}}
|
||||
<a class="muted author-wrapper" title="{{.LatestCommitUser.FullName}}" href="{{.LatestCommitUser.HomeLink}}"><strong>{{.LatestCommitUser.FullName}}</strong></a>
|
||||
{{else}}
|
||||
<a class="muted author-wrapper" title="{{if .LatestCommit.Author}}{{.LatestCommit.Author.Name}}{{else}}{{.LatestCommitUser.Name}}{{end}}" href="{{.LatestCommitUser.HomeLink}}"><strong>{{if .LatestCommit.Author}}{{.LatestCommit.Author.Name}}{{else}}{{.LatestCommitUser.Name}}{{end}}</strong></a>
|
||||
{{end}}
|
||||
{{else}}
|
||||
{{if .LatestCommit.Author}}
|
||||
{{ctx.AvatarUtils.AvatarByEmail .LatestCommit.Author.Email .LatestCommit.Author.Name 24}}
|
||||
<span class="author-wrapper" title="{{.LatestCommit.Author.Name}}"><strong>{{.LatestCommit.Author.Name}}</strong></span>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
{{template "repo/commit_author" (dict
|
||||
"User" .LatestCommitUser
|
||||
"Commit" .LatestCommit
|
||||
"AvatarSize" 24
|
||||
"AuthorBold" true
|
||||
)}}
|
||||
{{template "repo/commit_sign_badge" dict "Commit" .LatestCommit "CommitBaseLink" (print .RepoLink "/commit") "CommitSignVerification" .LatestCommitVerification}}
|
||||
|
||||
{{template "repo/commit_statuses" dict "Status" .LatestCommitStatus "Statuses" .LatestCommitStatuses}}
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"path"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
@ -63,7 +64,7 @@ func TestRepoCommits(t *testing.T) {
|
||||
commitHref := doc.doc.Find("#commits-table tr:first-child .commit-id-short").AttrOr("href", "")
|
||||
assert.Equal(t, "/user2/repo1/commit/985f0301dba5e7b34be866819cd15ad3d8f508ee", commitHref)
|
||||
authorElem := doc.doc.Find("#commits-table tr:first-child .author-wrapper")
|
||||
assert.Equal(t, "6543", authorElem.Text())
|
||||
assert.Equal(t, "6543", strings.TrimSpace(authorElem.Text()))
|
||||
assert.Equal(t, "span", authorElem.Nodes[0].Data)
|
||||
})
|
||||
|
||||
@ -74,7 +75,7 @@ func TestRepoCommits(t *testing.T) {
|
||||
commitHref := doc.doc.Find(".latest-commit .commit-id-short").AttrOr("href", "")
|
||||
assert.Equal(t, "/user2/repo1/commit/985f0301dba5e7b34be866819cd15ad3d8f508ee", commitHref)
|
||||
authorElem := doc.doc.Find(".latest-commit .author-wrapper")
|
||||
assert.Equal(t, "6543", authorElem.Text())
|
||||
assert.Equal(t, "6543", strings.TrimSpace(authorElem.Text()))
|
||||
assert.Equal(t, "span", authorElem.Nodes[0].Data)
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user