Golint fixed for modules/setting (#262)
* golint fixed for modules/setting * typo fixed and renamed UNIXSOCKET to UnixSocket
This commit is contained in:
parent
0a76d260fa
commit
94da472717
38 changed files with 178 additions and 167 deletions
|
@ -217,7 +217,7 @@ func AvatarLink(email string) string {
|
|||
return setting.GravatarSource + HashEmail(email)
|
||||
}
|
||||
|
||||
return setting.AppSubUrl + "/img/avatar_default.png"
|
||||
return setting.AppSubURL + "/img/avatar_default.png"
|
||||
}
|
||||
|
||||
// Seconds-based time units
|
||||
|
|
|
@ -47,16 +47,16 @@ func (ctx *APIContext) SetLinkHeader(total, pageSize int) {
|
|||
page := paginater.New(total, pageSize, ctx.QueryInt("page"), 0)
|
||||
links := make([]string, 0, 4)
|
||||
if page.HasNext() {
|
||||
links = append(links, fmt.Sprintf("<%s%s?page=%d>; rel=\"next\"", setting.AppUrl, ctx.Req.URL.Path[1:], page.Next()))
|
||||
links = append(links, fmt.Sprintf("<%s%s?page=%d>; rel=\"next\"", setting.AppURL, ctx.Req.URL.Path[1:], page.Next()))
|
||||
}
|
||||
if !page.IsLast() {
|
||||
links = append(links, fmt.Sprintf("<%s%s?page=%d>; rel=\"last\"", setting.AppUrl, ctx.Req.URL.Path[1:], page.TotalPages()))
|
||||
links = append(links, fmt.Sprintf("<%s%s?page=%d>; rel=\"last\"", setting.AppURL, ctx.Req.URL.Path[1:], page.TotalPages()))
|
||||
}
|
||||
if !page.IsFirst() {
|
||||
links = append(links, fmt.Sprintf("<%s%s?page=1>; rel=\"first\"", setting.AppUrl, ctx.Req.URL.Path[1:]))
|
||||
links = append(links, fmt.Sprintf("<%s%s?page=1>; rel=\"first\"", setting.AppURL, ctx.Req.URL.Path[1:]))
|
||||
}
|
||||
if page.HasPrevious() {
|
||||
links = append(links, fmt.Sprintf("<%s%s?page=%d>; rel=\"prev\"", setting.AppUrl, ctx.Req.URL.Path[1:], page.Previous()))
|
||||
links = append(links, fmt.Sprintf("<%s%s?page=%d>; rel=\"prev\"", setting.AppURL, ctx.Req.URL.Path[1:], page.Previous()))
|
||||
}
|
||||
|
||||
if len(links) > 0 {
|
||||
|
|
|
@ -26,7 +26,7 @@ func Toggle(options *ToggleOptions) macaron.Handler {
|
|||
return func(ctx *Context) {
|
||||
// Cannot view any page before installation.
|
||||
if !setting.InstallLock {
|
||||
ctx.Redirect(setting.AppSubUrl + "/install")
|
||||
ctx.Redirect(setting.AppSubURL + "/install")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -38,14 +38,14 @@ func Toggle(options *ToggleOptions) macaron.Handler {
|
|||
}
|
||||
|
||||
// Check non-logged users landing page.
|
||||
if !ctx.IsSigned && ctx.Req.RequestURI == "/" && setting.LandingPageURL != setting.LANDING_PAGE_HOME {
|
||||
ctx.Redirect(setting.AppSubUrl + string(setting.LandingPageURL))
|
||||
if !ctx.IsSigned && ctx.Req.RequestURI == "/" && setting.LandingPageURL != setting.LandingPageHome {
|
||||
ctx.Redirect(setting.AppSubURL + string(setting.LandingPageURL))
|
||||
return
|
||||
}
|
||||
|
||||
// Redirect to dashboard if user tries to visit any non-login page.
|
||||
if options.SignOutRequired && ctx.IsSigned && ctx.Req.RequestURI != "/" {
|
||||
ctx.Redirect(setting.AppSubUrl + "/")
|
||||
ctx.Redirect(setting.AppSubURL + "/")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -66,8 +66,8 @@ func Toggle(options *ToggleOptions) macaron.Handler {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.SetCookie("redirect_to", url.QueryEscape(setting.AppSubUrl+ctx.Req.RequestURI), 0, setting.AppSubUrl)
|
||||
ctx.Redirect(setting.AppSubUrl + "/user/login")
|
||||
ctx.SetCookie("redirect_to", url.QueryEscape(setting.AppSubURL+ctx.Req.RequestURI), 0, setting.AppSubURL)
|
||||
ctx.Redirect(setting.AppSubURL + "/user/login")
|
||||
return
|
||||
} else if !ctx.User.IsActive && setting.Service.RegisterEmailConfirm {
|
||||
ctx.Data["Title"] = ctx.Tr("auth.active_your_account")
|
||||
|
@ -79,8 +79,8 @@ func Toggle(options *ToggleOptions) macaron.Handler {
|
|||
// Redirect to log in page if auto-signin info is provided and has not signed in.
|
||||
if !options.SignOutRequired && !ctx.IsSigned && !auth.IsAPIPath(ctx.Req.URL.Path) &&
|
||||
len(ctx.GetCookie(setting.CookieUserName)) > 0 {
|
||||
ctx.SetCookie("redirect_to", url.QueryEscape(setting.AppSubUrl+ctx.Req.RequestURI), 0, setting.AppSubUrl)
|
||||
ctx.Redirect(setting.AppSubUrl + "/user/login")
|
||||
ctx.SetCookie("redirect_to", url.QueryEscape(setting.AppSubURL+ctx.Req.RequestURI), 0, setting.AppSubURL)
|
||||
ctx.Redirect(setting.AppSubURL + "/user/login")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ func Contexter() macaron.Handler {
|
|||
Org: &Organization{},
|
||||
}
|
||||
// Compute current URL for real-time change language.
|
||||
ctx.Data["Link"] = setting.AppSubUrl + strings.TrimSuffix(ctx.Req.URL.Path, "/")
|
||||
ctx.Data["Link"] = setting.AppSubURL + strings.TrimSuffix(ctx.Req.URL.Path, "/")
|
||||
|
||||
ctx.Data["PageStartTime"] = time.Now()
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
|
|||
ctx.Data["IsOrganizationOwner"] = ctx.Org.IsOwner
|
||||
ctx.Data["IsOrganizationMember"] = ctx.Org.IsMember
|
||||
|
||||
ctx.Org.OrgLink = setting.AppSubUrl + "/org/" + org.Name
|
||||
ctx.Org.OrgLink = setting.AppSubURL + "/org/" + org.Name
|
||||
ctx.Data["OrgLink"] = ctx.Org.OrgLink
|
||||
|
||||
// Team.
|
||||
|
|
|
@ -117,7 +117,7 @@ func RetrieveBaseRepo(ctx *Context, repo *models.Repository) {
|
|||
|
||||
// composeGoGetImport returns go-get-import meta content.
|
||||
func composeGoGetImport(owner, repo string) string {
|
||||
return path.Join(setting.Domain, setting.AppSubUrl, owner, repo)
|
||||
return path.Join(setting.Domain, setting.AppSubURL, owner, repo)
|
||||
}
|
||||
|
||||
// earlyResponseForGoGetMeta responses appropriate go-get meta with status 200
|
||||
|
@ -331,7 +331,7 @@ func RepoAssignment(args ...bool) macaron.Handler {
|
|||
|
||||
if ctx.Query("go-get") == "1" {
|
||||
ctx.Data["GoGetImport"] = composeGoGetImport(owner.Name, repo.Name)
|
||||
prefix := setting.AppUrl + path.Join(owner.Name, repo.Name, "src", ctx.Repo.BranchName)
|
||||
prefix := setting.AppURL + path.Join(owner.Name, repo.Name, "src", ctx.Repo.BranchName)
|
||||
ctx.Data["GoDocDirectory"] = prefix + "{/dir}"
|
||||
ctx.Data["GoDocFile"] = prefix + "{/dir}/{file}#L{line}"
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ func (r *Renderer) AutoLink(out *bytes.Buffer, link []byte, kind int) {
|
|||
|
||||
// Since this method could only possibly serve one link at a time,
|
||||
// we do not need to find all.
|
||||
if bytes.HasPrefix(link, []byte(setting.AppUrl)) {
|
||||
if bytes.HasPrefix(link, []byte(setting.AppURL)) {
|
||||
m := CommitPattern.Find(link)
|
||||
if m != nil {
|
||||
m = bytes.TrimSpace(m)
|
||||
|
@ -225,7 +225,7 @@ func cutoutVerbosePrefix(prefix string) string {
|
|||
if prefix[i] == '/' {
|
||||
count++
|
||||
}
|
||||
if count >= 3+setting.AppSubUrlDepth {
|
||||
if count >= 3+setting.AppSubURLDepth {
|
||||
return prefix[:i]
|
||||
}
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ func RenderSpecialLink(rawBytes []byte, urlPrefix string, metas map[string]strin
|
|||
for _, m := range ms {
|
||||
m = m[bytes.Index(m, []byte("@")):]
|
||||
rawBytes = bytes.Replace(rawBytes, m,
|
||||
[]byte(fmt.Sprintf(`<a href="%s/%s">%s</a>`, setting.AppSubUrl, m[1:], m)), -1)
|
||||
[]byte(fmt.Sprintf(`<a href="%s/%s">%s</a>`, setting.AppSubURL, m[1:], m)), -1)
|
||||
}
|
||||
|
||||
rawBytes = RenderIssueIndexPattern(rawBytes, urlPrefix, metas)
|
||||
|
|
|
@ -16,7 +16,7 @@ func TestMarkdown(t *testing.T) {
|
|||
urlPrefix = "/prefix"
|
||||
metas map[string]string = nil
|
||||
)
|
||||
setting.AppSubUrlDepth = 0
|
||||
setting.AppSubURLDepth = 0
|
||||
|
||||
Convey("To the internal issue tracker", func() {
|
||||
Convey("It should not render anything when there are no mentions", func() {
|
||||
|
@ -237,7 +237,7 @@ func TestMarkdown(t *testing.T) {
|
|||
})
|
||||
|
||||
Convey("Rendering an issue URL", t, func() {
|
||||
setting.AppUrl = "http://localhost:3000/"
|
||||
setting.AppURL = "http://localhost:3000/"
|
||||
htmlFlags := 0
|
||||
htmlFlags |= blackfriday.HTML_SKIP_STYLE
|
||||
htmlFlags |= blackfriday.HTML_OMIT_CONTENTS
|
||||
|
@ -279,7 +279,7 @@ func TestMarkdown(t *testing.T) {
|
|||
})
|
||||
|
||||
Convey("Rendering a commit URL", t, func() {
|
||||
setting.AppUrl = "http://localhost:3000/"
|
||||
setting.AppURL = "http://localhost:3000/"
|
||||
htmlFlags := 0
|
||||
htmlFlags |= blackfriday.HTML_SKIP_STYLE
|
||||
htmlFlags |= blackfriday.HTML_OMIT_CONTENTS
|
||||
|
|
|
@ -18,10 +18,10 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/Unknwon/com"
|
||||
_ "github.com/go-macaron/cache/memcache"
|
||||
_ "github.com/go-macaron/cache/memcache" // memcache plugin for cache
|
||||
_ "github.com/go-macaron/cache/redis"
|
||||
"github.com/go-macaron/session"
|
||||
_ "github.com/go-macaron/session/redis"
|
||||
_ "github.com/go-macaron/session/redis" // redis plugin for store session
|
||||
"gopkg.in/ini.v1"
|
||||
"strk.kbt.io/projects/go/libravatar"
|
||||
|
||||
|
@ -30,44 +30,51 @@ import (
|
|||
"code.gitea.io/gitea/modules/user"
|
||||
)
|
||||
|
||||
// Scheme describes protocol types
|
||||
type Scheme string
|
||||
|
||||
// enumerates all the scheme types
|
||||
const (
|
||||
HTTP Scheme = "http"
|
||||
HTTPS Scheme = "https"
|
||||
FCGI Scheme = "fcgi"
|
||||
UNIX_SOCKET Scheme = "unix"
|
||||
HTTP Scheme = "http"
|
||||
HTTPS Scheme = "https"
|
||||
FCGI Scheme = "fcgi"
|
||||
UnixSocket Scheme = "unix"
|
||||
)
|
||||
|
||||
// LandingPage describes the default page
|
||||
type LandingPage string
|
||||
|
||||
// enumerates all the landing page types
|
||||
const (
|
||||
LANDING_PAGE_HOME LandingPage = "/"
|
||||
LANDING_PAGE_EXPLORE LandingPage = "/explore"
|
||||
LandingPageHome LandingPage = "/"
|
||||
LandingPageExplore LandingPage = "/explore"
|
||||
)
|
||||
|
||||
// settings
|
||||
var (
|
||||
// Build information should only be set by -ldflags.
|
||||
// BuildTime information should only be set by -ldflags.
|
||||
BuildTime string
|
||||
BuildGitHash string
|
||||
|
||||
// App settings
|
||||
// AppVer settings
|
||||
AppVer string
|
||||
AppName string
|
||||
AppUrl string
|
||||
AppSubUrl string
|
||||
AppSubUrlDepth int // Number of slashes
|
||||
AppURL string
|
||||
AppSubURL string
|
||||
AppSubURLDepth int // Number of slashes
|
||||
AppPath string
|
||||
AppDataPath string
|
||||
|
||||
// Server settings
|
||||
Protocol Scheme
|
||||
Domain string
|
||||
HTTPAddr, HTTPPort string
|
||||
HTTPAddr string
|
||||
HTTPPort string
|
||||
LocalURL string
|
||||
OfflineMode bool
|
||||
DisableRouterLog bool
|
||||
CertFile, KeyFile string
|
||||
CertFile string
|
||||
KeyFile string
|
||||
StaticRootPath string
|
||||
EnableGzip bool
|
||||
LandingPageURL LandingPage
|
||||
|
@ -242,8 +249,9 @@ var (
|
|||
}
|
||||
|
||||
// I18n settings
|
||||
Langs, Names []string
|
||||
dateLangs map[string]string
|
||||
Langs []string
|
||||
Names []string
|
||||
dateLangs map[string]string
|
||||
|
||||
// Highlight settings are loaded in modules/template/hightlight.go
|
||||
|
||||
|
@ -386,20 +394,20 @@ please consider changing to GITEA_CUSTOM`)
|
|||
|
||||
sec := Cfg.Section("server")
|
||||
AppName = Cfg.Section("").Key("APP_NAME").MustString("Gogs: Go Git Service")
|
||||
AppUrl = sec.Key("ROOT_URL").MustString("http://localhost:3000/")
|
||||
if AppUrl[len(AppUrl)-1] != '/' {
|
||||
AppUrl += "/"
|
||||
AppURL = sec.Key("ROOT_URL").MustString("http://localhost:3000/")
|
||||
if AppURL[len(AppURL)-1] != '/' {
|
||||
AppURL += "/"
|
||||
}
|
||||
|
||||
// Check if has app suburl.
|
||||
url, err := url.Parse(AppUrl)
|
||||
url, err := url.Parse(AppURL)
|
||||
if err != nil {
|
||||
log.Fatal(4, "Invalid ROOT_URL '%s': %s", AppUrl, err)
|
||||
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, "/")
|
||||
AppSubURL = strings.TrimSuffix(url.Path, "/")
|
||||
AppSubURLDepth = strings.Count(AppSubURL, "/")
|
||||
|
||||
Protocol = HTTP
|
||||
if sec.Key("PROTOCOL").String() == "https" {
|
||||
|
@ -409,7 +417,7 @@ please consider changing to GITEA_CUSTOM`)
|
|||
} else if sec.Key("PROTOCOL").String() == "fcgi" {
|
||||
Protocol = FCGI
|
||||
} else if sec.Key("PROTOCOL").String() == "unix" {
|
||||
Protocol = UNIX_SOCKET
|
||||
Protocol = UnixSocket
|
||||
UnixSocketPermissionRaw := sec.Key("UNIX_SOCKET_PERMISSION").MustString("666")
|
||||
UnixSocketPermissionParsed, err := strconv.ParseUint(UnixSocketPermissionRaw, 8, 32)
|
||||
if err != nil || UnixSocketPermissionParsed > 0777 {
|
||||
|
@ -429,9 +437,9 @@ please consider changing to GITEA_CUSTOM`)
|
|||
|
||||
switch sec.Key("LANDING_PAGE").MustString("home") {
|
||||
case "explore":
|
||||
LandingPageURL = LANDING_PAGE_EXPLORE
|
||||
LandingPageURL = LandingPageExplore
|
||||
default:
|
||||
LandingPageURL = LANDING_PAGE_HOME
|
||||
LandingPageURL = LandingPageHome
|
||||
}
|
||||
|
||||
SSH.RootPath = path.Join(homeDir, ".ssh")
|
||||
|
@ -596,6 +604,7 @@ please consider changing to GITEA_CUSTOM`)
|
|||
HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt"))
|
||||
}
|
||||
|
||||
// Service settings
|
||||
var Service struct {
|
||||
ActiveCodeLives int
|
||||
ResetPwdCodeLives int
|
||||
|
@ -719,7 +728,7 @@ func newSessionService() {
|
|||
[]string{"memory", "file", "redis", "mysql"})
|
||||
SessionConfig.ProviderConfig = strings.Trim(Cfg.Section("session").Key("PROVIDER_CONFIG").String(), "\" ")
|
||||
SessionConfig.CookieName = Cfg.Section("session").Key("COOKIE_NAME").MustString("i_like_gogits")
|
||||
SessionConfig.CookiePath = AppSubUrl
|
||||
SessionConfig.CookiePath = AppSubURL
|
||||
SessionConfig.Secure = Cfg.Section("session").Key("COOKIE_SECURE").MustBool()
|
||||
SessionConfig.Gclifetime = Cfg.Section("session").Key("GC_INTERVAL_TIME").MustInt64(86400)
|
||||
SessionConfig.Maxlifetime = Cfg.Section("session").Key("SESSION_LIFE_TIME").MustInt64(86400)
|
||||
|
@ -744,6 +753,7 @@ type Mailer struct {
|
|||
}
|
||||
|
||||
var (
|
||||
// MailService the global mailer
|
||||
MailService *Mailer
|
||||
)
|
||||
|
||||
|
@ -810,6 +820,7 @@ func newWebhookService() {
|
|||
Webhook.PagingNum = sec.Key("PAGING_NUM").MustInt(10)
|
||||
}
|
||||
|
||||
// NewServices initializes the services
|
||||
func NewServices() {
|
||||
newService()
|
||||
newLogService()
|
||||
|
|
|
@ -33,16 +33,16 @@ func NewFuncMap() []template.FuncMap {
|
|||
return strings.Title(runtime.Version())
|
||||
},
|
||||
"UseHTTPS": func() bool {
|
||||
return strings.HasPrefix(setting.AppUrl, "https")
|
||||
return strings.HasPrefix(setting.AppURL, "https")
|
||||
},
|
||||
"AppName": func() string {
|
||||
return setting.AppName
|
||||
},
|
||||
"AppSubUrl": func() string {
|
||||
return setting.AppSubUrl
|
||||
return setting.AppSubURL
|
||||
},
|
||||
"AppUrl": func() string {
|
||||
return setting.AppUrl
|
||||
return setting.AppURL
|
||||
},
|
||||
"AppVer": func() string {
|
||||
return setting.AppVer
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue