aboutsummaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-09-03 10:58:52 +0800
committerGitHub <noreply@github.com>2023-09-03 02:58:52 +0000
commitfba7150ca9decee3e9c9fcd8ddeeef939231f8ec (patch)
treef330f27c3cc914d23a5b5cbadb9088b6bbe5bda9 /templates
parentf1fe102c8c9146f8cb997779a4e802691cd1d366 (diff)
downloadgitea-fba7150ca9decee3e9c9fcd8ddeeef939231f8ec.tar.gz
gitea-fba7150ca9decee3e9c9fcd8ddeeef939231f8ec.zip
Refactor "shortsha" (#26877)
The old code used complex `if` blocks and strange HTML layouts. <details> ![image](https://github.com/go-gitea/gitea/assets/2114189/7fbee2b8-d150-4e6b-b67e-83400fa290eb) </details> This PR refactors the template code and remove legacy CSS styles. The UI doesn't change much. ![image](https://github.com/go-gitea/gitea/assets/2114189/3e195df9-0ab5-4182-bcb2-bb20cad823f2) ![image](https://github.com/go-gitea/gitea/assets/2114189/f707a49f-be41-4dfe-871f-2869f2230380)
Diffstat (limited to 'templates')
-rw-r--r--templates/repo/commits_list.tmpl26
-rw-r--r--templates/repo/graph/commits.tmpl2
-rw-r--r--templates/repo/view_list.tmpl4
3 files changed, 11 insertions, 21 deletions
diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl
index b9b42ebb23..b9d0e61713 100644
--- a/templates/repo/commits_list.tmpl
+++ b/templates/repo/commits_list.tmpl
@@ -41,28 +41,18 @@
{{$class = (printf "%s%s" $class " isWarning")}}
{{end}}
{{end}}
+ {{$commitShaLink := ""}}
{{if $.PageIsWiki}}
- <a href="{{$commitRepoLink}}/wiki/commit/{{.ID}}" rel="nofollow" class="{{$class}}">
+ {{$commitShaLink = (printf "%s/wiki/commit/%s" $commitRepoLink (PathEscape .ID.String))}}
{{else if $.PageIsPullCommits}}
- <a href="{{$commitRepoLink}}/pulls/{{$.Issue.Index}}/commits/{{.ID}}" rel="nofollow" class="{{$class}}">
+ {{$commitShaLink = (printf "%s/pulls/%d/commits/%s" $commitRepoLink $.Issue.Index (PathEscape .ID.String))}}
{{else if $.Reponame}}
- <a href="{{$commitRepoLink}}/commit/{{.ID}}" rel="nofollow" class="{{$class}}">
- {{else}}
- <span class="{{$class}}">
+ {{$commitShaLink = (printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String))}}
{{end}}
+ <a {{if $commitShaLink}}href="{{$commitShaLink}}"{{end}} class="{{$class}}">
<span class="shortsha">{{ShortSha .ID.String}}</span>
- {{if .Signature}}
- {{template "repo/shabox_badge" dict "root" $ "verification" .Verification}}
- {{end}}
- {{if $.PageIsWiki}}
- </a>
- {{else if $.PageIsPullCommits}}
- </a>
- {{else if $.Reponame}}
- </a>
- {{else}}
- </span>
- {{end}}
+ {{if .Signature}}{{template "repo/shabox_badge" dict "root" $ "verification" .Verification}}{{end}}
+ </a>
</td>
<td class="message">
<span class="message-wrapper">
@@ -78,7 +68,7 @@
{{end}}
{{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses "root" $}}
{{if IsMultilineCommitMessage .Message}}
- <pre class="commit-body gt-hidden">{{RenderCommitBody $.Context .Message $commitRepoLink $.Repository.ComposeMetas}}</pre>
+ <pre class="commit-body gt-m-0 gt-hidden">{{RenderCommitBody $.Context .Message $commitRepoLink $.Repository.ComposeMetas}}</pre>
{{end}}
</td>
{{if .Committer}}
diff --git a/templates/repo/graph/commits.tmpl b/templates/repo/graph/commits.tmpl
index 0a21aec9c0..58ede56579 100644
--- a/templates/repo/graph/commits.tmpl
+++ b/templates/repo/graph/commits.tmpl
@@ -24,7 +24,7 @@
<a href="{{$.RepoLink}}/commit/{{$commit.Rev|PathEscape}}" rel="nofollow" class="{{$class}}">
<span class="shortsha">{{ShortSha $commit.Commit.ID.String}}</span>
{{- if $commit.Commit.Signature -}}
- <span class="shortsha-pad"></span>{{template "repo/shabox_badge" dict "root" $ "verification" $commit.Verification}}
+ {{template "repo/shabox_badge" dict "root" $ "verification" $commit.Verification}}
{{- end -}}
</a>
</span>
diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl
index 453c06216d..7be2455779 100644
--- a/templates/repo/view_list.tmpl
+++ b/templates/repo/view_list.tmpl
@@ -6,7 +6,7 @@
<div class="ui active tiny slow centered inline">…</div>
{{else}}
{{if .LatestCommitUser}}
- {{ctx.AvatarUtils.Avatar .LatestCommitUser 24}}
+ {{ctx.AvatarUtils.Avatar .LatestCommitUser 24 "gt-mr-2"}}
{{if .LatestCommitUser.FullName}}
<a class="muted author-wrapper" title="{{.LatestCommitUser.FullName}}" href="{{.LatestCommitUser.HomeLink}}"><strong>{{.LatestCommitUser.FullName}}</strong></a>
{{else}}
@@ -14,7 +14,7 @@
{{end}}
{{else}}
{{if .LatestCommit.Author}}
- {{ctx.AvatarUtils.AvatarByEmail .LatestCommit.Author.Email .LatestCommit.Author.Name 24}}
+ {{ctx.AvatarUtils.AvatarByEmail .LatestCommit.Author.Email .LatestCommit.Author.Name 24 "gt-mr-2"}}
<span class="author-wrapper" title="{{.LatestCommit.Author.Name}}"><strong>{{.LatestCommit.Author.Name}}</strong></span>
{{end}}
{{end}}