diff --git a/cmd/web.go b/cmd/web.go index 920227869..b2003be91 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -85,7 +85,7 @@ func newMacaron() *macaron.Macaron { m.Use(gzip.Gziper()) } if setting.Protocol == setting.SCHEME_FCGI { - m.SetURLPrefix(setting.AppSubUrl) + m.SetURLPrefix(setting.AppSubURL) } m.Use(macaron.Static( path.Join(setting.StaticRootPath, "public"), @@ -120,7 +120,7 @@ func newMacaron() *macaron.Macaron { localFiles[name] = bindata.MustAsset("conf/locale/" + name) } m.Use(i18n.I18n(i18n.Options{ - SubURL: setting.AppSubUrl, + SubURL: setting.AppSubURL, Files: localFiles, CustomDirectory: path.Join(setting.CustomPath, "conf/locale"), Langs: setting.Langs, @@ -134,7 +134,7 @@ func newMacaron() *macaron.Macaron { Interval: setting.CacheInterval, })) m.Use(captcha.Captchaer(captcha.Options{ - SubURL: setting.AppSubUrl, + SubURL: setting.AppSubURL, })) m.Use(session.Sessioner(setting.SessionConfig)) m.Use(csrf.Csrfer(csrf.Options{ @@ -142,7 +142,7 @@ func newMacaron() *macaron.Macaron { Cookie: setting.CSRFCookieName, SetCookie: true, Header: "X-Csrf-Token", - CookiePath: setting.AppSubUrl, + CookiePath: setting.AppSubURL, })) m.Use(toolbox.Toolboxer(m, toolbox.Options{ HealthCheckFuncs: []*toolbox.HealthCheckFuncDesc{ @@ -178,7 +178,7 @@ func runWeb(ctx *cli.Context) error { m.Get("/", ignSignIn, routers.Home) m.Group("/explore", func() { m.Get("", func(ctx *context.Context) { - ctx.Redirect(setting.AppSubUrl + "/explore/repos") + ctx.Redirect(setting.AppSubURL + "/explore/repos") }) m.Get("/repos", routers.ExploreRepos) m.Get("/users", routers.ExploreUsers) @@ -655,7 +655,7 @@ func runWeb(ctx *cli.Context) error { // Flag for port number in case first time run conflict. if ctx.IsSet("port") { - setting.AppUrl = strings.Replace(setting.AppUrl, setting.HTTPPort, ctx.String("port"), 1) + setting.AppURL = strings.Replace(setting.AppURL, setting.HTTPPort, ctx.String("port"), 1) setting.HTTPPort = ctx.String("port") } @@ -665,7 +665,7 @@ func runWeb(ctx *cli.Context) error { } else { listenAddr = fmt.Sprintf("%s:%s", setting.HTTPAddr, setting.HTTPPort) } - log.Info("Listen: %v://%s%s", setting.Protocol, listenAddr, setting.AppSubUrl) + log.Info("Listen: %v://%s%s", setting.Protocol, listenAddr, setting.AppSubURL) var err error switch setting.Protocol { diff --git a/models/action.go b/models/action.go index 0ad5f2879..4d2068941 100644 --- a/models/action.go +++ b/models/action.go @@ -136,8 +136,8 @@ func (a *Action) ShortRepoPath() string { } func (a *Action) GetRepoLink() string { - if len(setting.AppSubUrl) > 0 { - return path.Join(setting.AppSubUrl, a.GetRepoPath()) + if len(setting.AppSubURL) > 0 { + return path.Join(setting.AppSubURL, a.GetRepoPath()) } return "/" + a.GetRepoPath() } @@ -540,7 +540,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error { return nil } - compareURL := setting.AppUrl + opts.Commits.CompareURL + compareURL := setting.AppURL + opts.Commits.CompareURL if isNewRef { compareURL = "" if err = PrepareWebhooks(repo, HOOK_EVENT_CREATE, &api.CreatePayload{ diff --git a/models/pull.go b/models/pull.go index 5f7cbb579..cc94ee3e3 100644 --- a/models/pull.go +++ b/models/pull.go @@ -324,7 +324,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error Ref: git.BRANCH_PREFIX + pr.BaseBranch, Before: pr.MergeBase, After: pr.MergedCommitID, - CompareURL: setting.AppUrl + pr.BaseRepo.ComposeCompareURL(pr.MergeBase, pr.MergedCommitID), + CompareURL: setting.AppURL + pr.BaseRepo.ComposeCompareURL(pr.MergeBase, pr.MergedCommitID), Commits: commits, Repo: pr.BaseRepo.APIFormat(nil), Pusher: pr.HeadRepo.MustOwner().APIFormat(), diff --git a/models/repo.go b/models/repo.go index c9cf64c5f..476a78684 100644 --- a/models/repo.go +++ b/models/repo.go @@ -279,7 +279,7 @@ func (repo *Repository) FullName() string { } func (repo *Repository) HTMLURL() string { - return setting.AppUrl + repo.FullName() + return setting.AppURL + repo.FullName() } // Arguments that are allowed to be nil: permission @@ -458,7 +458,7 @@ func (repo *Repository) RelLink() string { } func (repo *Repository) Link() string { - return setting.AppSubUrl + "/" + repo.FullName() + return setting.AppSubURL + "/" + repo.FullName() } func (repo *Repository) ComposeCompareURL(oldCommitID, newCommitID string) string { @@ -597,7 +597,7 @@ type CloneLink struct { // ComposeHTTPSCloneURL returns HTTPS clone URL based on given owner and repository name. func ComposeHTTPSCloneURL(owner, repo string) string { - return fmt.Sprintf("%s%s/%s.git", setting.AppUrl, owner, repo) + return fmt.Sprintf("%s%s/%s.git", setting.AppURL, owner, repo) } func (repo *Repository) cloneLink(isWiki bool) *CloneLink { diff --git a/models/user.go b/models/user.go index 9f7b602ad..79774ae8e 100644 --- a/models/user.go +++ b/models/user.go @@ -175,18 +175,18 @@ func (u *User) CanImportLocal() bool { // DashboardLink returns the user dashboard page link. func (u *User) DashboardLink() string { if u.IsOrganization() { - return setting.AppSubUrl + "/org/" + u.Name + "/dashboard/" + return setting.AppSubURL + "/org/" + u.Name + "/dashboard/" } - return setting.AppSubUrl + "/" + return setting.AppSubURL + "/" } // HomeLink returns the user or organization home page link. func (u *User) HomeLink() string { - return setting.AppSubUrl + "/" + u.Name + return setting.AppSubURL + "/" + u.Name } func (u *User) HTMLURL() string { - return setting.AppUrl + u.Name + return setting.AppURL + u.Name } // GenerateEmailActivateCode generates an activate code based on user information and given e-mail. @@ -242,7 +242,7 @@ func (u *User) GenerateRandomAvatar() error { // which includes app sub-url as prefix. However, it is possible // to return full URL if user enables Gravatar-like service. func (u *User) RelAvatarLink() string { - defaultImgUrl := setting.AppSubUrl + "/img/avatar_default.png" + defaultImgUrl := setting.AppSubURL + "/img/avatar_default.png" if u.ID == -1 { return defaultImgUrl } @@ -252,7 +252,7 @@ func (u *User) RelAvatarLink() string { if !com.IsExist(u.CustomAvatarPath()) { return defaultImgUrl } - return setting.AppSubUrl + "/avatars/" + com.ToStr(u.ID) + return setting.AppSubURL + "/avatars/" + com.ToStr(u.ID) case setting.DisableGravatar, setting.OfflineMode: if !com.IsExist(u.CustomAvatarPath()) { if err := u.GenerateRandomAvatar(); err != nil { @@ -260,7 +260,7 @@ func (u *User) RelAvatarLink() string { } } - return setting.AppSubUrl + "/avatars/" + com.ToStr(u.ID) + return setting.AppSubURL + "/avatars/" + com.ToStr(u.ID) } return tool.AvatarLink(u.AvatarEmail) } @@ -269,7 +269,7 @@ func (u *User) RelAvatarLink() string { func (u *User) AvatarLink() string { link := u.RelAvatarLink() if link[0] == '/' && link[1] != '/' { - return setting.AppUrl + strings.TrimPrefix(link, setting.AppSubUrl)[1:] + return setting.AppURL + strings.TrimPrefix(link, setting.AppSubURL)[1:] } return link } diff --git a/models/webhook_discord.go b/models/webhook_discord.go index e452043c1..9cacc8372 100644 --- a/models/webhook_discord.go +++ b/models/webhook_discord.go @@ -77,7 +77,7 @@ func getDiscordCreatePayload(p *api.CreatePayload) (*DiscordPayload, error) { return &DiscordPayload{ Embeds: []*DiscordEmbedObject{{ Description: content, - URL: setting.AppUrl + p.Sender.UserName, + URL: setting.AppURL + p.Sender.UserName, Author: &DiscordEmbedAuthorObject{ Name: p.Sender.UserName, IconURL: p.Sender.AvatarUrl, @@ -94,7 +94,7 @@ func getDiscordDeletePayload(p *api.DeletePayload) (*DiscordPayload, error) { return &DiscordPayload{ Embeds: []*DiscordEmbedObject{{ Description: content, - URL: setting.AppUrl + p.Sender.UserName, + URL: setting.AppURL + p.Sender.UserName, Author: &DiscordEmbedAuthorObject{ Name: p.Sender.UserName, IconURL: p.Sender.AvatarUrl, @@ -111,7 +111,7 @@ func getDiscordForkPayload(p *api.ForkPayload) (*DiscordPayload, error) { return &DiscordPayload{ Embeds: []*DiscordEmbedObject{{ Description: content, - URL: setting.AppUrl + p.Sender.UserName, + URL: setting.AppURL + p.Sender.UserName, Author: &DiscordEmbedAuthorObject{ Name: p.Sender.UserName, IconURL: p.Sender.AvatarUrl, @@ -159,7 +159,7 @@ func getDiscordPushPayload(p *api.PushPayload, slack *SlackMeta) (*DiscordPayloa AvatarURL: slack.IconURL, Embeds: []*DiscordEmbedObject{{ Description: content, - URL: setting.AppUrl + p.Sender.UserName, + URL: setting.AppURL + p.Sender.UserName, Color: int(color), Author: &DiscordEmbedAuthorObject{ Name: p.Sender.UserName, @@ -360,7 +360,7 @@ func getDiscordReleasePayload(p *api.ReleasePayload) (*DiscordPayload, error) { return &DiscordPayload{ Embeds: []*DiscordEmbedObject{{ Description: content, - URL: setting.AppUrl + p.Sender.UserName, + URL: setting.AppURL + p.Sender.UserName, Author: &DiscordEmbedAuthorObject{ Name: p.Sender.UserName, IconURL: p.Sender.AvatarUrl, diff --git a/models/webhook_slack.go b/models/webhook_slack.go index e092d221a..76954795f 100644 --- a/models/webhook_slack.go +++ b/models/webhook_slack.go @@ -146,7 +146,7 @@ func getSlackPushPayload(p *api.PushPayload, slack *SlackMeta) (*SlackPayload, e } func getSlackIssuesPayload(p *api.IssuesPayload, slack *SlackMeta) (*SlackPayload, error) { - senderLink := SlackLinkFormatter(setting.AppUrl+p.Sender.UserName, p.Sender.UserName) + senderLink := SlackLinkFormatter(setting.AppURL+p.Sender.UserName, p.Sender.UserName) titleLink := SlackLinkFormatter(fmt.Sprintf("%s/issues/%d", p.Repository.HTMLURL, p.Index), fmt.Sprintf("#%d %s", p.Index, p.Issue.Title)) var text, title, attachmentText string @@ -164,7 +164,7 @@ func getSlackIssuesPayload(p *api.IssuesPayload, slack *SlackMeta) (*SlackPayloa attachmentText = SlackTextFormatter(p.Issue.Body) case api.HOOK_ISSUE_ASSIGNED: text = fmt.Sprintf("[%s] Issue assigned to %s: %s by %s", p.Repository.FullName, - SlackLinkFormatter(setting.AppUrl+p.Issue.Assignee.UserName, p.Issue.Assignee.UserName), + SlackLinkFormatter(setting.AppURL+p.Issue.Assignee.UserName, p.Issue.Assignee.UserName), titleLink, senderLink) case api.HOOK_ISSUE_UNASSIGNED: text = fmt.Sprintf("[%s] Issue unassigned: %s by %s", p.Repository.FullName, titleLink, senderLink) @@ -192,7 +192,7 @@ func getSlackIssuesPayload(p *api.IssuesPayload, slack *SlackMeta) (*SlackPayloa } func getSlackIssueCommentPayload(p *api.IssueCommentPayload, slack *SlackMeta) (*SlackPayload, error) { - senderLink := SlackLinkFormatter(setting.AppUrl+p.Sender.UserName, p.Sender.UserName) + senderLink := SlackLinkFormatter(setting.AppURL+p.Sender.UserName, p.Sender.UserName) titleLink := SlackLinkFormatter(fmt.Sprintf("%s/issues/%d#%s", p.Repository.HTMLURL, p.Issue.Index, CommentHashTag(p.Comment.ID)), fmt.Sprintf("#%d %s", p.Issue.Index, p.Issue.Title)) var text, title, attachmentText string @@ -226,7 +226,7 @@ func getSlackIssueCommentPayload(p *api.IssueCommentPayload, slack *SlackMeta) ( } func getSlackPullRequestPayload(p *api.PullRequestPayload, slack *SlackMeta) (*SlackPayload, error) { - senderLink := SlackLinkFormatter(setting.AppUrl+p.Sender.UserName, p.Sender.UserName) + senderLink := SlackLinkFormatter(setting.AppURL+p.Sender.UserName, p.Sender.UserName) titleLink := SlackLinkFormatter(fmt.Sprintf("%s/pulls/%d", p.Repository.HTMLURL, p.Index), fmt.Sprintf("#%d %s", p.Index, p.PullRequest.Title)) var text, title, attachmentText string @@ -248,7 +248,7 @@ func getSlackPullRequestPayload(p *api.PullRequestPayload, slack *SlackMeta) (*S attachmentText = SlackTextFormatter(p.PullRequest.Body) case api.HOOK_ISSUE_ASSIGNED: text = fmt.Sprintf("[%s] Pull request assigned to %s: %s by %s", p.Repository.FullName, - SlackLinkFormatter(setting.AppUrl+p.PullRequest.Assignee.UserName, p.PullRequest.Assignee.UserName), + SlackLinkFormatter(setting.AppURL+p.PullRequest.Assignee.UserName, p.PullRequest.Assignee.UserName), titleLink, senderLink) case api.HOOK_ISSUE_UNASSIGNED: text = fmt.Sprintf("[%s] Pull request unassigned: %s by %s", p.Repository.FullName, titleLink, senderLink) diff --git a/pkg/context/api.go b/pkg/context/api.go index ffaddd335..623bc1aac 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 642a320b1..d2bfe6035 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 4a11ce064..1649dc3dd 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 55c2ed04d..497856747 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 00f0eaa1e..a1924954c 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 43f588062..741f6f552 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(`#%s`, 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(`%s#%s`, m, repo, index) } out.WriteString(link) diff --git a/pkg/markup/markdown_test.go b/pkg/markup/markdown_test.go index a4bf074fd..15a66b816 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 c5549b6c1..9f5734a3e 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(`%s`, setting.AppUrl, repo, index, m) + link := fmt.Sprintf(`%s`, 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(`%s`, setting.AppSubUrl, m[1:], m)), -1) + []byte(fmt.Sprintf(`%s`, 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 d3d720912..6e19a23cb 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 6ce716eac..c8902b459 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 dd29ccc47..882be1459 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 4a5532a31..6936ca7d5 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 } diff --git a/routers/admin/admin.go b/routers/admin/admin.go index c7aa7f024..69ca48774 100644 --- a/routers/admin/admin.go +++ b/routers/admin/admin.go @@ -165,7 +165,7 @@ func Dashboard(ctx *context.Context) { } else { ctx.Flash.Success(success) } - ctx.Redirect(setting.AppSubUrl + "/admin") + ctx.Redirect(setting.AppSubURL + "/admin") return } @@ -185,7 +185,7 @@ func SendTestMail(ctx *context.Context) { ctx.Flash.Info(ctx.Tr("admin.config.test_mail_sent", email)) } - ctx.Redirect(setting.AppSubUrl + "/admin/config") + ctx.Redirect(setting.AppSubURL + "/admin/config") } func Config(ctx *context.Context) { @@ -193,7 +193,7 @@ func Config(ctx *context.Context) { ctx.Data["PageIsAdmin"] = true ctx.Data["PageIsAdminConfig"] = true - ctx.Data["AppUrl"] = setting.AppUrl + ctx.Data["AppURL"] = setting.AppURL ctx.Data["Domain"] = setting.Domain ctx.Data["OfflineMode"] = setting.OfflineMode ctx.Data["DisableRouterLog"] = setting.DisableRouterLog diff --git a/routers/admin/auths.go b/routers/admin/auths.go index 81a619570..532adb4f0 100644 --- a/routers/admin/auths.go +++ b/routers/admin/auths.go @@ -163,7 +163,7 @@ func NewAuthSourcePost(ctx *context.Context, f form.Authentication) { log.Trace("Authentication created by admin(%s): %s", ctx.User.Name, f.Name) ctx.Flash.Success(ctx.Tr("admin.auths.new_success", f.Name)) - ctx.Redirect(setting.AppSubUrl + "/admin/auths") + ctx.Redirect(setting.AppSubURL + "/admin/auths") } func EditAuthSource(ctx *context.Context) { @@ -230,7 +230,7 @@ func EditAuthSourcePost(ctx *context.Context, f form.Authentication) { log.Trace("Authentication changed by admin(%s): %d", ctx.User.Name, source.ID) ctx.Flash.Success(ctx.Tr("admin.auths.update_success")) - ctx.Redirect(setting.AppSubUrl + "/admin/auths/" + com.ToStr(f.ID)) + ctx.Redirect(setting.AppSubURL + "/admin/auths/" + com.ToStr(f.ID)) } func DeleteAuthSource(ctx *context.Context) { @@ -247,7 +247,7 @@ func DeleteAuthSource(ctx *context.Context) { ctx.Flash.Error(fmt.Sprintf("DeleteSource: %v", err)) } ctx.JSON(200, map[string]interface{}{ - "redirect": setting.AppSubUrl + "/admin/auths/" + ctx.Params(":authid"), + "redirect": setting.AppSubURL + "/admin/auths/" + ctx.Params(":authid"), }) return } @@ -255,6 +255,6 @@ func DeleteAuthSource(ctx *context.Context) { ctx.Flash.Success(ctx.Tr("admin.auths.deletion_success")) ctx.JSON(200, map[string]interface{}{ - "redirect": setting.AppSubUrl + "/admin/auths", + "redirect": setting.AppSubURL + "/admin/auths", }) } diff --git a/routers/admin/notice.go b/routers/admin/notice.go index 4041a0fc6..37f120bcf 100644 --- a/routers/admin/notice.go +++ b/routers/admin/notice.go @@ -68,5 +68,5 @@ func EmptyNotices(ctx *context.Context) { log.Trace("System notices deleted by admin (%s): [start: %d]", ctx.User.Name, 0) ctx.Flash.Success(ctx.Tr("admin.notices.delete_success")) - ctx.Redirect(setting.AppSubUrl + "/admin/notices") + ctx.Redirect(setting.AppSubURL + "/admin/notices") } diff --git a/routers/admin/repos.go b/routers/admin/repos.go index 1cd0b749b..b26917062 100644 --- a/routers/admin/repos.go +++ b/routers/admin/repos.go @@ -82,6 +82,6 @@ func DeleteRepo(ctx *context.Context) { ctx.Flash.Success(ctx.Tr("repo.settings.deletion_success")) ctx.JSON(200, map[string]interface{}{ - "redirect": setting.AppSubUrl + "/admin/repos?page=" + ctx.Query("page"), + "redirect": setting.AppSubURL + "/admin/repos?page=" + ctx.Query("page"), }) } diff --git a/routers/admin/users.go b/routers/admin/users.go index 7bb9ec77b..4b8949c18 100644 --- a/routers/admin/users.go +++ b/routers/admin/users.go @@ -120,7 +120,7 @@ func NewUserPost(ctx *context.Context, f form.AdminCrateUser) { } ctx.Flash.Success(ctx.Tr("admin.users.new_success", u.Name)) - ctx.Redirect(setting.AppSubUrl + "/admin/users/" + com.ToStr(u.ID)) + ctx.Redirect(setting.AppSubURL + "/admin/users/" + com.ToStr(u.ID)) } func prepareUserInfo(ctx *context.Context) *models.User { @@ -226,7 +226,7 @@ func EditUserPost(ctx *context.Context, f form.AdminEditUser) { log.Trace("Account profile updated by admin (%s): %s", ctx.User.Name, u.Name) ctx.Flash.Success(ctx.Tr("admin.users.update_profile_success")) - ctx.Redirect(setting.AppSubUrl + "/admin/users/" + ctx.Params(":userid")) + ctx.Redirect(setting.AppSubURL + "/admin/users/" + ctx.Params(":userid")) } func DeleteUser(ctx *context.Context) { @@ -241,12 +241,12 @@ func DeleteUser(ctx *context.Context) { case models.IsErrUserOwnRepos(err): ctx.Flash.Error(ctx.Tr("admin.users.still_own_repo")) ctx.JSON(200, map[string]interface{}{ - "redirect": setting.AppSubUrl + "/admin/users/" + ctx.Params(":userid"), + "redirect": setting.AppSubURL + "/admin/users/" + ctx.Params(":userid"), }) case models.IsErrUserHasOrgs(err): ctx.Flash.Error(ctx.Tr("admin.users.still_has_org")) ctx.JSON(200, map[string]interface{}{ - "redirect": setting.AppSubUrl + "/admin/users/" + ctx.Params(":userid"), + "redirect": setting.AppSubURL + "/admin/users/" + ctx.Params(":userid"), }) default: ctx.Handle(500, "DeleteUser", err) @@ -257,6 +257,6 @@ func DeleteUser(ctx *context.Context) { ctx.Flash.Success(ctx.Tr("admin.users.deletion_success")) ctx.JSON(200, map[string]interface{}{ - "redirect": setting.AppSubUrl + "/admin/users", + "redirect": setting.AppSubURL + "/admin/users", }) } diff --git a/routers/api/v1/repo/key.go b/routers/api/v1/repo/key.go index df1a8bb80..4ac180f1a 100644 --- a/routers/api/v1/repo/key.go +++ b/routers/api/v1/repo/key.go @@ -16,7 +16,7 @@ import ( ) func composeDeployKeysAPILink(repoPath string) string { - return setting.AppUrl + "api/v1/repos/" + repoPath + "/keys/" + return setting.AppURL + "api/v1/repos/" + repoPath + "/keys/" } // https://github.com/gogits/go-gogs-client/wiki/Repositories-Deploy-Keys#list-deploy-keys diff --git a/routers/api/v1/user/key.go b/routers/api/v1/user/key.go index 22df75482..b9ede63ff 100644 --- a/routers/api/v1/user/key.go +++ b/routers/api/v1/user/key.go @@ -34,7 +34,7 @@ func GetUserByParams(ctx *context.APIContext) *models.User { } func composePublicKeysAPILink() string { - return setting.AppUrl + "api/v1/user/keys/" + return setting.AppURL + "api/v1/user/keys/" } func listPublicKeys(ctx *context.APIContext, uid int64) { diff --git a/routers/dev/template.go b/routers/dev/template.go index 89cdd10d7..544b3f5d2 100644 --- a/routers/dev/template.go +++ b/routers/dev/template.go @@ -14,7 +14,7 @@ func TemplatePreview(ctx *context.Context) { ctx.Data["User"] = models.User{Name: "Unknown"} ctx.Data["AppName"] = setting.AppName ctx.Data["AppVer"] = setting.AppVer - ctx.Data["AppUrl"] = setting.AppUrl + ctx.Data["AppURL"] = setting.AppURL ctx.Data["Code"] = "2014031910370000009fff6782aadb2162b4a997acb69d4400888e0b9274657374" ctx.Data["ActiveCodeLives"] = setting.Service.ActiveCodeLives / 60 ctx.Data["ResetPwdCodeLives"] = setting.Service.ResetPwdCodeLives / 60 diff --git a/routers/home.go b/routers/home.go index 660915796..eaf338155 100644 --- a/routers/home.go +++ b/routers/home.go @@ -34,7 +34,7 @@ func Home(ctx *context.Context) { // Check auto-login. uname := ctx.GetCookie(setting.CookieUserName) if len(uname) != 0 { - ctx.Redirect(setting.AppSubUrl + "/user/login") + ctx.Redirect(setting.AppSubURL + "/user/login") return } diff --git a/routers/install.go b/routers/install.go index 2f94dc091..ccc87b3d5 100644 --- a/routers/install.go +++ b/routers/install.go @@ -145,7 +145,7 @@ func Install(ctx *context.Context) { f.SSHPort = setting.SSH.Port f.UseBuiltinSSHServer = setting.SSH.StartBuiltinServer f.HTTPPort = setting.HTTPPort - f.AppUrl = setting.AppUrl + f.AppUrl = setting.AppURL f.LogRootPath = setting.LogRootPath // E-mail service settings diff --git a/routers/org/members.go b/routers/org/members.go index 06d8fe6ab..b63f2f473 100644 --- a/routers/org/members.go +++ b/routers/org/members.go @@ -87,7 +87,7 @@ func MembersAction(ctx *context.Context) { if ctx.Params(":action") != "leave" { ctx.Redirect(ctx.Org.OrgLink + "/members") } else { - ctx.Redirect(setting.AppSubUrl + "/") + ctx.Redirect(setting.AppSubURL + "/") } } diff --git a/routers/org/org.go b/routers/org/org.go index 42768dd5c..8e6665619 100644 --- a/routers/org/org.go +++ b/routers/org/org.go @@ -52,5 +52,5 @@ func CreatePost(ctx *context.Context, f form.CreateOrg) { } log.Trace("Organization created: %s", org.Name) - ctx.Redirect(setting.AppSubUrl + "/org/" + f.OrgName + "/dashboard") + ctx.Redirect(setting.AppSubURL + "/org/" + f.OrgName + "/dashboard") } diff --git a/routers/org/setting.go b/routers/org/setting.go index 2ce454fe9..0d934892b 100644 --- a/routers/org/setting.go +++ b/routers/org/setting.go @@ -63,7 +63,7 @@ func SettingsPost(ctx *context.Context, f form.UpdateOrgSetting) { return } // reset ctx.org.OrgLink with new name - ctx.Org.OrgLink = setting.AppSubUrl + "/org/" + f.Name + ctx.Org.OrgLink = setting.AppSubURL + "/org/" + f.Name log.Trace("Organization name changed: %s -> %s", org.Name, f.Name) } // In case it's just a case change. @@ -130,7 +130,7 @@ func SettingsDelete(ctx *context.Context) { } } else { log.Trace("Organization deleted: %s", org.Name) - ctx.Redirect(setting.AppSubUrl + "/") + ctx.Redirect(setting.AppSubURL + "/") } return } diff --git a/routers/repo/commit.go b/routers/repo/commit.go index 9723b7f1a..992b35f5d 100644 --- a/routers/repo/commit.go +++ b/routers/repo/commit.go @@ -171,11 +171,11 @@ func Diff(ctx *context.Context) { ctx.Data["Diff"] = diff ctx.Data["Parents"] = parents ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0 - ctx.Data["SourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", commitID) + ctx.Data["SourcePath"] = setting.AppSubURL + "/" + path.Join(userName, repoName, "src", commitID) if commit.ParentCount() > 0 { - ctx.Data["BeforeSourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", parents[0]) + ctx.Data["BeforeSourcePath"] = setting.AppSubURL + "/" + path.Join(userName, repoName, "src", parents[0]) } - ctx.Data["RawPath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "raw", commitID) + ctx.Data["RawPath"] = setting.AppSubURL + "/" + path.Join(userName, repoName, "raw", commitID) ctx.HTML(200, DIFF) } @@ -232,8 +232,8 @@ func CompareDiff(ctx *context.Context) { ctx.Data["Commit"] = commit ctx.Data["Diff"] = diff ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0 - ctx.Data["SourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", afterCommitID) - ctx.Data["BeforeSourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", beforeCommitID) - ctx.Data["RawPath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "raw", afterCommitID) + ctx.Data["SourcePath"] = setting.AppSubURL + "/" + path.Join(userName, repoName, "src", afterCommitID) + ctx.Data["BeforeSourcePath"] = setting.AppSubURL + "/" + path.Join(userName, repoName, "src", beforeCommitID) + ctx.Data["RawPath"] = setting.AppSubURL + "/" + path.Join(userName, repoName, "raw", afterCommitID) ctx.HTML(200, DIFF) } diff --git a/routers/repo/editor.go b/routers/repo/editor.go index a8ce490a3..69c36b879 100644 --- a/routers/repo/editor.go +++ b/routers/repo/editor.go @@ -110,7 +110,7 @@ func editFile(ctx *context.Context, isNewFile bool) { ctx.Data["MarkdownFileExts"] = strings.Join(setting.Markdown.FileExtensions, ",") ctx.Data["LineWrapExtensions"] = strings.Join(setting.Repository.Editor.LineWrapExtensions, ",") ctx.Data["PreviewableFileModes"] = strings.Join(setting.Repository.Editor.PreviewableFileModes, ",") - ctx.Data["EditorconfigURLPrefix"] = fmt.Sprintf("%s/api/v1/repos/%s/editorconfig/", setting.AppSubUrl, ctx.Repo.Repository.FullName()) + ctx.Data["EditorconfigURLPrefix"] = fmt.Sprintf("%s/api/v1/repos/%s/editorconfig/", setting.AppSubURL, ctx.Repo.Repository.FullName()) ctx.HTML(200, EDIT_FILE) } diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 875ff8fec..61401b435 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -116,8 +116,8 @@ func issues(ctx *context.Context, isPullList bool) { // Must sign in to see issues about you. if viewType != "all" && !ctx.IsSigned { - 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 } @@ -653,7 +653,7 @@ func viewIssue(ctx *context.Context, isPullList bool) { ctx.Data["NumParticipants"] = len(participants) ctx.Data["Issue"] = issue ctx.Data["IsIssueOwner"] = ctx.Repo.IsWriter() || (ctx.IsSigned && issue.IsPoster(ctx.User.ID)) - ctx.Data["SignInLink"] = setting.AppSubUrl + "/user/login?redirect_to=" + ctx.Data["Link"].(string) + ctx.Data["SignInLink"] = setting.AppSubURL + "/user/login?redirect_to=" + ctx.Data["Link"].(string) ctx.HTML(200, ISSUE_VIEW) } diff --git a/routers/repo/pull.go b/routers/repo/pull.go index 6ff313b70..b88500e81 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -371,9 +371,9 @@ func ViewPullFiles(ctx *context.Context) { ctx.Data["Reponame"] = pull.HeadRepo.Name headTarget := path.Join(pull.HeadUserName, pull.HeadRepo.Name) - ctx.Data["SourcePath"] = setting.AppSubUrl + "/" + path.Join(headTarget, "src", endCommitID) - ctx.Data["BeforeSourcePath"] = setting.AppSubUrl + "/" + path.Join(headTarget, "src", startCommitID) - ctx.Data["RawPath"] = setting.AppSubUrl + "/" + path.Join(headTarget, "raw", endCommitID) + ctx.Data["SourcePath"] = setting.AppSubURL + "/" + path.Join(headTarget, "src", endCommitID) + ctx.Data["BeforeSourcePath"] = setting.AppSubURL + "/" + path.Join(headTarget, "src", startCommitID) + ctx.Data["RawPath"] = setting.AppSubURL + "/" + path.Join(headTarget, "raw", endCommitID) } ctx.Data["RequireHighlightJS"] = true @@ -573,9 +573,9 @@ func PrepareCompareDiff( ctx.Data["IsImageFile"] = headCommit.IsImageFile headTarget := path.Join(headUser.Name, repo.Name) - ctx.Data["SourcePath"] = setting.AppSubUrl + "/" + path.Join(headTarget, "src", headCommitID) - ctx.Data["BeforeSourcePath"] = setting.AppSubUrl + "/" + path.Join(headTarget, "src", prInfo.MergeBase) - ctx.Data["RawPath"] = setting.AppSubUrl + "/" + path.Join(headTarget, "raw", headCommitID) + ctx.Data["SourcePath"] = setting.AppSubURL + "/" + path.Join(headTarget, "src", headCommitID) + ctx.Data["BeforeSourcePath"] = setting.AppSubURL + "/" + path.Join(headTarget, "src", prInfo.MergeBase) + ctx.Data["RawPath"] = setting.AppSubURL + "/" + path.Join(headTarget, "raw", headCommitID) return false } diff --git a/routers/repo/repo.go b/routers/repo/repo.go index bdc471fe8..3f99f53c0 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -132,7 +132,7 @@ func CreatePost(ctx *context.Context, f form.CreateRepo) { }) if err == nil { log.Trace("Repository created [%d]: %s/%s", repo.ID, ctxUser.Name, repo.Name) - ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + repo.Name) + ctx.Redirect(setting.AppSubURL + "/" + ctxUser.Name + "/" + repo.Name) return } @@ -204,7 +204,7 @@ func MigratePost(ctx *context.Context, f form.MigrateRepo) { }) if err == nil { log.Trace("Repository migrated [%d]: %s/%s", repo.ID, ctxUser.Name, f.RepoName) - ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + f.RepoName) + ctx.Redirect(setting.AppSubURL + "/" + ctxUser.Name + "/" + f.RepoName) return } diff --git a/routers/repo/setting.go b/routers/repo/setting.go index 6a049ead2..f9dc4180c 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -189,7 +189,7 @@ func SettingsPost(ctx *context.Context, f form.RepoSetting) { } log.Trace("Repository converted from mirror to regular: %s/%s", ctx.Repo.Owner.Name, repo.Name) ctx.Flash.Success(ctx.Tr("repo.settings.convert_succeed")) - ctx.Redirect(setting.AppSubUrl + "/" + ctx.Repo.Owner.Name + "/" + repo.Name) + ctx.Redirect(setting.AppSubURL + "/" + ctx.Repo.Owner.Name + "/" + repo.Name) case "transfer": if !ctx.Repo.IsOwner() { @@ -228,7 +228,7 @@ func SettingsPost(ctx *context.Context, f form.RepoSetting) { } log.Trace("Repository transfered: %s/%s -> %s", ctx.Repo.Owner.Name, repo.Name, newOwner) ctx.Flash.Success(ctx.Tr("repo.settings.transfer_succeed")) - ctx.Redirect(setting.AppSubUrl + "/" + newOwner + "/" + repo.Name) + ctx.Redirect(setting.AppSubURL + "/" + newOwner + "/" + repo.Name) case "delete": if !ctx.Repo.IsOwner() { @@ -307,7 +307,7 @@ func SettingsCollaboration(ctx *context.Context) { func SettingsCollaborationPost(ctx *context.Context) { name := strings.ToLower(ctx.Query("collaborator")) if len(name) == 0 || ctx.Repo.Owner.LowerName == name { - ctx.Redirect(setting.AppSubUrl + ctx.Req.URL.Path) + ctx.Redirect(setting.AppSubURL + ctx.Req.URL.Path) return } @@ -315,7 +315,7 @@ func SettingsCollaborationPost(ctx *context.Context) { if err != nil { if errors.IsUserNotExist(err) { ctx.Flash.Error(ctx.Tr("form.user_not_exist")) - ctx.Redirect(setting.AppSubUrl + ctx.Req.URL.Path) + ctx.Redirect(setting.AppSubURL + ctx.Req.URL.Path) } else { ctx.Handle(500, "GetUserByName", err) } @@ -325,7 +325,7 @@ func SettingsCollaborationPost(ctx *context.Context) { // Organization is not allowed to be added as a collaborator if u.IsOrganization() { ctx.Flash.Error(ctx.Tr("repo.settings.org_not_allowed_to_be_collaborator")) - ctx.Redirect(setting.AppSubUrl + ctx.Req.URL.Path) + ctx.Redirect(setting.AppSubURL + ctx.Req.URL.Path) return } @@ -339,7 +339,7 @@ func SettingsCollaborationPost(ctx *context.Context) { } ctx.Flash.Success(ctx.Tr("repo.settings.add_collaborator_success")) - ctx.Redirect(setting.AppSubUrl + ctx.Req.URL.Path) + ctx.Redirect(setting.AppSubURL + ctx.Req.URL.Path) } func ChangeCollaborationAccessMode(ctx *context.Context) { diff --git a/routers/user/auth.go b/routers/user/auth.go index 25c7988ed..d54e674ca 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -44,9 +44,9 @@ func AutoLogin(c *context.Context) (bool, error) { defer func() { if !isSucceed { log.Trace("auto-login cookie cleared: %s", uname) - c.SetCookie(setting.CookieUserName, "", -1, setting.AppSubUrl) - c.SetCookie(setting.CookieRememberName, "", -1, setting.AppSubUrl) - c.SetCookie(setting.LoginStatusCookieName, "", -1, setting.AppSubUrl) + c.SetCookie(setting.CookieUserName, "", -1, setting.AppSubURL) + c.SetCookie(setting.CookieRememberName, "", -1, setting.AppSubURL) + c.SetCookie(setting.LoginStatusCookieName, "", -1, setting.AppSubURL) } }() @@ -65,9 +65,9 @@ func AutoLogin(c *context.Context) (bool, error) { isSucceed = true c.Session.Set("uid", u.ID) c.Session.Set("uname", u.Name) - c.SetCookie(setting.CSRFCookieName, "", -1, setting.AppSubUrl) + c.SetCookie(setting.CSRFCookieName, "", -1, setting.AppSubURL) if setting.EnableLoginStatusCookie { - c.SetCookie(setting.LoginStatusCookieName, "true", 0, setting.AppSubUrl) + c.SetCookie(setting.LoginStatusCookieName, "true", 0, setting.AppSubURL) } return true, nil } @@ -91,17 +91,17 @@ func Login(c *context.Context) { redirectTo := c.Query("redirect_to") if len(redirectTo) > 0 { - c.SetCookie("redirect_to", redirectTo, 0, setting.AppSubUrl) + c.SetCookie("redirect_to", redirectTo, 0, setting.AppSubURL) } else { redirectTo, _ = url.QueryUnescape(c.GetCookie("redirect_to")) } - c.SetCookie("redirect_to", "", -1, setting.AppSubUrl) + c.SetCookie("redirect_to", "", -1, setting.AppSubURL) if isSucceed { if isValidRedirect(redirectTo) { c.Redirect(redirectTo) } else { - c.Redirect(setting.AppSubUrl + "/") + c.Redirect(setting.AppSubURL + "/") } return } @@ -112,8 +112,8 @@ func Login(c *context.Context) { func afterLogin(c *context.Context, u *models.User, remember bool) { if remember { days := 86400 * setting.LoginRememberDays - c.SetCookie(setting.CookieUserName, u.Name, days, setting.AppSubUrl, "", setting.CookieSecure, true) - c.SetSuperSecureCookie(u.Rands+u.Passwd, setting.CookieRememberName, u.Name, days, setting.AppSubUrl, "", setting.CookieSecure, true) + c.SetCookie(setting.CookieUserName, u.Name, days, setting.AppSubURL, "", setting.CookieSecure, true) + c.SetSuperSecureCookie(u.Rands+u.Passwd, setting.CookieRememberName, u.Name, days, setting.AppSubURL, "", setting.CookieSecure, true) } c.Session.Set("uid", u.ID) @@ -122,19 +122,19 @@ func afterLogin(c *context.Context, u *models.User, remember bool) { c.Session.Delete("twoFactorUserID") // Clear whatever CSRF has right now, force to generate a new one - c.SetCookie(setting.CSRFCookieName, "", -1, setting.AppSubUrl) + c.SetCookie(setting.CSRFCookieName, "", -1, setting.AppSubURL) if setting.EnableLoginStatusCookie { - c.SetCookie(setting.LoginStatusCookieName, "true", 0, setting.AppSubUrl) + c.SetCookie(setting.LoginStatusCookieName, "true", 0, setting.AppSubURL) } redirectTo, _ := url.QueryUnescape(c.GetCookie("redirect_to")) - c.SetCookie("redirect_to", "", -1, setting.AppSubUrl) + c.SetCookie("redirect_to", "", -1, setting.AppSubURL) if isValidRedirect(redirectTo) { c.Redirect(redirectTo) return } - c.Redirect(setting.AppSubUrl + "/") + c.Redirect(setting.AppSubURL + "/") } func LoginPost(c *context.Context, f form.SignIn) { @@ -162,7 +162,7 @@ func LoginPost(c *context.Context, f form.SignIn) { c.Session.Set("twoFactorRemember", f.Remember) c.Session.Set("twoFactorUserID", u.ID) - c.Redirect(setting.AppSubUrl + "/user/login/two_factor") + c.Redirect(setting.AppSubURL + "/user/login/two_factor") } func LoginTwoFactor(c *context.Context) { @@ -193,7 +193,7 @@ func LoginTwoFactorPost(c *context.Context) { return } else if !valid { c.Flash.Error(c.Tr("settings.two_factor_invalid_passcode")) - c.Redirect(setting.AppSubUrl + "/user/login/two_factor") + c.Redirect(setting.AppSubURL + "/user/login/two_factor") return } @@ -225,7 +225,7 @@ func LoginTwoFactorRecoveryCodePost(c *context.Context) { if err := models.UseRecoveryCode(userID, c.Query("recovery_code")); err != nil { if errors.IsTwoFactorRecoveryCodeNotFound(err) { c.Flash.Error(c.Tr("auth.login_two_factor_invalid_recovery_code")) - c.Redirect(setting.AppSubUrl + "/user/login/two_factor_recovery_code") + c.Redirect(setting.AppSubURL + "/user/login/two_factor_recovery_code") } else { c.ServerError("UseRecoveryCode", err) } @@ -243,10 +243,10 @@ func LoginTwoFactorRecoveryCodePost(c *context.Context) { func SignOut(ctx *context.Context) { ctx.Session.Delete("uid") ctx.Session.Delete("uname") - ctx.SetCookie(setting.CookieUserName, "", -1, setting.AppSubUrl) - ctx.SetCookie(setting.CookieRememberName, "", -1, setting.AppSubUrl) - ctx.SetCookie(setting.CSRFCookieName, "", -1, setting.AppSubUrl) - ctx.Redirect(setting.AppSubUrl + "/") + ctx.SetCookie(setting.CookieUserName, "", -1, setting.AppSubURL) + ctx.SetCookie(setting.CookieRememberName, "", -1, setting.AppSubURL) + ctx.SetCookie(setting.CSRFCookieName, "", -1, setting.AppSubURL) + ctx.Redirect(setting.AppSubURL + "/") } func SignUp(ctx *context.Context) { @@ -341,7 +341,7 @@ func SignUpPost(ctx *context.Context, cpt *captcha.Captcha, f form.Register) { return } - ctx.Redirect(setting.AppSubUrl + "/user/login") + ctx.Redirect(setting.AppSubURL + "/user/login") } func Activate(ctx *context.Context) { @@ -389,7 +389,7 @@ func Activate(ctx *context.Context) { ctx.Session.Set("uid", user.ID) ctx.Session.Set("uname", user.Name) - ctx.Redirect(setting.AppSubUrl + "/") + ctx.Redirect(setting.AppSubURL + "/") return } @@ -411,7 +411,7 @@ func ActivateEmail(ctx *context.Context) { ctx.Flash.Success(ctx.Tr("settings.add_email_success")) } - ctx.Redirect(setting.AppSubUrl + "/user/settings/email") + ctx.Redirect(setting.AppSubURL + "/user/settings/email") return } @@ -525,7 +525,7 @@ func ResetPasswdPost(ctx *context.Context) { } log.Trace("User password reset: %s", u.Name) - ctx.Redirect(setting.AppSubUrl + "/user/login") + ctx.Redirect(setting.AppSubURL + "/user/login") return } diff --git a/routers/user/home.go b/routers/user/home.go index b556a1763..745c2afac 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -420,5 +420,5 @@ func Email2User(ctx *context.Context) { ctx.NotFoundOrServerError("GetUserByEmail", errors.IsUserNotExist, err) return } - ctx.Redirect(setting.AppSubUrl + "/user/" + u.Name) + ctx.Redirect(setting.AppSubURL + "/user/" + u.Name) } diff --git a/routers/user/setting.go b/routers/user/setting.go index b9c70d64a..84c69a622 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -67,16 +67,16 @@ func handleUsernameChange(ctx *context.Context, newName string) { switch { case models.IsErrUserAlreadyExist(err): ctx.Flash.Error(ctx.Tr("newName_been_taken")) - ctx.Redirect(setting.AppSubUrl + "/user/settings") + ctx.Redirect(setting.AppSubURL + "/user/settings") case models.IsErrEmailAlreadyUsed(err): ctx.Flash.Error(ctx.Tr("form.email_been_used")) - ctx.Redirect(setting.AppSubUrl + "/user/settings") + ctx.Redirect(setting.AppSubURL + "/user/settings") case models.IsErrNameReserved(err): ctx.Flash.Error(ctx.Tr("user.newName_reserved")) - ctx.Redirect(setting.AppSubUrl + "/user/settings") + ctx.Redirect(setting.AppSubURL + "/user/settings") case models.IsErrNamePatternNotAllowed(err): ctx.Flash.Error(ctx.Tr("user.newName_pattern_not_allowed")) - ctx.Redirect(setting.AppSubUrl + "/user/settings") + ctx.Redirect(setting.AppSubURL + "/user/settings") default: ctx.Handle(500, "ChangeUserName", err) } @@ -116,7 +116,7 @@ func SettingsPost(ctx *context.Context, f form.UpdateProfile) { log.Trace("User settings updated: %s", ctx.User.Name) ctx.Flash.Success(ctx.Tr("settings.update_profile_success")) - ctx.Redirect(setting.AppSubUrl + "/user/settings") + ctx.Redirect(setting.AppSubURL + "/user/settings") } // FIXME: limit size. @@ -174,7 +174,7 @@ func SettingsAvatarPost(ctx *context.Context, f form.Avatar) { ctx.Flash.Success(ctx.Tr("settings.update_avatar_success")) } - ctx.Redirect(setting.AppSubUrl + "/user/settings/avatar") + ctx.Redirect(setting.AppSubURL + "/user/settings/avatar") } func SettingsDeleteAvatar(ctx *context.Context) { @@ -182,7 +182,7 @@ func SettingsDeleteAvatar(ctx *context.Context) { ctx.Flash.Error(err.Error()) } - ctx.Redirect(setting.AppSubUrl + "/user/settings/avatar") + ctx.Redirect(setting.AppSubURL + "/user/settings/avatar") } func SettingsPassword(ctx *context.Context) { @@ -220,7 +220,7 @@ func SettingsPasswordPost(ctx *context.Context, f form.ChangePassword) { ctx.Flash.Success(ctx.Tr("settings.change_password_success")) } - ctx.Redirect(setting.AppSubUrl + "/user/settings/password") + ctx.Redirect(setting.AppSubURL + "/user/settings/password") } func SettingsEmails(ctx *context.Context) { @@ -249,7 +249,7 @@ func SettingsEmailPost(ctx *context.Context, f form.AddEmail) { } log.Trace("Email made primary: %s", ctx.User.Name) - ctx.Redirect(setting.AppSubUrl + "/user/settings/email") + ctx.Redirect(setting.AppSubURL + "/user/settings/email") return } @@ -293,7 +293,7 @@ func SettingsEmailPost(ctx *context.Context, f form.AddEmail) { } log.Trace("Email address added: %s", email.Email) - ctx.Redirect(setting.AppSubUrl + "/user/settings/email") + ctx.Redirect(setting.AppSubURL + "/user/settings/email") } func DeleteEmail(ctx *context.Context) { @@ -308,7 +308,7 @@ func DeleteEmail(ctx *context.Context) { ctx.Flash.Success(ctx.Tr("settings.email_deletion_success")) ctx.JSON(200, map[string]interface{}{ - "redirect": setting.AppSubUrl + "/user/settings/email", + "redirect": setting.AppSubURL + "/user/settings/email", }) } @@ -348,7 +348,7 @@ func SettingsSSHKeysPost(ctx *context.Context, f form.AddSSHKey) { ctx.Flash.Info(ctx.Tr("form.unable_verify_ssh_key")) } else { ctx.Flash.Error(ctx.Tr("form.invalid_ssh_key", err.Error())) - ctx.Redirect(setting.AppSubUrl + "/user/settings/ssh") + ctx.Redirect(setting.AppSubURL + "/user/settings/ssh") return } } @@ -369,7 +369,7 @@ func SettingsSSHKeysPost(ctx *context.Context, f form.AddSSHKey) { } ctx.Flash.Success(ctx.Tr("settings.add_key_success", f.Title)) - ctx.Redirect(setting.AppSubUrl + "/user/settings/ssh") + ctx.Redirect(setting.AppSubURL + "/user/settings/ssh") } func DeleteSSHKey(ctx *context.Context) { @@ -380,7 +380,7 @@ func DeleteSSHKey(ctx *context.Context) { } ctx.JSON(200, map[string]interface{}{ - "redirect": setting.AppSubUrl + "/user/settings/ssh", + "redirect": setting.AppSubURL + "/user/settings/ssh", }) } @@ -452,20 +452,20 @@ func SettingsTwoFactorEnablePost(c *context.Context) { if !totp.Validate(c.Query("passcode"), secret) { c.Flash.Error(c.Tr("settings.two_factor_invalid_passcode")) - c.Redirect(setting.AppSubUrl + "/user/settings/security/two_factor_enable") + c.Redirect(setting.AppSubURL + "/user/settings/security/two_factor_enable") return } if err := models.NewTwoFactor(c.UserID(), secret); err != nil { c.Flash.Error(c.Tr("settings.two_factor_enable_error", err)) - c.Redirect(setting.AppSubUrl + "/user/settings/security/two_factor_enable") + c.Redirect(setting.AppSubURL + "/user/settings/security/two_factor_enable") return } c.Session.Delete("twoFactorSecret") c.Session.Delete("twoFactorURL") c.Flash.Success(c.Tr("settings.two_factor_enable_success")) - c.Redirect(setting.AppSubUrl + "/user/settings/security/two_factor_recovery_codes") + c.Redirect(setting.AppSubURL + "/user/settings/security/two_factor_recovery_codes") } func SettingsTwoFactorRecoveryCodes(c *context.Context) { @@ -499,7 +499,7 @@ func SettingsTwoFactorRecoveryCodesPost(c *context.Context) { c.Flash.Success(c.Tr("settings.two_factor_regenerate_recovery_codes_success")) } - c.Redirect(setting.AppSubUrl + "/user/settings/security/two_factor_recovery_codes") + c.Redirect(setting.AppSubURL + "/user/settings/security/two_factor_recovery_codes") } func SettingsTwoFactorDisable(c *context.Context) { @@ -515,7 +515,7 @@ func SettingsTwoFactorDisable(c *context.Context) { c.Flash.Success(c.Tr("settings.two_factor_disable_success")) c.JSONSuccess(map[string]interface{}{ - "redirect": setting.AppSubUrl + "/user/settings/security", + "redirect": setting.AppSubURL + "/user/settings/security", }) } @@ -563,7 +563,7 @@ func SettingsLeaveOrganization(ctx *context.Context) { } ctx.JSON(200, map[string]interface{}{ - "redirect": setting.AppSubUrl + "/user/settings/organizations", + "redirect": setting.AppSubURL + "/user/settings/organizations", }) } @@ -581,7 +581,7 @@ func SettingsLeaveRepo(ctx *context.Context) { ctx.Flash.Success(ctx.Tr("settings.repos.leave_success", repo.FullName())) ctx.JSON(200, map[string]interface{}{ - "redirect": setting.AppSubUrl + "/user/settings/repositories", + "redirect": setting.AppSubURL + "/user/settings/repositories", }) } @@ -612,7 +612,7 @@ func SettingsApplicationsPost(ctx *context.Context, f form.NewAccessToken) { ctx.Flash.Success(ctx.Tr("settings.generate_token_succees")) ctx.Flash.Info(t.Sha1) - ctx.Redirect(setting.AppSubUrl + "/user/settings/applications") + ctx.Redirect(setting.AppSubURL + "/user/settings/applications") } func SettingsDeleteApplication(ctx *context.Context) { @@ -623,7 +623,7 @@ func SettingsDeleteApplication(ctx *context.Context) { } ctx.JSON(200, map[string]interface{}{ - "redirect": setting.AppSubUrl + "/user/settings/applications", + "redirect": setting.AppSubURL + "/user/settings/applications", }) } @@ -659,16 +659,16 @@ func SettingsDelete(ctx *context.Context) { switch { case models.IsErrUserOwnRepos(err): ctx.Flash.Error(ctx.Tr("form.still_own_repo")) - ctx.Redirect(setting.AppSubUrl + "/user/settings/delete") + ctx.Redirect(setting.AppSubURL + "/user/settings/delete") case models.IsErrUserHasOrgs(err): ctx.Flash.Error(ctx.Tr("form.still_has_org")) - ctx.Redirect(setting.AppSubUrl + "/user/settings/delete") + ctx.Redirect(setting.AppSubURL + "/user/settings/delete") default: ctx.Handle(500, "DeleteUser", err) } } else { log.Trace("Account deleted: %s", ctx.User.Name) - ctx.Redirect(setting.AppSubUrl + "/") + ctx.Redirect(setting.AppSubURL + "/") } return } diff --git a/templates/admin/auth/list.tmpl b/templates/admin/auth/list.tmpl index 58bdc66b2..dee67ab47 100644 --- a/templates/admin/auth/list.tmpl +++ b/templates/admin/auth/list.tmpl @@ -8,7 +8,7 @@