Skip to content

Commit

Permalink
Remove cache avatar support and add its tests
Browse files Browse the repository at this point in the history
  • Loading branch information
unknwon committed Feb 15, 2016
1 parent fd92d91 commit 58e004f
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 390 deletions.
1 change: 1 addition & 0 deletions .bra.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ watch_dirs = [
"$WORKDIR/routers"
]
watch_exts = [".go"]
ignore_files = [".+_test.go"]
build_delay = 1500
cmds = [
["make", "build-dev"], # sqlite cert pam tidb
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ build: $(GENERATED)
go install -v -ldflags '$(LDFLAGS)' -tags '$(TAGS)'
cp '$(GOPATH)/bin/gogs' .

build-dev: $(GENERATED)
go install -v -race -tags '$(TAGS)'
cp '$(GOPATH)/bin/gogs' .

govet:
go tool vet -composites=false -methods=false -structtags=false .

build-dev: $(GENERATED) govet
go install -v -race -tags '$(TAGS)'
cp '$(GOPATH)/bin/gogs' .

pack:
rm -rf $(RELEASE_GOGS)
mkdir -p $(RELEASE_GOGS)
Expand All @@ -52,4 +52,4 @@ clean-mac: clean
find . -name ".DS_Store" -print0 | xargs -0 rm

test:
go test ./...
go test -cover -race ./...
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra

![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)

##### Current version: 0.8.35
##### Current version: 0.8.36

| Web | UI | Preview |
|:-------------:|:-------:|:-------:|
Expand Down
6 changes: 0 additions & 6 deletions cmd/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (

"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/auth"
"github.com/gogits/gogs/modules/avatar"
"github.com/gogits/gogs/modules/bindata"
"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/middleware"
Expand Down Expand Up @@ -245,11 +244,6 @@ func runWeb(ctx *cli.Context) {
})
// ***** END: User *****

// Gravatar service.
avt := avatar.CacheServer("public/img/avatar/", "public/img/avatar_default.jpg")
os.MkdirAll("public/img/avatar/", os.ModePerm)
m.Get("/avatar/:hash", avt.ServeHTTP)

adminReq := middleware.Toggle(&middleware.ToggleOptions{SignInRequire: true, AdminRequire: true})

// ***** START: Admin *****
Expand Down
2 changes: 0 additions & 2 deletions conf/app.ini
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ REGISTER_EMAIL_CONFIRM = false
DISABLE_REGISTRATION = false
; User must sign in to view anything.
REQUIRE_SIGNIN_VIEW = false
; Cache avatar as picture
ENABLE_CACHE_AVATAR = false
; Mail notification
ENABLE_NOTIFY_MAIL = false
; More detail: https://github.com/gogits/gogs/issues/165
Expand Down
2 changes: 1 addition & 1 deletion gogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)

const APP_VER = "0.8.35.0214"
const APP_VER = "0.8.36.0214"

func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
Expand Down
6 changes: 2 additions & 4 deletions models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,6 @@ func (u *User) RelAvatarLink() string {
}

return "/avatars/" + com.ToStr(u.Id)
case setting.Service.EnableCacheAvatar:
return "/avatar/" + u.Avatar
}
return setting.GravatarSource + u.Avatar
}
Expand Down Expand Up @@ -493,7 +491,7 @@ func CreateUser(u *User) (err error) {

u.LowerName = strings.ToLower(u.Name)
u.AvatarEmail = u.Email
u.Avatar = avatar.HashEmail(u.AvatarEmail)
u.Avatar = base.HashEmail(u.AvatarEmail)
u.Rands = GetUserSalt()
u.Salt = GetUserSalt()
u.EncodePasswd()
Expand Down Expand Up @@ -628,7 +626,7 @@ func updateUser(e Engine, u *User) error {
if len(u.AvatarEmail) == 0 {
u.AvatarEmail = u.Email
}
u.Avatar = avatar.HashEmail(u.AvatarEmail)
u.Avatar = base.HashEmail(u.AvatarEmail)
}

u.LowerName = strings.ToLower(u.Name)
Expand Down
Loading

0 comments on commit 58e004f

Please sign in to comment.