1
1
mirror of https://github.com/go-gitea/gitea.git synced 2024-11-18 02:54:44 +01:00

minor fix on #1432

This commit is contained in:
Unknwon 2015-08-04 09:13:37 +08:00
parent 96c1ce9606
commit e6792796cc
2 changed files with 8 additions and 20 deletions

@ -24,7 +24,9 @@ github.com/macaron-contrib/oauth2 = commit:8f394c3629
github.com/macaron-contrib/session = commit:e48134e803 github.com/macaron-contrib/session = commit:e48134e803
github.com/macaron-contrib/toolbox = commit:acbfe36e16 github.com/macaron-contrib/toolbox = commit:acbfe36e16
github.com/mattn/go-sqlite3 = commit:e28cd440fa github.com/mattn/go-sqlite3 = commit:e28cd440fa
github.com/mcuadros/go-version
github.com/microcosm-cc/bluemonday = commit:2b7763a06c github.com/microcosm-cc/bluemonday = commit:2b7763a06c
github.com/mssola/user_agent = commit:f659b98638
github.com/msteinert/pam = commit:9a42d39dbf github.com/msteinert/pam = commit:9a42d39dbf
github.com/nfnt/resize = commit:dc93e1b98c github.com/nfnt/resize = commit:dc93e1b98c
github.com/russross/blackfriday = commit:8cec3a854e github.com/russross/blackfriday = commit:8cec3a854e
@ -33,8 +35,6 @@ golang.org/x/net = commit:937a34c9de13
golang.org/x/text = commit:5b2527008a4c golang.org/x/text = commit:5b2527008a4c
gopkg.in/ini.v1 = commit:caf3f03ad9 gopkg.in/ini.v1 = commit:caf3f03ad9
gopkg.in/redis.v2 = commit:e617904962 gopkg.in/redis.v2 = commit:e617904962
github.com/hashicorp/go-version = commit:999359b6b7
github.com/mssola/user_agent = commit:f659b98638
[res] [res]
include = etc|public|scripts|templates include = etc|public|scripts|templates

@ -10,15 +10,14 @@ import (
"strings" "strings"
"github.com/Unknwon/macaron" "github.com/Unknwon/macaron"
"github.com/mcuadros/go-version"
"github.com/mssola/user_agent"
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/git" "github.com/gogits/gogs/modules/git"
"github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/modules/setting"
"github.com/hashicorp/go-version"
"github.com/mssola/user_agent"
) )
const ( const (
@ -355,22 +354,11 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
ctx.Data["CommitId"] = ctx.Repo.CommitId ctx.Data["CommitId"] = ctx.Repo.CommitId
userAgent := ctx.Req.Header.Get("User-Agent") userAgent := ctx.Req.Header.Get("User-Agent")
ua := user_agent.New(userAgent); ua := user_agent.New(userAgent)
browserName, browserVer := ua.Browser() browserName, browserVer := ua.Browser()
sliceVer := strings.Split(browserVer, ".") ctx.Data["BrowserSupportsCopy"] = (browserName == "Chrome" && version.Compare(browserVer, CHROME_COPY_SUPPORT, ">=")) ||
var max int (browserName == "Firefox" && version.Compare(browserVer, FIREFOX_COPY_SUPPORT, ">="))
if max = len(sliceVer); 3 < max {
max = 3
}
browserVer = strings.Join(sliceVer[:max], ".")
browserVersion, err := version.NewVersion(browserVer)
chromeConstraint, err := version.NewConstraint(">= " + CHROME_COPY_SUPPORT)
firefoxConstraint, err := version.NewConstraint(">= " + FIREFOX_COPY_SUPPORT)
ctx.Data["BrowserSupportsCopy"] = (browserName == "Chrome" && chromeConstraint.Check(browserVersion)) || (browserName == "Firefox" && firefoxConstraint.Check(browserVersion))
} }
} }