mirror of
https://github.com/gogs/gogs.git
synced 2026-07-01 00:18:37 +02:00
pkg/template: fix Gravatar URLs are badly generated (#5157)
This commit is contained in:
2
gogs.go
2
gogs.go
@@ -16,7 +16,7 @@ import (
|
||||
"github.com/gogits/gogs/pkg/setting"
|
||||
)
|
||||
|
||||
const APP_VER = "0.11.45.0416"
|
||||
const APP_VER = "0.11.46.0418"
|
||||
|
||||
func init() {
|
||||
setting.AppVer = APP_VER
|
||||
|
||||
@@ -60,14 +60,15 @@ func NewFuncMap() []template.FuncMap {
|
||||
"LoadTimes": func(startTime time.Time) string {
|
||||
return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms"
|
||||
},
|
||||
"AvatarLink": tool.AvatarLink,
|
||||
"Safe": Safe,
|
||||
"Sanitize": bluemonday.UGCPolicy().Sanitize,
|
||||
"Str2html": Str2html,
|
||||
"TimeSince": tool.TimeSince,
|
||||
"RawTimeSince": tool.RawTimeSince,
|
||||
"FileSize": tool.FileSize,
|
||||
"Subtract": tool.Subtract,
|
||||
"AvatarLink": tool.AvatarLink,
|
||||
"AppendAvatarSize": tool.AppendAvatarSize,
|
||||
"Safe": Safe,
|
||||
"Sanitize": bluemonday.UGCPolicy().Sanitize,
|
||||
"Str2html": Str2html,
|
||||
"TimeSince": tool.TimeSince,
|
||||
"RawTimeSince": tool.RawTimeSince,
|
||||
"FileSize": tool.FileSize,
|
||||
"Subtract": tool.Subtract,
|
||||
"Add": func(a, b int) int {
|
||||
return a + b
|
||||
},
|
||||
|
||||
@@ -207,6 +207,14 @@ func AvatarLink(email string) (url string) {
|
||||
return url
|
||||
}
|
||||
|
||||
// AppendAvatarSize appends avatar size query parameter to the URL in the correct format.
|
||||
func AppendAvatarSize(url string, size int) string {
|
||||
if strings.Contains(url, "?") {
|
||||
return url + "&s=" + com.ToStr(size)
|
||||
}
|
||||
return url + "?s=" + com.ToStr(size)
|
||||
}
|
||||
|
||||
// Seconds-based time units
|
||||
const (
|
||||
Minute = 60
|
||||
|
||||
@@ -1 +1 @@
|
||||
0.11.45.0416
|
||||
0.11.46.0418
|
||||
@@ -6,11 +6,11 @@
|
||||
<div class="ui card">
|
||||
{{if eq .LoggedUserName .Owner.Name}}
|
||||
<a class="image poping up" href="{{AppSubURL}}/user/settings/avatar" id="profile-avatar" data-content="{{.i18n.Tr "user.change_avatar"}}" data-variation="inverted tiny" data-position="bottom center">
|
||||
<img src="{{.Owner.RelAvatarLink}}?s=290" title="{{.Owner.Name}}"/>
|
||||
<img src="{{AppendAvatarSize .Owner.RelAvatarLink 290}}" title="{{.Owner.Name}}"/>
|
||||
</a>
|
||||
{{else}}
|
||||
<span class="image">
|
||||
<img src="{{.Owner.RelAvatarLink}}?s=290" title="{{.Owner.Name}}"/>
|
||||
<img src="{{AppendAvatarSize .Owner.RelAvatarLink 290}}" title="{{.Owner.Name}}"/>
|
||||
</span>
|
||||
{{end}}
|
||||
<div class="content">
|
||||
|
||||
Reference in New Issue
Block a user