mirror of
https://github.com/go-gitea/gitea.git
synced 2025-12-15 21:45:35 +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>
|
||||||
|
|
||||||
<div class="ui bottom attached segment flex-text-block tw-flex-wrap">
|
<div class="ui bottom attached segment flex-text-block tw-flex-wrap">
|
||||||
<div class="flex-text-inline">
|
{{template "repo/commit_author" (dict
|
||||||
{{if .Author}}
|
"Commit" .Commit
|
||||||
{{ctx.AvatarUtils.Avatar .Author 20}}
|
"Author" .Author
|
||||||
{{if .Author.FullName}}
|
"AvatarSize" 20
|
||||||
<a href="{{.Author.HomeLink}}"><strong>{{.Author.FullName}}</strong></a>
|
"AuthorBold" true
|
||||||
{{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>
|
|
||||||
|
|
||||||
<span class="text grey">{{DateUtils.TimeSince .Commit.Author.When}}</span>
|
<span class="text grey">{{DateUtils.TimeSince .Commit.Author.When}}</span>
|
||||||
|
|
||||||
|
|||||||
@ -15,16 +15,11 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="author">
|
<td class="author">
|
||||||
<div class="tw-flex">
|
<div class="tw-flex">
|
||||||
{{$userName := .Author.Name}}
|
{{template "repo/commit_author" (dict
|
||||||
{{if .User}}
|
"Commit" .
|
||||||
{{if and .User.FullName DefaultShowFullName}}
|
"User" .User
|
||||||
{{$userName = .User.FullName}}
|
"AvatarSize" 28
|
||||||
{{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}}
|
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="sha">
|
<td class="sha">
|
||||||
|
|||||||
@ -2,20 +2,12 @@
|
|||||||
{{if not .LatestCommit}}
|
{{if not .LatestCommit}}
|
||||||
…
|
…
|
||||||
{{else}}
|
{{else}}
|
||||||
{{if .LatestCommitUser}}
|
{{template "repo/commit_author" (dict
|
||||||
{{ctx.AvatarUtils.Avatar .LatestCommitUser 24}}
|
"User" .LatestCommitUser
|
||||||
{{if and .LatestCommitUser.FullName DefaultShowFullName}}
|
"Commit" .LatestCommit
|
||||||
<a class="muted author-wrapper" title="{{.LatestCommitUser.FullName}}" href="{{.LatestCommitUser.HomeLink}}"><strong>{{.LatestCommitUser.FullName}}</strong></a>
|
"AvatarSize" 24
|
||||||
{{else}}
|
"AuthorBold" true
|
||||||
<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_sign_badge" dict "Commit" .LatestCommit "CommitBaseLink" (print .RepoLink "/commit") "CommitSignVerification" .LatestCommitVerification}}
|
{{template "repo/commit_sign_badge" dict "Commit" .LatestCommit "CommitBaseLink" (print .RepoLink "/commit") "CommitSignVerification" .LatestCommitVerification}}
|
||||||
|
|
||||||
{{template "repo/commit_statuses" dict "Status" .LatestCommitStatus "Statuses" .LatestCommitStatuses}}
|
{{template "repo/commit_statuses" dict "Status" .LatestCommitStatus "Statuses" .LatestCommitStatuses}}
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"path"
|
"path"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -63,7 +64,7 @@ func TestRepoCommits(t *testing.T) {
|
|||||||
commitHref := doc.doc.Find("#commits-table tr:first-child .commit-id-short").AttrOr("href", "")
|
commitHref := doc.doc.Find("#commits-table tr:first-child .commit-id-short").AttrOr("href", "")
|
||||||
assert.Equal(t, "/user2/repo1/commit/985f0301dba5e7b34be866819cd15ad3d8f508ee", commitHref)
|
assert.Equal(t, "/user2/repo1/commit/985f0301dba5e7b34be866819cd15ad3d8f508ee", commitHref)
|
||||||
authorElem := doc.doc.Find("#commits-table tr:first-child .author-wrapper")
|
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)
|
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", "")
|
commitHref := doc.doc.Find(".latest-commit .commit-id-short").AttrOr("href", "")
|
||||||
assert.Equal(t, "/user2/repo1/commit/985f0301dba5e7b34be866819cd15ad3d8f508ee", commitHref)
|
assert.Equal(t, "/user2/repo1/commit/985f0301dba5e7b34be866819cd15ad3d8f508ee", commitHref)
|
||||||
authorElem := doc.doc.Find(".latest-commit .author-wrapper")
|
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)
|
assert.Equal(t, "span", authorElem.Nodes[0].Data)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user