Remove unnecessary template helper repoAvatar (#26387)

And simplify the "repo/icon" code
pull/26386/head^2
wxiaoguang 1 year ago committed by GitHub
parent 6913053223
commit 78b2a1cc36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      modules/templates/helper.go
  2. 11
      modules/templates/util_avatar.go
  3. 5
      templates/explore/repo_list.tmpl
  4. 5
      templates/org/team/repositories.tmpl
  5. 5
      templates/repo/header.tmpl
  6. 9
      templates/repo/icon.tmpl

@ -59,7 +59,6 @@ func NewFuncMap() template.FuncMap {
"avatarHTML": AvatarHTML, "avatarHTML": AvatarHTML,
"avatarByAction": AvatarByAction, "avatarByAction": AvatarByAction,
"avatarByEmail": AvatarByEmail, "avatarByEmail": AvatarByEmail,
"repoAvatar": RepoAvatar,
"EntryIcon": base.EntryIcon, "EntryIcon": base.EntryIcon,
"MigrationIcon": MigrationIcon, "MigrationIcon": MigrationIcon,
"ActionIcon": ActionIcon, "ActionIcon": ActionIcon,

@ -60,17 +60,6 @@ func AvatarByAction(ctx context.Context, action *activities_model.Action, others
return Avatar(ctx, action.ActUser, 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) // 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 { func AvatarByEmail(ctx context.Context, email, name string, others ...any) template.HTML {
size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...) size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...)

@ -2,12 +2,7 @@
{{range .Repos}} {{range .Repos}}
<div class="flex-item"> <div class="flex-item">
<div class="flex-item-leading"> <div class="flex-item-leading">
{{$avatar := (repoAvatar . 32)}}
{{if $avatar}}
{{$avatar}}
{{else}}
{{template "repo/icon" .}} {{template "repo/icon" .}}
{{end}}
</div> </div>
<div class="flex-item-main"> <div class="flex-item-main">
<div class="flex-item-header"> <div class="flex-item-header">

@ -30,12 +30,7 @@
{{range .Team.Repos}} {{range .Team.Repos}}
<div class="flex-item flex-item-center"> <div class="flex-item flex-item-center">
<div class="flex-item-leading"> <div class="flex-item-leading">
{{$avatar := (repoAvatar . 32)}}
{{if $avatar}}
{{$avatar}}
{{else}}
{{template "repo/icon" .}} {{template "repo/icon" .}}
{{end}}
</div> </div>
<div class="flex-item-main"> <div class="flex-item-main">
<a class="flex-item-title text primary" href="{{$.Org.HomeLink}}/{{.Name | PathEscape}}"> <a class="flex-item-title text primary" href="{{$.Org.HomeLink}}/{{.Name | PathEscape}}">

@ -4,14 +4,9 @@
<div class="repo-header"> <div class="repo-header">
<div class="repo-title-wrap gt-df gt-fc"> <div class="repo-title-wrap gt-df gt-fc">
<div class="repo-title" role="heading" aria-level="1"> <div class="repo-title" role="heading" aria-level="1">
{{$avatar := (repoAvatar . 32 "gt-mr-3")}}
{{if $avatar}}
{{$avatar}}
{{else}}
<div class="gt-mr-3"> <div class="gt-mr-3">
{{template "repo/icon" .}} {{template "repo/icon" .}}
</div> </div>
{{end}}
<a href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a> <a href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a>
<div class="gt-mx-2">/</div> <div class="gt-mx-2">/</div>
<a href="{{$.RepoLink}}">{{.Name}}</a> <a href="{{$.RepoLink}}">{{.Name}}</a>

@ -1,8 +1,10 @@
<div class="repo-icon"> <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}} {{svg "octicon-repo-template" 32}}
{{else}} {{else if $.IsPrivate}}
{{if $.IsPrivate}}
{{svg "octicon-lock" 32}} {{svg "octicon-lock" 32}}
{{else if $.IsMirror}} {{else if $.IsMirror}}
{{svg "octicon-mirror" 32}} {{svg "octicon-mirror" 32}}
@ -11,5 +13,4 @@
{{else}} {{else}}
{{svg "octicon-repo" 32}} {{svg "octicon-repo" 32}}
{{end}} {{end}}
{{end}}
</div> </div>

Loading…
Cancel
Save