Skip to content

Remove unnecessary template helper repoAvatar #26387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion modules/templates/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ func NewFuncMap() template.FuncMap {
"avatarHTML": AvatarHTML,
"avatarByAction": AvatarByAction,
"avatarByEmail": AvatarByEmail,
"repoAvatar": RepoAvatar,
"EntryIcon": base.EntryIcon,
"MigrationIcon": MigrationIcon,
"ActionIcon": ActionIcon,
Expand Down
11 changes: 0 additions & 11 deletions modules/templates/util_avatar.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,6 @@ func AvatarByAction(ctx context.Context, action *activities_model.Action, others
return Avatar(ctx, action.ActUser, others...)
}

// RepoAvatar renders repo avatars. args: repo, size(int), class (string)
func RepoAvatar(repo *repo_model.Repository, others ...any) template.HTML {
size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...)

src := repo.RelAvatarLink()
if src != "" {
return AvatarHTML(src, size, class, repo.FullName())
}
return template.HTML("")
}

// AvatarByEmail renders avatars by email address. args: email, name, size (int), class (string)
func AvatarByEmail(ctx context.Context, email, name string, others ...any) template.HTML {
size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...)
Expand Down
7 changes: 1 addition & 6 deletions templates/explore/repo_list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
{{range .Repos}}
<div class="flex-item">
<div class="flex-item-leading">
{{$avatar := (repoAvatar . 32)}}
{{if $avatar}}
{{$avatar}}
{{else}}
{{template "repo/icon" .}}
{{end}}
{{template "repo/icon" .}}
</div>
<div class="flex-item-main">
<div class="flex-item-header">
Expand Down
7 changes: 1 addition & 6 deletions templates/org/team/repositories.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@
{{range .Team.Repos}}
<div class="flex-item flex-item-center">
<div class="flex-item-leading">
{{$avatar := (repoAvatar . 32)}}
{{if $avatar}}
{{$avatar}}
{{else}}
{{template "repo/icon" .}}
{{end}}
{{template "repo/icon" .}}
</div>
<div class="flex-item-main">
<a class="flex-item-title text primary" href="{{$.Org.HomeLink}}/{{.Name | PathEscape}}">
Expand Down
11 changes: 3 additions & 8 deletions templates/repo/header.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@
<div class="repo-header">
<div class="repo-title-wrap gt-df gt-fc">
<div class="repo-title" role="heading" aria-level="1">
{{$avatar := (repoAvatar . 32 "gt-mr-3")}}
{{if $avatar}}
{{$avatar}}
{{else}}
<div class="gt-mr-3">
{{template "repo/icon" .}}
</div>
{{end}}
<div class="gt-mr-3">
{{template "repo/icon" .}}
</div>
<a href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a>
<div class="gt-mx-2">/</div>
<a href="{{$.RepoLink}}">{{.Name}}</a>
Expand Down
21 changes: 11 additions & 10 deletions templates/repo/icon.tmpl
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<div class="repo-icon">
{{if $.IsTemplate}}
{{$avatarLink := .RelAvatarLink}}
{{if $avatarLink}}
<img class="ui avatar gt-vm" src="{{$avatarLink}}" width="32" height="32" alt="{{.FullName}}">
{{else if $.IsTemplate}}
{{svg "octicon-repo-template" 32}}
{{else if $.IsPrivate}}
{{svg "octicon-lock" 32}}
{{else if $.IsMirror}}
{{svg "octicon-mirror" 32}}
{{else if $.IsFork}}
{{svg "octicon-repo-forked" 32}}
{{else}}
{{if $.IsPrivate}}
{{svg "octicon-lock" 32}}
{{else if $.IsMirror}}
{{svg "octicon-mirror" 32}}
{{else if $.IsFork}}
{{svg "octicon-repo-forked" 32}}
{{else}}
{{svg "octicon-repo" 32}}
{{end}}
{{svg "octicon-repo" 32}}
{{end}}
</div>