diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-11-16 21:32:26 -0500 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-11-16 21:32:26 -0500 |
commit | a0f9197b4573aa9d4d868637ed00e710a435797b (patch) | |
tree | 41efdcb5813cdb1a66bd1fc3bc5c86a371c7815b /modules/avatar/avatar.go | |
parent | 340a4595ddc9e08f4c51f40496affb8fd3bb013d (diff) | |
download | gitea-a0f9197b4573aa9d4d868637ed00e710a435797b.tar.gz gitea-a0f9197b4573aa9d4d868637ed00e710a435797b.zip |
GetFile api
Diffstat (limited to 'modules/avatar/avatar.go')
-rw-r--r-- | modules/avatar/avatar.go | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/modules/avatar/avatar.go b/modules/avatar/avatar.go index 5ed5d16a62..fb198da149 100644 --- a/modules/avatar/avatar.go +++ b/modules/avatar/avatar.go @@ -33,11 +33,17 @@ import ( "github.com/nfnt/resize" "github.com/gogits/gogs/modules/log" + "github.com/gogits/gogs/modules/setting" ) -var ( - gravatar = "http://www.gravatar.com/avatar" -) +var gravatarSource string + +func init() { + gravatarSource = setting.GravatarSource + if !strings.HasPrefix(gravatarSource, "http:") { + gravatarSource = "http:" + gravatarSource + } +} // hash email to md5 string // keep this func in order to make this package indenpent @@ -121,7 +127,7 @@ func (this *Avatar) Encode(wr io.Writer, size int) (err error) { // get image from gravatar.com func (this *Avatar) Update() { - thunder.Fetch(gravatar+"/"+this.Hash+"?"+this.reqParams, + thunder.Fetch(gravatarSource+this.Hash+"?"+this.reqParams, this.imagePath) } @@ -129,7 +135,7 @@ func (this *Avatar) UpdateTimeout(timeout time.Duration) (err error) { select { case <-time.After(timeout): err = fmt.Errorf("get gravatar image %s timeout", this.Hash) - case err = <-thunder.GoFetch(gravatar+"/"+this.Hash+"?"+this.reqParams, + case err = <-thunder.GoFetch(gravatarSource+this.Hash+"?"+this.reqParams, this.imagePath): } return err |