summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2016-11-27 18:14:25 +0800
committerGitHub <noreply@github.com>2016-11-27 18:14:25 +0800
commit94da47271701401b6959bfd308d6c74fd30b22e2 (patch)
tree92a6c3298ab198efa04fbe4409d282da44736640 /modules
parent0a76d260fa16764ab66bf1623b4cd9e9adfdac27 (diff)
downloadgitea-94da47271701401b6959bfd308d6c74fd30b22e2.tar.gz
gitea-94da47271701401b6959bfd308d6c74fd30b22e2.zip
Golint fixed for modules/setting (#262)
* golint fixed for modules/setting * typo fixed and renamed UNIXSOCKET to UnixSocket
Diffstat (limited to 'modules')
-rw-r--r--modules/base/tool.go2
-rw-r--r--modules/context/api.go8
-rw-r--r--modules/context/auth.go16
-rw-r--r--modules/context/context.go2
-rw-r--r--modules/context/org.go2
-rw-r--r--modules/context/repo.go4
-rw-r--r--modules/markdown/markdown.go6
-rw-r--r--modules/markdown/markdown_test.go6
-rw-r--r--modules/setting/setting.go67
-rw-r--r--modules/template/template.go6
10 files changed, 65 insertions, 54 deletions
diff --git a/modules/base/tool.go b/modules/base/tool.go
index db065afd8c..981f89b6a5 100644
--- a/modules/base/tool.go
+++ b/modules/base/tool.go
@@ -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
diff --git a/modules/context/api.go b/modules/context/api.go
index 2823d696d2..7706e9c499 100644
--- a/modules/context/api.go
+++ b/modules/context/api.go
@@ -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 {
diff --git a/modules/context/auth.go b/modules/context/auth.go
index 0e5ae93a87..372bcb187a 100644
--- a/modules/context/auth.go
+++ b/modules/context/auth.go
@@ -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
}
diff --git a/modules/context/context.go b/modules/context/context.go
index 0535da995a..57a9195306 100644
--- a/modules/context/context.go
+++ b/modules/context/context.go
@@ -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()
diff --git a/modules/context/org.go b/modules/context/org.go
index d31d9773a0..cfe9a26220 100644
--- a/modules/context/org.go
+++ b/modules/context/org.go
@@ -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.
diff --git a/modules/context/repo.go b/modules/context/repo.go
index 6135ac46ae..338a78cb93 100644
--- a/modules/context/repo.go
+++ b/modules/context/repo.go
@@ -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}"
}
diff --git a/modules/markdown/markdown.go b/modules/markdown/markdown.go
index e46f172d3e..6bf29db07a 100644
--- a/modules/markdown/markdown.go
+++ b/modules/markdown/markdown.go
@@ -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)
diff --git a/modules/markdown/markdown_test.go b/modules/markdown/markdown_test.go
index 3fc260bf1f..55496aa6af 100644
--- a/modules/markdown/markdown_test.go
+++ b/modules/markdown/markdown_test.go
@@ -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
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index baaa3f50a8..12025a27bf 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -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()
diff --git a/modules/template/template.go b/modules/template/template.go
index baf1a7ab92..65d78c2f6e 100644
--- a/modules/template/template.go
+++ b/modules/template/template.go
@@ -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