Browse Source

#3393 fix missing sub-url prefix in relative avatar link

pull/3403/head
Unknwon 9 years ago
parent
commit
ec92565f23
  1. 2
      README.md
  2. 2
      gogs.go
  3. 2
      models/pull.go
  4. 9
      models/user.go
  5. 40
      modules/bindata/bindata.go
  6. 1
      modules/setting/setting.go
  7. 1
      scripts/README
  8. 2
      templates/.VERSION

2
README.md

@ -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 tip version: 0.9.64 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions)
##### Current tip version: 0.9.65 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions)
| Web | UI | Preview |
|:-------------:|:-------:|:-------:|

2
gogs.go

@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)
const APP_VER = "0.9.64.0805"
const APP_VER = "0.9.65.0806"
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())

2
models/pull.go

@ -246,7 +246,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error
Sender: &api.PayloadUser{
UserName: doer.Name,
ID: doer.ID,
AvatarUrl: setting.AppUrl + doer.RelAvatarLink(),
AvatarUrl: doer.AvatarLink(),
},
}
if err = PrepareWebhooks(pr.BaseRepo, HOOK_EVENT_PUSH, p); err != nil {

9
models/user.go

@ -230,8 +230,11 @@ func (u *User) GenerateRandomAvatar() error {
return nil
}
// RelAvatarLink returns relative avatar link to the site domain,
// which includes app sub-url as prefix. However, it is possible
// to return full URL if user enables Gravatar-like service.
func (u *User) RelAvatarLink() string {
defaultImgUrl := "/img/avatar_default.png"
defaultImgUrl := setting.AppSubUrl + "/img/avatar_default.png"
if u.ID == -1 {
return defaultImgUrl
}
@ -241,7 +244,7 @@ func (u *User) RelAvatarLink() string {
if !com.IsExist(u.CustomAvatarPath()) {
return defaultImgUrl
}
return "/avatars/" + com.ToStr(u.ID)
return setting.AppSubUrl + "/avatars/" + com.ToStr(u.ID)
case setting.DisableGravatar, setting.OfflineMode:
if !com.IsExist(u.CustomAvatarPath()) {
if err := u.GenerateRandomAvatar(); err != nil {
@ -249,7 +252,7 @@ func (u *User) RelAvatarLink() string {
}
}
return "/avatars/" + com.ToStr(u.ID)
return setting.AppSubUrl + "/avatars/" + com.ToStr(u.ID)
}
return setting.GravatarSource + u.Avatar
}

40
modules/bindata/bindata.go

File diff suppressed because one or more lines are too long

1
modules/setting/setting.go

@ -334,6 +334,7 @@ func NewContext() {
log.Fatal(4, "Invalid ROOT_URL '%s': %s", AppUrl, err)
}
// Suburl should start with '/' and end without '/', such as '/{subpath}'.
// This value is empty if site does not have sub-url.
AppSubUrl = strings.TrimSuffix(url.Path, "/")
AppSubUrlDepth = strings.Count(AppSubUrl, "/")

1
scripts/README

@ -0,0 +1 @@
All files in subdirectories are templates, do modifications based on your environment first.

2
templates/.VERSION

@ -1 +1 @@
0.9.64.0805
0.9.65.0806
Loading…
Cancel
Save