diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/context/api.go | 8 | ||||
-rw-r--r-- | pkg/context/auth.go | 14 | ||||
-rw-r--r-- | pkg/context/context.go | 2 | ||||
-rw-r--r-- | pkg/context/org.go | 2 | ||||
-rw-r--r-- | pkg/context/repo.go | 4 | ||||
-rw-r--r-- | pkg/markup/markdown.go | 6 | ||||
-rw-r--r-- | pkg/markup/markdown_test.go | 4 | ||||
-rw-r--r-- | pkg/markup/markup.go | 6 | ||||
-rw-r--r-- | pkg/markup/markup_test.go | 2 | ||||
-rw-r--r-- | pkg/setting/setting.go | 30 | ||||
-rw-r--r-- | pkg/template/template.go | 10 | ||||
-rw-r--r-- | pkg/tool/tool.go | 2 |
12 files changed, 46 insertions, 44 deletions
diff --git a/pkg/context/api.go b/pkg/context/api.go index ffaddd33..623bc1aa 100644 --- a/pkg/context/api.go +++ b/pkg/context/api.go @@ -48,16 +48,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/pkg/context/auth.go b/pkg/context/auth.go index 642a320b..d2bfe603 100644 --- a/pkg/context/auth.go +++ b/pkg/context/auth.go @@ -25,7 +25,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,13 +38,13 @@ 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)) + 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 } @@ -65,8 +65,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") @@ -78,8 +78,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/pkg/context/context.go b/pkg/context/context.go index 4a11ce06..1649dc3d 100644 --- a/pkg/context/context.go +++ b/pkg/context/context.go @@ -185,7 +185,7 @@ func Contexter() macaron.Handler { } // 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/pkg/context/org.go b/pkg/context/org.go index 55c2ed04..49785674 100644 --- a/pkg/context/org.go +++ b/pkg/context/org.go @@ -91,7 +91,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/pkg/context/repo.go b/pkg/context/repo.go index 00f0eaa1..a1924954 100644 --- a/pkg/context/repo.go +++ b/pkg/context/repo.go @@ -110,7 +110,7 @@ func (r *Repository) PullRequestURL(baseBranch, headBranch string) string { // 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 @@ -311,7 +311,7 @@ func RepoAssignment(pages ...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/pkg/markup/markdown.go b/pkg/markup/markdown.go index 43f58806..741f6f55 100644 --- a/pkg/markup/markdown.go +++ b/pkg/markup/markdown.go @@ -63,7 +63,7 @@ func (r *MarkdownRenderer) 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) @@ -86,14 +86,14 @@ func (r *MarkdownRenderer) AutoLink(out *bytes.Buffer, link []byte, kind int) { } index := string(m[i+7 : j]) - fullRepoURL := setting.AppUrl + strings.TrimPrefix(r.urlPrefix, "/") + fullRepoURL := setting.AppURL + strings.TrimPrefix(r.urlPrefix, "/") var link string if strings.HasPrefix(string(m), fullRepoURL) { // Use a short issue reference if the URL refers to this repository link = fmt.Sprintf(`<a href="%s">#%s</a>`, m, index) } else { // Use a cross-repository issue reference if the URL refers to a different repository - repo := string(m[len(setting.AppUrl) : i-1]) + repo := string(m[len(setting.AppURL) : i-1]) link = fmt.Sprintf(`<a href="%s">%s#%s</a>`, m, repo, index) } out.WriteString(link) diff --git a/pkg/markup/markdown_test.go b/pkg/markup/markdown_test.go index a4bf074f..15a66b81 100644 --- a/pkg/markup/markdown_test.go +++ b/pkg/markup/markdown_test.go @@ -40,7 +40,7 @@ func Test_IsMarkdownFile(t *testing.T) { func Test_Markdown(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 @@ -82,7 +82,7 @@ func Test_Markdown(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/pkg/markup/markup.go b/pkg/markup/markup.go index c5549b6c..9f5734a3 100644 --- a/pkg/markup/markup.go +++ b/pkg/markup/markup.go @@ -74,7 +74,7 @@ func cutoutVerbosePrefix(prefix string) string { if prefix[i] == '/' { count++ } - if count >= 3+setting.AppSubUrlDepth { + if count >= 3+setting.AppSubURLDepth { return prefix[:i] } } @@ -128,7 +128,7 @@ func RenderCrossReferenceIssueIndexPattern(rawBytes []byte, urlPrefix string, me repo := string(m[:delimIdx]) index := string(m[delimIdx+1:]) - link := fmt.Sprintf(`<a href="%s%s/issues/%s">%s</a>`, setting.AppUrl, repo, index, m) + link := fmt.Sprintf(`<a href="%s%s/issues/%s">%s</a>`, setting.AppURL, repo, index, m) rawBytes = bytes.Replace(rawBytes, m, []byte(link), 1) } return rawBytes @@ -150,7 +150,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/pkg/markup/markup_test.go b/pkg/markup/markup_test.go index d3d72091..6e19a23c 100644 --- a/pkg/markup/markup_test.go +++ b/pkg/markup/markup_test.go @@ -62,7 +62,7 @@ func Test_RenderIssueIndexPattern(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() { diff --git a/pkg/setting/setting.go b/pkg/setting/setting.go index 6ce716ea..c8902b45 100644 --- a/pkg/setting/setting.go +++ b/pkg/setting/setting.go @@ -54,16 +54,17 @@ var ( // App 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 @@ -288,8 +289,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 @@ -416,20 +418,20 @@ func NewContext() { sec := Cfg.Section("server") AppName = Cfg.Section("").Key("APP_NAME").MustString("Gogs") - 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(2, "Invalid ROOT_URL '%s': %s", AppUrl, err) + log.Fatal(2, "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 = SCHEME_HTTP if sec.Key("PROTOCOL").String() == "https" { @@ -771,7 +773,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(3600) SessionConfig.Maxlifetime = Cfg.Section("session").Key("SESSION_LIFE_TIME").MustInt64(86400) diff --git a/pkg/template/template.go b/pkg/template/template.go index dd29ccc4..882be145 100644 --- a/pkg/template/template.go +++ b/pkg/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 + "AppSubURL": func() string { + return setting.AppSubURL }, - "AppUrl": func() string { - return setting.AppUrl + "AppURL": func() string { + return setting.AppURL }, "AppVer": func() string { return setting.AppVer diff --git a/pkg/tool/tool.go b/pkg/tool/tool.go index 4a5532a3..6936ca7d 100644 --- a/pkg/tool/tool.go +++ b/pkg/tool/tool.go @@ -202,7 +202,7 @@ func AvatarLink(email string) (url string) { url = setting.GravatarSource + HashEmail(email) } if len(url) == 0 { - url = setting.AppSubUrl + "/img/avatar_default.png" + url = setting.AppSubURL + "/img/avatar_default.png" } return url } |