avatars

package
v1.20.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2023 License: MIT Imports: 12 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// DefaultAvatarClass is the default class of a rendered avatar
	DefaultAvatarClass = "ui avatar gt-vm"
	// DefaultAvatarPixelSize is the default size in pixels of a rendered avatar
	DefaultAvatarPixelSize = 28
)

Variables

This section is empty.

Functions

func DefaultAvatarLink() string

DefaultAvatarLink the default avatar link

func GenerateEmailAvatarFastLink(ctx context.Context, email string, size int) string

GenerateEmailAvatarFastLink returns a avatar link (fast, the link may be a delegated one: "/avatar/${hash}")

func GenerateEmailAvatarFinalLink(ctx context.Context, email string, size int) string

GenerateEmailAvatarFinalLink returns a avatar final link (maybe slow)

func GenerateUserAvatarFastLink(userName string, size int) string

GenerateUserAvatarFastLink returns a fast link (302) to the user's avatar: "/user/avatar/${User.Name}/${size}"

func GenerateUserAvatarImageLink(userAvatar string, size int) string

GenerateUserAvatarImageLink returns a link for `User.Avatar` image file: "/avatars/${User.Avatar}"

func GetEmailForHash

func GetEmailForHash(md5Sum string) (string, error)

GetEmailForHash converts a provided md5sum to the email

func HashEmail

func HashEmail(email string) string

HashEmail hashes email address to MD5 string. https://en.gravatar.com/site/implement/hash/

func LibravatarURL

func LibravatarURL(email string) (*url.URL, error)

LibravatarURL returns the URL for the given email. Slow due to the DNS lookup. This function should only be called if a federated avatar service is enabled.

Types

type EmailHash

type EmailHash struct {
	Hash  string `xorm:"pk varchar(32)"`
	Email string `xorm:"UNIQUE NOT NULL"`
}

EmailHash represents a pre-generated hash map (mainly used by LibravatarURL, it queries email server's DNS records)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL