diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 5af1addb60..0b5ae0f013 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -341,6 +341,7 @@ func NewFuncMap() []template.FuncMap { "svg": SVG, "avatar": Avatar, "avatarByEmail": AvatarByEmail, + "repoAvatar": RepoAvatar, "SortArrow": func(normSort, revSort, urlSort string, isDefault bool) template.HTML { // if needed if len(normSort) == 0 || len(urlSort) == 0 { @@ -545,23 +546,25 @@ func SVG(icon string, others ...interface{}) template.HTML { return template.HTML("") } -// Avatar renders user and repo avatars. args: user/repo, size (int), class (string) -func Avatar(item interface{}, others ...interface{}) template.HTML { +// Avatar renders user avatars. args: user, size (int), class (string) +func Avatar(user *models.User, others ...interface{}) template.HTML { size, class := parseOthers(28, "ui avatar image", others...) - if user, ok := item.(*models.User); ok { - src := user.RealSizedAvatarLink(size * 2) // request double size for finer rendering - if src != "" { - return avatarHTML(src, size, class, user.DisplayName()) - } - } - if repo, ok := item.(*models.Repository); ok { - src := repo.RelAvatarLink() - if src != "" { - return avatarHTML(src, size, class, repo.FullName()) - } + src := user.RealSizedAvatarLink(size * 2) // request double size for finer rendering + if src != "" { + return avatarHTML(src, size, class, user.DisplayName()) } + return template.HTML("") +} +// RepoAvatar renders repo avatars. args: repo, size(int), class (string) +func RepoAvatar(repo *models.Repository, others ...interface{}) template.HTML { + size, class := parseOthers(28, "ui avatar image", others...) + + src := repo.RelAvatarLink() + if src != "" { + return avatarHTML(src, size, class, repo.FullName()) + } return template.HTML("") } diff --git a/templates/explore/repo_list.tmpl b/templates/explore/repo_list.tmpl index fe4b278e2c..bfec17ff29 100644 --- a/templates/explore/repo_list.tmpl +++ b/templates/explore/repo_list.tmpl @@ -1,37 +1,44 @@
{{range .Repos}}
-
- {{avatar .}} - - {{if or $.PageIsExplore $.PageIsProfileStarList }}{{if .Owner}}{{.Owner.Name}} / {{end}}{{end}}{{.Name}} - - {{if .IsArchived}} - {{$.i18n.Tr "repo.desc.archived"}} - {{end}} - {{if .IsTemplate}} - {{if .IsPrivate}} - {{$.i18n.Tr "repo.desc.private_template"}} - {{else}} - {{if .Owner.Visibility.IsPrivate}} - {{$.i18n.Tr "repo.desc.internal_template"}} - {{end}} +
+
+ {{$avatar := (repoAvatar . 32 "mr-3")}} + {{if $avatar}} + {{$avatar}} {{end}} - {{else}} - {{if .IsPrivate}} - {{$.i18n.Tr "repo.desc.private"}} - {{else}} - {{if .Owner.Visibility.IsPrivate}} - {{$.i18n.Tr "repo.desc.internal"}} + + {{if or $.PageIsExplore $.PageIsProfileStarList }}{{if .Owner}}{{.Owner.Name}} / {{end}}{{end}}{{.Name}} + +
+ {{if .IsArchived}} + {{$.i18n.Tr "repo.desc.archived"}} {{end}} - {{end}} - {{end}} - {{if .IsFork}} - {{svg "octicon-repo-forked"}} - {{else if .IsMirror}} - {{svg "octicon-mirror"}} - {{end}} -
+ {{if .IsTemplate}} + {{if .IsPrivate}} + {{$.i18n.Tr "repo.desc.private_template"}} + {{else}} + {{if .Owner.Visibility.IsPrivate}} + {{$.i18n.Tr "repo.desc.internal_template"}} + {{end}} + {{end}} + {{else}} + {{if .IsPrivate}} + {{$.i18n.Tr "repo.desc.private"}} + {{else}} + {{if .Owner.Visibility.IsPrivate}} + {{$.i18n.Tr "repo.desc.internal"}} + {{end}} + {{end}} + {{end}} + {{if .IsFork}} + {{svg "octicon-repo-forked"}} + {{else if .IsMirror}} + {{svg "octicon-mirror"}} + {{end}} +
+
+
{{if .PrimaryLanguage }} {{ .PrimaryLanguage.Language }} {{end}} diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 348c6b1ffa..8799cda655 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -2,35 +2,40 @@ {{with .Repository}}
-