]> source.dussan.org Git - gitea.git/commitdiff
Unifies commit list in repository commit table and wiki revision page (#7907)
authorMario Lubenka <mario.lubenka@googlemail.com>
Fri, 1 Nov 2019 22:02:41 +0000 (23:02 +0100)
committerzeripath <art27@cantab.net>
Fri, 1 Nov 2019 22:02:41 +0000 (22:02 +0000)
Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
modules/templates/helper.go
templates/repo/commits_list.tmpl [new file with mode: 0644]
templates/repo/commits_table.tmpl
templates/repo/wiki/revision.tmpl

index bdcaa12754abc909c832f79ba075762903ed3860..2d7a1aee9b4f68ca2861c67fb311ada95bab307f 100644 (file)
@@ -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 (file)
index 0000000..177c434
--- /dev/null
@@ -0,0 +1,87 @@
+<div class="ui attached table segment">
+               <table class="ui very basic striped fixed table single line" id="commits-table">
+                       <thead>
+                               <tr>
+                                       <th class="four wide">{{.i18n.Tr "repo.commits.author"}}</th>
+                                       <th class="two wide sha">SHA1</th>
+                                       <th class="seven wide message">{{.i18n.Tr "repo.commits.message"}}</th>
+                                       <th class="three wide right aligned">{{.i18n.Tr "repo.commits.date"}}</th>
+                               </tr>
+                       </thead>
+                       <tbody class="commit-list">
+                               {{ $r:= List .Commits}}
+                               {{range $r}}
+                                       <tr>
+                                               <td class="author">
+                                                   {{$userName := .Author.Name}}
+                                                       {{if .User}}
+                                                               {{if .User.FullName}}
+                                                                   {{$userName = .User.FullName}}
+                                                               {{end}}
+                                                           <img class="ui avatar image" src="{{.User.RelAvatarLink}}" alt=""/>&nbsp;&nbsp;<a href="{{AppSubUrl}}/{{.User.Name}}">{{$userName}}</a>
+                                                       {{else}}
+                                                               <img class="ui avatar image" src="{{AvatarLink .Author.Email}}" alt=""/>&nbsp;&nbsp;{{$userName}}
+                                                       {{end}}
+                                               </td>
+                                               <td class="sha">
+                                                   {{$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}}
+                                                           <a href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/commit/{{.ID}}" rel="nofollow" class="{{$class}}">
+                                                   {{else}}
+                                                           <span class="{{$class}}">
+                                                   {{end}}
+                                                               {{ShortSha .ID.String}}
+                                                               {{if .Signature}}
+                                                                       <div class="ui detail icon button">
+                                                                               {{if .Verification.Verified}}
+                                                                                       <i title="{{.Verification.Reason}}" class="lock green icon"></i>
+                                                                                       {{if ne .Verification.SigningUser.ID 0}}
+                                               <i title="{{.Verification.Reason}}" class="lock green icon"></i>
+                                            {{else}}
+                                               <i title="{{.Verification.Reason}}" class="icons">
+                                                       <i class="green lock icon"></i>
+                                                       <i class="tiny inverted cog icon centerlock"></i>
+                                               </i>
+                                            {{end}}
+                                                                               {{else if .Verification.Warning}}
+                                               <i title="{{$.i18n.Tr .Verification.Reason}}" class="red unlock icon"></i>
+                                        {{else}}
+                                                                                       <i title="{{$.i18n.Tr .Verification.Reason}}" class="unlock icon"></i>
+                                                                               {{end}}
+                                                                       </div>
+                                                               {{end}}
+                                                   {{if $.Reponame}}
+                                                           </a>
+                                                   {{else}}
+                                                           </span>
+                                                   {{end}}
+                                               </td>
+                                               <td class="message">
+                                                       <span class="message-wrapper">
+                                                               {{ $commitLink:= printf "%s/%s/%s/commit/%s" AppSubUrl $.Username $.Reponame .ID }}
+                                                               <span class="commit-summary has-emoji{{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{RenderCommitMessageLinkSubject .Message $.RepoLink $commitLink $.Repository.ComposeMetas}}</span>
+                                                       </span>
+                                                       {{if IsMultilineCommitMessage .Message}}
+                                                       <button class="basic compact mini ui icon button commit-button"><i class="ellipsis horizontal icon"></i></button>
+                                                       {{end}}
+                                                       {{if eq (CommitType .) "SignCommitWithStatuses"}}
+                                                           {{template "repo/commit_status" .Status}}
+                                                       {{end}}
+                                                       {{if IsMultilineCommitMessage .Message}}
+                                                       <pre class="commit-body" style="display: none;">{{RenderCommitBody .Message $.RepoLink $.Repository.ComposeMetas}}</pre>
+                                                       {{end}}
+                                               </td>
+                                               <td class="grey text right aligned">{{TimeSince .Author.When $.Lang}}</td>
+                                       </tr>
+                               {{end}}
+                       </tbody>
+               </table>
+       </div>
index 09a2c072b139588f26e87d3f0e59de60acaa774d..93c321cbe7b78354768175e35da98ca3f7d25882 100644 (file)
 </h4>
 
 {{if and .Commits (gt .CommitCount 0)}}
-       <div class="ui attached table segment">
-               <table class="ui very basic striped fixed table single line" id="commits-table">
-                       <thead>
-                               <tr>
-                                       <th class="four wide">{{.i18n.Tr "repo.commits.author"}}</th>
-                                       <th class="two wide sha">SHA1</th>
-                                       <th class="seven wide message">{{.i18n.Tr "repo.commits.message"}}</th>
-                                       <th class="three wide right aligned">{{.i18n.Tr "repo.commits.date"}}</th>
-                               </tr>
-                       </thead>
-                       <tbody class="commit-list">
-                               {{ $r:= List .Commits}}
-                               {{range $r}}
-                                       <tr>
-                                               <td class="author">
-                                                       {{if .User}}
-                                                               {{if .User.FullName}}
-                                                               <img class="ui avatar image" src="{{.User.RelAvatarLink}}" alt=""/>&nbsp;&nbsp;<a href="{{AppSubUrl}}/{{.User.Name}}">{{.User.FullName}}</a>
-                                                               {{else}}
-                                                               <img class="ui avatar image" src="{{.User.RelAvatarLink}}" alt=""/>&nbsp;&nbsp;<a href="{{AppSubUrl}}/{{.User.Name}}">{{.Author.Name}}</a>
-                                                               {{end}}
-                                                       {{else}}
-                                                               <img class="ui avatar image" src="{{AvatarLink .Author.Email}}" alt=""/>&nbsp;&nbsp;{{.Author.Name}}
-                                                       {{end}}
-                                               </td>
-                                               <td class="sha">
-                                                       <a rel="nofollow" class="ui sha label {{if .Signature}} isSigned {{if .Verification.Verified }} isVerified {{else if .Verification.Warning}} isWarning {{end}}{{end}}" href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/commit/{{.ID}}">
-                                                               {{ShortSha .ID.String}}
-                                                               {{if .Signature}}
-                                                                       <div class="ui detail icon button">
-                                                                               {{if .Verification.Verified}}
-                                                                                       {{if ne .Verification.SigningUser.ID 0}}
-                                                                                               <i title="{{.Verification.Reason}}" class="lock green icon"></i>
-                                                                                       {{else}}
-                                                                                               <i title="{{.Verification.Reason}}" class="icons">
-                                                                                                       <i class="green lock icon"></i>
-                                                                                                       <i class="tiny inverted cog icon centerlock"></i>
-                                                                                               </i>
-                                                                                       {{end}}
-                                                                               {{else if .Verification.Warning}}
-                                                                                       <i title="{{$.i18n.Tr .Verification.Reason}}" class="red unlock icon"></i>
-                                                                               {{else}}
-                                                                                       <i title="{{$.i18n.Tr .Verification.Reason}}" class="unlock icon"></i>
-                                                                               {{end}}
-                                                                       </div>
-                                                               {{end}}
-                                                       </a>
-                                               </td>
-                                               <td class="message">
-                                                       <span class="message-wrapper">
-                                                               {{ $commitLink:= printf "%s/%s/%s/commit/%s" AppSubUrl $.Username $.Reponame .ID }}
-                                                               <span class="commit-summary has-emoji{{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{RenderCommitMessageLinkSubject .Message $.RepoLink $commitLink $.Repository.ComposeMetas}}</span>
-                                                       </span>
-                                                       {{if IsMultilineCommitMessage .Message}}
-                                                       <button class="basic compact mini ui icon button commit-button"><i class="ellipsis horizontal icon"></i></button>
-                                                       {{end}}
-                                                       {{template "repo/commit_status" .Status}}
-                                                       {{if IsMultilineCommitMessage .Message}}
-                                                       <pre class="commit-body" style="display: none;">{{RenderCommitBody .Message $.RepoLink $.Repository.ComposeMetas}}</pre>
-                                                       {{end}}
-                                               </td>
-                                               <td class="grey text right aligned">{{TimeSince .Author.When $.Lang}}</td>
-                                       </tr>
-                               {{end}}
-                       </tbody>
-               </table>
-       </div>
+    {{template "repo/commits_list" .}}
 {{end}}
 
 {{template "base/paginate" .}}
index c3a4f7636b357ecc870251f9d354cc4c66fa69b7..13d3a6227f314f8a342711d9a8cdb5ec755738cf 100644 (file)
                        </h4>
 
                        {{if and .Commits (gt .CommitCount 0)}}
-                               <div class="ui attached table segment">
-                                       <table class="ui very basic striped fixed table single line" id="commits-table">
-                                               <thead>
-                                                       <tr>
-                                                               <th class="four wide">{{.i18n.Tr "repo.commits.author"}}</th>
-                                                               <th class="tree wide sha">SHA1</th>
-                                                               <th class="five wide message">{{.i18n.Tr "repo.commits.message"}}</th>
-                                                               <th class="four wide">{{.i18n.Tr "repo.commits.date"}}</th>
-                                                       </tr>
-                                               </thead>
-                                               <tbody class="commit-list">
-                                                       {{ $r:= List .Commits}}
-                                                       {{range $r}}
-                                                               <tr>
-                                                                       <td class="author">
-                                                                               {{if .User}}
-                                                                                 {{if .User.FullName}}
-                                                                                       <img class="ui avatar image" src="{{.User.RelAvatarLink}}" alt=""/>&nbsp;&nbsp;<a href="{{AppSubUrl}}/{{.User.Name}}">{{.User.FullName}}</a>
-                                                                                 {{else}}
-                                                                                       <img class="ui avatar image" src="{{.User.RelAvatarLink}}" alt=""/>&nbsp;&nbsp;<a href="{{AppSubUrl}}/{{.User.Name}}">{{.Author.Name}}</a>
-                                                                                 {{end}}
-                                                                               {{else}}
-                                                                                       <img class="ui avatar image" src="{{AvatarLink .Author.Email}}" alt=""/>&nbsp;&nbsp;{{.Author.Name}}
-                                                                               {{end}}
-                                                                       </td>
-                                                                       <td class="sha">
-                                                                               <label rel="nofollow" class="ui sha label {{if .Signature}} isSigned {{if .Verification.Verified }} isVerified {{end}}{{end}}">
-                                                                                       {{ShortSha .ID.String}}
-                                                                                       {{if .Signature}}
-                                                                                               <div class="ui detail icon button">
-                                                                                                       {{if .Verification.Verified}}
-                                                                                                               <i title="{{.Verification.Reason}}" class="lock green icon"></i>
-                                                                                                       {{else}}
-                                                                                                               <i title="{{$.i18n.Tr .Verification.Reason}}" class="unlock icon"></i>
-                                                                                                       {{end}}
-                                                                                               </div>
-                                                                                       {{end}}
-                                                                               </label>
-                                                                       </td>
-                                                                       <td class="message">
-                                                                               <span class="message-wrapper">
-                                                                                       <span class="commit-summary has-emoji{{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{.Summary}}</span>
-                                                                                       {{if IsMultilineCommitMessage .Message}}
-                                                                                       <button class="basic compact mini ui icon button commit-button"><i class="ellipsis horizontal icon"></i></button>
-                                                                                       <pre class="commit-body" style="display: none;">{{RenderCommitBody .Message $.RepoLink $.Repository.ComposeMetas}}</pre>
-                                                                                       {{end}}
-                                                                               </span>
-                                                                       </td>
-                                                                       <td class="grey text">{{TimeSince .Author.When $.Lang}}</td>
-                                                               </tr>
-                                                       {{end}}
-                                               </tbody>
-                                       </table>
-                               </div>
+                {{template "repo/commits_list" .}}
                        {{end}}
 
                        {{template "base/paginate" .}}