From ba336f6f456835f1f327ee967991079dd220266d Mon Sep 17 00:00:00 2001 From: Mario Lubenka Date: Fri, 1 Nov 2019 23:02:41 +0100 Subject: [PATCH] Unifies commit list in repository commit table and wiki revision page (#7907) Signed-off-by: Mario Lubenka --- modules/templates/helper.go | 12 +++++ templates/repo/commits_list.tmpl | 87 +++++++++++++++++++++++++++++++ templates/repo/commits_table.tmpl | 68 +----------------------- templates/repo/wiki/revision.tmpl | 55 +------------------ 4 files changed, 101 insertions(+), 121 deletions(-) create mode 100644 templates/repo/commits_list.tmpl diff --git a/modules/templates/helper.go b/modules/templates/helper.go index bdcaa12754abc..2d7a1aee9b4f6 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -246,6 +246,18 @@ func NewFuncMap() []template.FuncMap { "MirrorFullAddress": mirror_service.AddressNoCredentials, "MirrorUserName": mirror_service.Username, "MirrorPassword": mirror_service.Password, + "CommitType": func(commit interface{}) string { + switch commit.(type) { + case models.SignCommitWithStatuses: + return "SignCommitWithStatuses" + case models.SignCommit: + return "SignCommit" + case models.UserCommit: + return "UserCommit" + default: + return "" + } + }, }} } diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl new file mode 100644 index 0000000000000..177c434724ffa --- /dev/null +++ b/templates/repo/commits_list.tmpl @@ -0,0 +1,87 @@ +
+ + + + + + + + + + + {{ $r:= List .Commits}} + {{range $r}} + + + + + + + {{end}} + +
{{.i18n.Tr "repo.commits.author"}}SHA1{{.i18n.Tr "repo.commits.message"}}{{.i18n.Tr "repo.commits.date"}}
+ {{$userName := .Author.Name}} + {{if .User}} + {{if .User.FullName}} + {{$userName = .User.FullName}} + {{end}} +   {{$userName}} + {{else}} +   {{$userName}} + {{end}} + + {{$class := "ui sha label"}} + {{if .Signature}} + {{$class = (printf "%s%s" $class " isSigned")}} + {{if .Verification.Verified}} + {{$class = (printf "%s%s" $class " isVerified")}} + {{else if .Verification.Warning}} + {{$class = (printf "%s%s" $class " isWarning")}} + {{end}} + {{end}} + {{if $.Reponame}} + + {{else}} + + {{end}} + {{ShortSha .ID.String}} + {{if .Signature}} +
+ {{if .Verification.Verified}} + + {{if ne .Verification.SigningUser.ID 0}} + + {{else}} + + + + + {{end}} + {{else if .Verification.Warning}} + + {{else}} + + {{end}} +
+ {{end}} + {{if $.Reponame}} +
+ {{else}} + + {{end}} +
+ + {{ $commitLink:= printf "%s/%s/%s/commit/%s" AppSubUrl $.Username $.Reponame .ID }} + {{RenderCommitMessageLinkSubject .Message $.RepoLink $commitLink $.Repository.ComposeMetas}} + + {{if IsMultilineCommitMessage .Message}} + + {{end}} + {{if eq (CommitType .) "SignCommitWithStatuses"}} + {{template "repo/commit_status" .Status}} + {{end}} + {{if IsMultilineCommitMessage .Message}} + + {{end}} + {{TimeSince .Author.When $.Lang}}
+
diff --git a/templates/repo/commits_table.tmpl b/templates/repo/commits_table.tmpl index 09a2c072b1395..93c321cbe7b78 100644 --- a/templates/repo/commits_table.tmpl +++ b/templates/repo/commits_table.tmpl @@ -30,73 +30,7 @@ {{if and .Commits (gt .CommitCount 0)}} -
- - - - - - - - - - - {{ $r:= List .Commits}} - {{range $r}} - - - - - - - {{end}} - -
{{.i18n.Tr "repo.commits.author"}}SHA1{{.i18n.Tr "repo.commits.message"}}{{.i18n.Tr "repo.commits.date"}}
- {{if .User}} - {{if .User.FullName}} -   {{.User.FullName}} - {{else}} -   {{.Author.Name}} - {{end}} - {{else}} -   {{.Author.Name}} - {{end}} - - - {{ShortSha .ID.String}} - {{if .Signature}} -
- {{if .Verification.Verified}} - {{if ne .Verification.SigningUser.ID 0}} - - {{else}} - - - - - {{end}} - {{else if .Verification.Warning}} - - {{else}} - - {{end}} -
- {{end}} -
-
- - {{ $commitLink:= printf "%s/%s/%s/commit/%s" AppSubUrl $.Username $.Reponame .ID }} - {{RenderCommitMessageLinkSubject .Message $.RepoLink $commitLink $.Repository.ComposeMetas}} - - {{if IsMultilineCommitMessage .Message}} - - {{end}} - {{template "repo/commit_status" .Status}} - {{if IsMultilineCommitMessage .Message}} - - {{end}} - {{TimeSince .Author.When $.Lang}}
-
+ {{template "repo/commits_list" .}} {{end}} {{template "base/paginate" .}} diff --git a/templates/repo/wiki/revision.tmpl b/templates/repo/wiki/revision.tmpl index c3a4f7636b357..13d3a6227f314 100644 --- a/templates/repo/wiki/revision.tmpl +++ b/templates/repo/wiki/revision.tmpl @@ -48,60 +48,7 @@ {{if and .Commits (gt .CommitCount 0)}} -
- - - - - - - - - - - {{ $r:= List .Commits}} - {{range $r}} - - - - - - - {{end}} - -
{{.i18n.Tr "repo.commits.author"}}SHA1{{.i18n.Tr "repo.commits.message"}}{{.i18n.Tr "repo.commits.date"}}
- {{if .User}} - {{if .User.FullName}} -   {{.User.FullName}} - {{else}} -   {{.Author.Name}} - {{end}} - {{else}} -   {{.Author.Name}} - {{end}} - - - - - {{.Summary}} - {{if IsMultilineCommitMessage .Message}} - - - {{end}} - - {{TimeSince .Author.When $.Lang}}
-
+ {{template "repo/commits_list" .}} {{end}} {{template "base/paginate" .}}