From 0cde670b4ad2f36b93c6edd7d1668c23248add32 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 11 Dec 2025 02:28:22 +0100 Subject: [PATCH] wip --- templates/repo/commit_author.tmpl | 58 +++++++++++++++++++++++++++++++ templates/repo/commit_page.tmpl | 22 ++++-------- templates/repo/commits_list.tmpl | 16 ++++----- templates/repo/latest_commit.tmpl | 21 ++++------- 4 files changed, 78 insertions(+), 39 deletions(-) create mode 100644 templates/repo/commit_author.tmpl diff --git a/templates/repo/commit_author.tmpl b/templates/repo/commit_author.tmpl new file mode 100644 index 0000000000..ec7fb563cb --- /dev/null +++ b/templates/repo/commit_author.tmpl @@ -0,0 +1,58 @@ +{{/* Template Attributes: +* User: The user associated with the commit +* Author: The author associated with the commit +* Commit: The author associated with the commit +* AvatarSize: Avatar size in pixels +* AuthorBold: Whether to render the autor as bold text +* IsSigned: Whether the user is currently signed in +* Hack: Hack to avoid error related to .Author.FullName and .Author.HomeLink +*/}} +
+ {{if .User}} + {{ctx.AvatarUtils.Avatar .User .AvatarSize}} + {{$username := ""}} + {{if and .User.FullName DefaultShowFullName}} + {{$username = .User.FullName}} + {{else if .User.Name}} + {{$username = .User.Name}} + {{end}} + + {{$username}} + + {{else if .Author}} + b + {{$username := ""}} + {{if and .Author .Author.FullName DefaultShowFullName}} + {{$username = .Author.FullName}} + {{else if .Author.Name}} + {{$username = .Author.Name}} + {{else if and .Commit .Commit.Author .Commit.Author.Name}} + {{$username = .Commit.Author.Name}} + {{end}} + {{ctx.AvatarUtils.AvatarByEmail .Author.Email $username .AvatarSize}} + + {{if and .Hack .Author.HomeLink}} + + {{$username}} + + {{else}} + {{$username}} + {{end}} + + {{else}} + {{$username := ""}} + {{if and .Commit .Commit.Author .Commit.Author.Name}} + {{$username = .Commit.Author.Name}} + {{else}} + {{$username = .Author.Name}} + {{end}} + {{ctx.AvatarUtils.AvatarByEmail .Commit.Author.Email $username .AvatarSize}} + + {{if and .Commit .Commit.Author .Commit.Author.Name}} + {{.Commit.Author.Name}} + {{else}} + {{.Author.Name}} + {{end}} + + {{end}} +
diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl index 796566017e..60316b8ac4 100644 --- a/templates/repo/commit_page.tmpl +++ b/templates/repo/commit_page.tmpl @@ -128,21 +128,13 @@
- {{if .Author}} -
- {{ctx.AvatarUtils.Avatar .Author 20}} - {{if .Author.FullName}} - {{.Author.FullName}} - {{else}} - {{.Commit.Author.Name}} - {{end}} -
- {{else}} -
- {{ctx.AvatarUtils.AvatarByEmail .Commit.Author.Email .Commit.Author.Email 20}} - {{.Commit.Author.Name}} -
- {{end}} + {{template "repo/commit_author" (dict + "Author" .Author + "Commit" .Commit + "AvatarSize" 20 + "AuthorBold" true + "IsSigned" $.IsSigned + )}} {{DateUtils.TimeSince .Commit.Author.When}} diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl index c38eaf9036..43b924f70d 100644 --- a/templates/repo/commits_list.tmpl +++ b/templates/repo/commits_list.tmpl @@ -15,16 +15,12 @@
- {{$userName := .Author.Name}} - {{if .User}} - {{if and .User.FullName DefaultShowFullName}} - {{$userName = .User.FullName}} - {{end}} - {{ctx.AvatarUtils.Avatar .User 28 "tw-mr-2"}}{{$userName}} - {{else}} - {{ctx.AvatarUtils.AvatarByEmail .Author.Email .Author.Email 28 "tw-mr-2"}} - {{$userName}} - {{end}} + {{template "repo/commit_author" (dict + "User" .User + "Author" .Author + "AvatarSize" 28 + "IsSigned" $.IsSigned + )}}
diff --git a/templates/repo/latest_commit.tmpl b/templates/repo/latest_commit.tmpl index e328b48e84..4b09629a32 100644 --- a/templates/repo/latest_commit.tmpl +++ b/templates/repo/latest_commit.tmpl @@ -2,20 +2,13 @@ {{if not .LatestCommit}} … {{else}} - {{if .LatestCommitUser}} - {{ctx.AvatarUtils.Avatar .LatestCommitUser 24}} - {{if and .LatestCommitUser.FullName DefaultShowFullName}} - {{.LatestCommitUser.FullName}} - {{else}} - {{if .LatestCommit.Author}}{{.LatestCommit.Author.Name}}{{else}}{{.LatestCommitUser.Name}}{{end}} - {{end}} - {{else}} - {{if .LatestCommit.Author}} - {{ctx.AvatarUtils.AvatarByEmail .LatestCommit.Author.Email .LatestCommit.Author.Name 24}} - {{.LatestCommit.Author.Name}} - {{end}} - {{end}} - + {{template "repo/commit_author" (dict + "User" .LatestCommitUser + "Author" .LatestCommit.Author + "AvatarSize" 24 + "AuthorBold" true + "IsSigned" $.IsSigned + )}} {{template "repo/commit_sign_badge" dict "Commit" .LatestCommit "CommitBaseLink" (print .RepoLink "/commit") "CommitSignVerification" .LatestCommitVerification}} {{template "repo/commit_statuses" dict "Status" .LatestCommitStatus "Statuses" .LatestCommitStatuses}}