@ -341,6 +341,7 @@ func NewFuncMap() []template.FuncMap {
"svg" : SVG ,
"svg" : SVG ,
"avatar" : Avatar ,
"avatar" : Avatar ,
"avatarByEmail" : AvatarByEmail ,
"avatarByEmail" : AvatarByEmail ,
"repoAvatar" : RepoAvatar ,
"SortArrow" : func ( normSort , revSort , urlSort string , isDefault bool ) template . HTML {
"SortArrow" : func ( normSort , revSort , urlSort string , isDefault bool ) template . HTML {
// if needed
// if needed
if len ( normSort ) == 0 || len ( urlSort ) == 0 {
if len ( normSort ) == 0 || len ( urlSort ) == 0 {
@ -545,23 +546,25 @@ func SVG(icon string, others ...interface{}) template.HTML {
return template . HTML ( "" )
return template . HTML ( "" )
}
}
// Avatar renders user and repo a vatars. args: user/repo , size (int), class (string)
// Avatar renders user avatars. args: user, size (int), class (string)
func Avatar ( item interface { } , others ... interface { } ) template . HTML {
func Avatar ( user * models . User , others ... interface { } ) template . HTML {
size , class := parseOthers ( 28 , "ui avatar image" , others ... )
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 := user . RealSizedAvatarLink ( size * 2 ) // request double size for finer rendering
src := repo . RelAvatarLink ( )
if src != "" {
if src != "" {
return avatarHTML ( src , size , class , user . DisplayName ( ) )
return avatarHTML ( src , size , class , repo . FullName ( ) )
}
}
}
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 ( "" )
return template . HTML ( "" )
}
}