avatar

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2015 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

It is recommend to use this way

cacheDir := "./cache"
defaultImg := "./default.jpg"
http.Handle("/avatar/", avatar.CacheServer(cacheDir, defaultImg))

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheServer

func CacheServer(cacheDir string, defaultImgPath string) http.Handler

http.Handle("/avatar/", avatar.CacheServer("./cache"))

func HashEmail

func HashEmail(email string) string

hash email to md5 string keep this func in order to make this package independent

func RandomImage added in v0.6.5

func RandomImage(data []byte) (image.Image, error)

RandomImage generates and returns a random avatar image.

func UpdateGravatarSource added in v0.5.13

func UpdateGravatarSource()

Types

type Avatar

type Avatar struct {
	Hash       string
	AlterImage string // image path
	// contains filtered or unexported fields
}

Avatar represents the avatar object.

func New

func New(hash string, cacheDir string) *Avatar

func (*Avatar) Encode

func (this *Avatar) Encode(wr io.Writer, size int) (err error)

default image format: jpeg

func (*Avatar) Expired

func (this *Avatar) Expired() bool

func (*Avatar) HasCache

func (this *Avatar) HasCache() bool

func (*Avatar) Modtime

func (this *Avatar) Modtime() (modtime time.Time, err error)

func (*Avatar) Update

func (this *Avatar) Update()

get image from gravatar.com

func (*Avatar) UpdateTimeout

func (this *Avatar) UpdateTimeout(timeout time.Duration) (err error)

type Thunder

type Thunder struct {
	QueueSize int // download queue size
	// contains filtered or unexported fields
}

func (*Thunder) Fetch

func (t *Thunder) Fetch(url string, saveFile string) error

func (*Thunder) GoFetch

func (t *Thunder) GoFetch(url, saveFile string) chan error

Jump to

Keyboard shortcuts

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