@ -340,6 +340,7 @@ func NewFuncMap() []template.FuncMap {
} ,
} ,
"svg" : SVG ,
"svg" : SVG ,
"avatar" : Avatar ,
"avatar" : Avatar ,
"avatarHTML" : AvatarHTML ,
"avatarByEmail" : AvatarByEmail ,
"avatarByEmail" : AvatarByEmail ,
"repoAvatar" : RepoAvatar ,
"repoAvatar" : RepoAvatar ,
"SortArrow" : func ( normSort , revSort , urlSort string , isDefault bool ) template . HTML {
"SortArrow" : func ( normSort , revSort , urlSort string , isDefault bool ) template . HTML {
@ -519,7 +520,8 @@ func parseOthers(defaultSize int, defaultClass string, others ...interface{}) (i
return size , class
return size , class
}
}
func avatarHTML ( src string , size int , class string , name string ) template . HTML {
// AvatarHTML creates the HTML for an avatar
func AvatarHTML ( src string , size int , class string , name string ) template . HTML {
sizeStr := fmt . Sprintf ( ` %d ` , size )
sizeStr := fmt . Sprintf ( ` %d ` , size )
if name == "" {
if name == "" {
@ -548,33 +550,33 @@ func SVG(icon string, others ...interface{}) template.HTML {
// Avatar renders user avatars. args: user, size (int), class (string)
// Avatar renders user avatars. args: user, size (int), class (string)
func Avatar ( user * models . User , others ... interface { } ) template . HTML {
func Avatar ( user * models . User , others ... interface { } ) template . HTML {
size , class := parseOthers ( 28 , "ui avatar image" , others ... )
size , class := parseOthers ( models . DefaultAvatarPixelSize , "ui avatar image" , others ... )
src := user . RealSizedAvatarLink ( size * 2 ) // request double size for finer rendering
src := user . RealSizedAvatarLink ( size * models . AvatarRenderedSizeFactor )
if src != "" {
if src != "" {
return a vatarHTML( src , size , class , user . DisplayName ( ) )
return A vatarHTML( src , size , class , user . DisplayName ( ) )
}
}
return template . HTML ( "" )
return template . HTML ( "" )
}
}
// RepoAvatar renders repo avatars. args: repo, size(int), class (string)
// RepoAvatar renders repo avatars. args: repo, size(int), class (string)
func RepoAvatar ( repo * models . Repository , others ... interface { } ) template . HTML {
func RepoAvatar ( repo * models . Repository , others ... interface { } ) template . HTML {
size , class := parseOthers ( 28 , "ui avatar image" , others ... )
size , class := parseOthers ( models . DefaultAvatarPixelSize , "ui avatar image" , others ... )
src := repo . RelAvatarLink ( )
src := repo . RelAvatarLink ( )
if src != "" {
if src != "" {
return a vatarHTML( src , size , class , repo . FullName ( ) )
return A vatarHTML( src , size , class , repo . FullName ( ) )
}
}
return template . HTML ( "" )
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 ( email string , name string , others ... interface { } ) template . HTML {
func AvatarByEmail ( email string , name string , others ... interface { } ) template . HTML {
size , class := parseOthers ( 28 , "ui avatar image" , others ... )
size , class := parseOthers ( models . DefaultAvatarPixelSize , "ui avatar image" , others ... )
src := models . SizedAvatarLink ( email , size * 2 ) // request double size for finer rendering
src := models . SizedAvatarLink ( email , size * models . AvatarRenderedSizeFactor )
if src != "" {
if src != "" {
return a vatarHTML( src , size , class , name )
return A vatarHTML( src , size , class , name )
}
}
return template . HTML ( "" )
return template . HTML ( "" )