diff --git a/cmd/web.go b/cmd/web.go index f56ae82685..45f35a35af 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -79,6 +79,7 @@ func newMacaron() *macaron.Macaron { IndentJSON: macaron.Env != macaron.PROD, })) m.Use(i18n.I18n(i18n.Options{ + SubURL: setting.AppSubUrl, Langs: setting.Langs, Names: setting.Names, Redirect: true, @@ -88,7 +89,9 @@ func newMacaron() *macaron.Macaron { Interval: setting.CacheInternal, Conn: setting.CacheConn, })) - m.Use(captcha.Captchaer()) + m.Use(captcha.Captchaer(captcha.Options{ + SubURL: setting.AppSubUrl, + })) m.Use(session.Sessioner(session.Options{ Provider: setting.SessionProvider, Config: *setting.SessionConfig, @@ -365,7 +368,7 @@ func runWeb(*cli.Context) { var err error listenAddr := fmt.Sprintf("%s:%s", setting.HttpAddr, setting.HttpPort) - log.Info("Listen: %v://%s", setting.Protocol, listenAddr) + log.Info("Listen: %v://%s%s", setting.Protocol, listenAddr, setting.AppSubUrl) switch setting.Protocol { case setting.HTTP: err = http.ListenAndServe(listenAddr, m) diff --git a/gogs.go b/gogs.go index c5249b2512..8f9bc767d9 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.5.2.0917 Beta" +const APP_VER = "0.5.3.0919 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/models/action.go b/models/action.go index 596f51aff2..b4457656ba 100644 --- a/models/action.go +++ b/models/action.go @@ -137,7 +137,7 @@ func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, com return err } - url := fmt.Sprintf("%s/%s/%s/commit/%s", setting.AppRootSubUrl, repoUserName, repoName, c.Sha1) + url := fmt.Sprintf("%s/%s/%s/commit/%s", setting.AppSubUrl, repoUserName, repoName, c.Sha1) message := fmt.Sprintf(`%s`, url, c.Message) if _, err = CreateComment(userId, issue.RepoId, issue.Id, 0, 0, COMMIT, message, nil); err != nil { diff --git a/models/user.go b/models/user.go index 1bed8109a2..46e1b1554b 100644 --- a/models/user.go +++ b/models/user.go @@ -82,14 +82,14 @@ type User struct { // DashboardLink returns the user dashboard page link. func (u *User) DashboardLink() string { if u.IsOrganization() { - return setting.AppRootSubUrl + "/org/" + u.Name + "/dashboard/" + return setting.AppSubUrl + "/org/" + u.Name + "/dashboard/" } - return setting.AppRootSubUrl + "/" + return setting.AppSubUrl + "/" } // HomeLink returns the user home page link. func (u *User) HomeLink() string { - return setting.AppRootSubUrl + "/user/" + u.Name + return setting.AppSubUrl + "/user/" + u.Name } // AvatarLink returns user gravatar link. diff --git a/modules/base/markdown.go b/modules/base/markdown.go index 2aa81005bf..a3db15df1a 100644 --- a/modules/base/markdown.go +++ b/modules/base/markdown.go @@ -113,7 +113,7 @@ func RenderSpecialLink(rawBytes []byte, urlPrefix string) []byte { ms := MentionPattern.FindAll(line, -1) for _, m := range ms { line = bytes.Replace(line, m, - []byte(fmt.Sprintf(`%s`, setting.AppRootSubUrl, m[1:], m)), -1) + []byte(fmt.Sprintf(`%s`, setting.AppSubUrl, m[1:], m)), -1) } } diff --git a/modules/base/template.go b/modules/base/template.go index dd883ea360..ec41914937 100644 --- a/modules/base/template.go +++ b/modules/base/template.go @@ -82,8 +82,8 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{ "AppName": func() string { return setting.AppName }, - "AppRootSubUrl": func() string { - return setting.AppRootSubUrl + "AppSubUrl": func() string { + return setting.AppSubUrl }, "AppVer": func() string { return setting.AppVer @@ -210,7 +210,7 @@ func ActionDesc(act Actioner) string { content := act.GetContent() switch act.GetOpType() { case 1: // Create repository. - return fmt.Sprintf(TPL_CREATE_REPO, setting.AppRootSubUrl, actUserName, actUserName, repoLink, repoName) + return fmt.Sprintf(TPL_CREATE_REPO, setting.AppSubUrl, actUserName, actUserName, repoLink, repoName) case 5: // Commit repository. var push *PushCommits if err := json.Unmarshal([]byte(content), &push); err != nil { @@ -223,20 +223,20 @@ func ActionDesc(act Actioner) string { if push.Len > 3 { buf.WriteString(fmt.Sprintf(`
`, actUserName, repoName, branch, push.Len)) } - return fmt.Sprintf(TPL_COMMIT_REPO, setting.AppRootSubUrl, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink, + return fmt.Sprintf(TPL_COMMIT_REPO, setting.AppSubUrl, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink, buf.String()) case 6: // Create issue. infos := strings.SplitN(content, "|", 2) - return fmt.Sprintf(TPL_CREATE_ISSUE, setting.AppRootSubUrl, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0], + return fmt.Sprintf(TPL_CREATE_ISSUE, setting.AppSubUrl, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0], AvatarLink(email), infos[1]) case 8: // Transfer repository. newRepoLink := content + "/" + repoName - return fmt.Sprintf(TPL_TRANSFER_REPO, setting.AppRootSubUrl, actUserName, actUserName, repoLink, newRepoLink, newRepoLink) + return fmt.Sprintf(TPL_TRANSFER_REPO, setting.AppSubUrl, actUserName, actUserName, repoLink, newRepoLink, newRepoLink) case 9: // Push tag. - return fmt.Sprintf(TPL_PUSH_TAG, setting.AppRootSubUrl, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink) + return fmt.Sprintf(TPL_PUSH_TAG, setting.AppSubUrl, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink) case 10: // Comment issue. infos := strings.SplitN(content, "|", 2) - return fmt.Sprintf(TPL_COMMENT_ISSUE, setting.AppRootSubUrl, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0], + return fmt.Sprintf(TPL_COMMENT_ISSUE, setting.AppSubUrl, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0], AvatarLink(email), infos[1]) default: return "invalid type" diff --git a/modules/middleware/auth.go b/modules/middleware/auth.go index ccd8d0315d..8fae5d1ece 100644 --- a/modules/middleware/auth.go +++ b/modules/middleware/auth.go @@ -25,13 +25,13 @@ func Toggle(options *ToggleOptions) macaron.Handler { return func(ctx *Context) { // Cannot view any page before installation. if !setting.InstallLock { - ctx.Redirect(setting.AppRootSubUrl + "/install") + ctx.Redirect(setting.AppSubUrl + "/install") return } // Redirect to dashboard if user tries to visit any non-login page. if options.SignOutRequire && ctx.IsSigned && ctx.Req.RequestURI != "/" { - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") return } @@ -48,8 +48,8 @@ func Toggle(options *ToggleOptions) macaron.Handler { if strings.HasSuffix(ctx.Req.RequestURI, "watch") { return } - ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppRootSubUrl + ctx.Req.RequestURI)) - ctx.Redirect(setting.AppRootSubUrl + "/user/login") + ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppSubUrl+ctx.Req.RequestURI)) + ctx.Redirect(setting.AppSubUrl + "/user/login") return } else if !ctx.User.IsActive && setting.Service.RegisterEmailConfirm { ctx.Data["Title"] = ctx.Tr("auth.active_your_account") diff --git a/modules/middleware/context.go b/modules/middleware/context.go index 5c26f91f5e..9145038fb0 100644 --- a/modules/middleware/context.go +++ b/modules/middleware/context.go @@ -187,7 +187,7 @@ func Contexter() macaron.Handler { Session: sess, } // Compute current URL for real-time change language. - link := setting.AppRootSubUrl + ctx.Req.RequestURI + link := setting.AppSubUrl + ctx.Req.RequestURI i := strings.Index(link, "?") if i > -1 { link = link[:i] diff --git a/modules/middleware/org.go b/modules/middleware/org.go index 3a2cf7bc8f..be10298991 100644 --- a/modules/middleware/org.go +++ b/modules/middleware/org.go @@ -38,7 +38,7 @@ func OrgAssignment(redirect bool, args ...bool) macaron.Handler { ctx.Handle(404, "GetUserByName", err) } else if redirect { log.Error(4, "GetUserByName", err) - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") } else { ctx.Handle(500, "GetUserByName", err) } @@ -68,7 +68,7 @@ func OrgAssignment(redirect bool, args ...bool) macaron.Handler { } ctx.Data["IsOrganizationOwner"] = ctx.Org.IsOwner - ctx.Org.OrgLink = setting.AppRootSubUrl + "/org/" + org.Name + ctx.Org.OrgLink = setting.AppSubUrl + "/org/" + org.Name ctx.Data["OrgLink"] = ctx.Org.OrgLink // Team. @@ -80,7 +80,7 @@ func OrgAssignment(redirect bool, args ...bool) macaron.Handler { ctx.Handle(404, "GetTeam", err) } else if redirect { log.Error(4, "GetTeam", err) - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") } else { ctx.Handle(500, "GetTeam", err) } diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index e7d7fb561d..79b01133bd 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -60,7 +60,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { ctx.Handle(404, "GetUserByName", err) } else if redirect { log.Error(4, "GetUserByName", err) - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") } else { ctx.Handle(500, "GetUserByName", err) } @@ -72,7 +72,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { if u == nil { if redirect { - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") return } ctx.Handle(404, "RepoAssignment", errors.New("invliad user account for single repository")) @@ -92,7 +92,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { ctx.Handle(404, "GetRepositoryByName", err) return } else if redirect { - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") return } ctx.Handle(500, "GetRepositoryByName", err) @@ -160,7 +160,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { return } ctx.Repo.GitRepo = gitRepo - ctx.Repo.RepoLink = setting.AppRootSubUrl + "/" + u.Name + "/" + repo.Name + ctx.Repo.RepoLink = setting.AppSubUrl + "/" + u.Name + "/" + repo.Name ctx.Data["RepoLink"] = ctx.Repo.RepoLink tags, err := ctx.Repo.GitRepo.GetTags() @@ -298,8 +298,8 @@ func RequireTrueOwner() macaron.Handler { return func(ctx *Context) { if !ctx.Repo.IsTrueOwner && !ctx.Repo.IsAdmin { if !ctx.IsSigned { - ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppRootSubUrl + ctx.Req.RequestURI)) - ctx.Redirect(setting.AppRootSubUrl + "/user/login") + ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppSubUrl+ctx.Req.RequestURI)) + ctx.Redirect(setting.AppSubUrl + "/user/login") return } ctx.Handle(404, ctx.Req.RequestURI, nil) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 7442774488..321282df25 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -32,10 +32,10 @@ const ( var ( // App settings. - AppVer string - AppName string - AppUrl string - AppRootSubUrl string + AppVer string + AppName string + AppUrl string + AppSubUrl string // Server settings. Protocol Scheme @@ -167,11 +167,12 @@ func NewConfigContext() { AppUrl += "/" } + // Check if has app suburl. 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) } - AppRootSubUrl = strings.TrimSuffix(url.Path, "/") + AppSubUrl = strings.TrimSuffix(url.Path, "/") Protocol = HTTP if Cfg.MustValue("server", "PROTOCOL") == "https" { diff --git a/routers/admin/admin.go b/routers/admin/admin.go index 1fee7adbd5..6f2966bcb4 100644 --- a/routers/admin/admin.go +++ b/routers/admin/admin.go @@ -143,7 +143,7 @@ func Dashboard(ctx *middleware.Context) { } else { ctx.Flash.Success(success) } - ctx.Redirect(setting.AppRootSubUrl + "/admin") + ctx.Redirect(setting.AppSubUrl + "/admin") return } diff --git a/routers/admin/auths.go b/routers/admin/auths.go index 9eaae489ae..e537572b41 100644 --- a/routers/admin/auths.go +++ b/routers/admin/auths.go @@ -100,7 +100,7 @@ func NewAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) { } log.Trace("Authentication created by admin(%s): %s", ctx.User.Name, form.AuthName) - ctx.Redirect(setting.AppRootSubUrl + "/admin/auths") + ctx.Redirect(setting.AppSubUrl + "/admin/auths") } func EditAuthSource(ctx *middleware.Context) { @@ -181,7 +181,7 @@ func EditAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) { log.Trace("Authentication changed by admin(%s): %s", ctx.User.Name, form.AuthName) ctx.Flash.Success(ctx.Tr("admin.auths.update_success")) - ctx.Redirect(setting.AppRootSubUrl + "/admin/auths/" + ctx.Params(":authid")) + ctx.Redirect(setting.AppSubUrl + "/admin/auths/" + ctx.Params(":authid")) } func DeleteAuthSource(ctx *middleware.Context) { @@ -201,12 +201,12 @@ func DeleteAuthSource(ctx *middleware.Context) { switch err { case models.ErrAuthenticationUserUsed: ctx.Flash.Error("form.still_own_user") - ctx.Redirect(setting.AppRootSubUrl + "/admin/auths/" + ctx.Params(":authid")) + ctx.Redirect(setting.AppSubUrl + "/admin/auths/" + ctx.Params(":authid")) default: ctx.Handle(500, "DelLoginSource", err) } return } log.Trace("Authentication deleted by admin(%s): %s", ctx.User.Name, a.Name) - ctx.Redirect(setting.AppRootSubUrl + "/admin/auths") + ctx.Redirect(setting.AppSubUrl + "/admin/auths") } diff --git a/routers/admin/users.go b/routers/admin/users.go index 5cdb0f5ce9..fc3b0cbce0 100644 --- a/routers/admin/users.go +++ b/routers/admin/users.go @@ -121,7 +121,7 @@ func NewUserPost(ctx *middleware.Context, form auth.RegisterForm) { return } log.Trace("Account created by admin(%s): %s", ctx.User.Name, u.Name) - ctx.Redirect(setting.AppRootSubUrl + "/admin/users") + ctx.Redirect(setting.AppSubUrl + "/admin/users") } func EditUser(ctx *middleware.Context) { @@ -198,7 +198,7 @@ func EditUserPost(ctx *middleware.Context, form auth.AdminEditUserForm) { ctx.Data["User"] = u ctx.Flash.Success(ctx.Tr("admin.users.update_profile_success")) - ctx.Redirect(setting.AppRootSubUrl + "/admin/users/" + ctx.Params(":userid")) + ctx.Redirect(setting.AppSubUrl + "/admin/users/" + ctx.Params(":userid")) } func DeleteUser(ctx *middleware.Context) { @@ -218,12 +218,12 @@ func DeleteUser(ctx *middleware.Context) { switch err { case models.ErrUserOwnRepos: ctx.Flash.Error(ctx.Tr("admin.users.still_own_repo")) - ctx.Redirect(setting.AppRootSubUrl + "/admin/users/" + ctx.Params(":userid")) + ctx.Redirect(setting.AppSubUrl + "/admin/users/" + ctx.Params(":userid")) default: ctx.Handle(500, "DeleteUser", err) } return } log.Trace("Account deleted by admin(%s): %s", ctx.User.Name, u.Name) - ctx.Redirect(setting.AppRootSubUrl + "/admin/users") + ctx.Redirect(setting.AppSubUrl + "/admin/users") } diff --git a/routers/home.go b/routers/home.go index 8e973d161b..dd604ec7e3 100644 --- a/routers/home.go +++ b/routers/home.go @@ -33,7 +33,7 @@ func Home(ctx *middleware.Context) { // Check auto-login. uname := ctx.GetCookie(setting.CookieUserName) if len(uname) != 0 { - ctx.Redirect(setting.AppRootSubUrl + "/user/login") + ctx.Redirect(setting.AppSubUrl + "/user/login") return } diff --git a/routers/install.go b/routers/install.go index 54da4d4f72..07af613c7e 100644 --- a/routers/install.go +++ b/routers/install.go @@ -253,5 +253,5 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) { log.Info("First-time run install finished!") ctx.Flash.Success(ctx.Tr("install.install_success")) - ctx.Redirect(setting.AppRootSubUrl + "/user/login") + ctx.Redirect(setting.AppSubUrl + "/user/login") } diff --git a/routers/org/members.go b/routers/org/members.go index d3bd51eae8..f571e334e1 100644 --- a/routers/org/members.go +++ b/routers/org/members.go @@ -87,7 +87,7 @@ func MembersAction(ctx *middleware.Context) { if ctx.Params(":action") != "leave" { ctx.Redirect(ctx.Org.OrgLink + "/members") } else { - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") } } diff --git a/routers/org/org.go b/routers/org/org.go index cea70823af..ab589832d1 100644 --- a/routers/org/org.go +++ b/routers/org/org.go @@ -83,5 +83,5 @@ func CreatePost(ctx *middleware.Context, form auth.CreateOrgForm) { } log.Trace("Organization created: %s", org.Name) - ctx.Redirect(setting.AppRootSubUrl + "/org/" + form.OrgName + "/dashboard") + ctx.Redirect(setting.AppSubUrl + "/org/" + form.OrgName + "/dashboard") } diff --git a/routers/org/setting.go b/routers/org/setting.go index 3d397c0c66..0522f99803 100644 --- a/routers/org/setting.go +++ b/routers/org/setting.go @@ -49,7 +49,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateOrgSettingForm) { } else if err = models.ChangeUserName(org, form.OrgUserName); err != nil { if err == models.ErrUserNameIllegal { ctx.Flash.Error(ctx.Tr("form.illegal_username")) - ctx.Redirect(setting.AppRootSubUrl + "/org/" + org.LowerName + "/settings") + ctx.Redirect(setting.AppSubUrl + "/org/" + org.LowerName + "/settings") return } else { ctx.Handle(500, "ChangeUserName", err) @@ -73,7 +73,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateOrgSettingForm) { } log.Trace("Organization setting updated: %s", org.Name) ctx.Flash.Success(ctx.Tr("org.settings.update_setting_success")) - ctx.Redirect(setting.AppRootSubUrl + "/org/" + org.Name + "/settings") + ctx.Redirect(setting.AppSubUrl + "/org/" + org.Name + "/settings") } func SettingsDelete(ctx *middleware.Context) { @@ -87,13 +87,13 @@ func SettingsDelete(ctx *middleware.Context) { switch err { case models.ErrUserOwnRepos: ctx.Flash.Error(ctx.Tr("form.org_still_own_repo")) - ctx.Redirect(setting.AppRootSubUrl + "/org/" + org.LowerName + "/settings/delete") + ctx.Redirect(setting.AppSubUrl + "/org/" + org.LowerName + "/settings/delete") default: ctx.Handle(500, "DeleteOrganization", err) } } else { log.Trace("Organization deleted: %s", ctx.User.Name) - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") } return } diff --git a/routers/repo/commit.go b/routers/repo/commit.go index e58b9e78f6..218cae7bed 100644 --- a/routers/repo/commit.go +++ b/routers/repo/commit.go @@ -159,8 +159,8 @@ func Diff(ctx *middleware.Context) { ctx.Data["Diff"] = diff ctx.Data["Parents"] = parents ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0 - ctx.Data["SourcePath"] = setting.AppRootSubUrl + "/" + path.Join(userName, repoName, "src", commitId) - ctx.Data["RawPath"] = setting.AppRootSubUrl + "/" + path.Join(userName, repoName, "raw", commitId) + ctx.Data["SourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", commitId) + ctx.Data["RawPath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "raw", commitId) ctx.HTML(200, DIFF) } diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 8aba82ffc5..3a028e58ff 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -54,8 +54,8 @@ func Issues(ctx *middleware.Context) { isShowClosed := ctx.Query("state") == "closed" if viewType != "all" && !ctx.IsSigned { - ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppRootSubUrl + ctx.Req.RequestURI)) - ctx.Redirect(setting.AppRootSubUrl + "/user/login") + ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppSubUrl+ctx.Req.RequestURI)) + ctx.Redirect(setting.AppSubUrl + "/user/login") return } @@ -312,7 +312,7 @@ func CreateIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) { } log.Trace("%d Issue created: %d", ctx.Repo.Repository.Id, issue.Id) - send(200, fmt.Sprintf("%s/%s/%s/issues/%d", setting.AppRootSubUrl, ctx.Params(":username"), ctx.Params(":reponame"), issue.Index), nil) + send(200, fmt.Sprintf("%s/%s/%s/issues/%d", setting.AppSubUrl, ctx.Params(":username"), ctx.Params(":reponame"), issue.Index), nil) } func checkLabels(labels, allLabels []*models.Label) { diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 3bd9aa7cd1..ae599f9fa2 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -96,7 +96,7 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) { form.Gitignore, form.License, form.Private, false, form.InitReadme) if err == nil { log.Trace("Repository created: %s/%s", ctxUser.Name, form.RepoName) - ctx.Redirect(setting.AppRootSubUrl + "/" + ctxUser.Name + "/" + form.RepoName) + ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + form.RepoName) return } else if err == models.ErrRepoAlreadyExist { ctx.Data["Err_RepoName"] = true @@ -180,7 +180,7 @@ func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) { form.Mirror, url) if err == nil { log.Trace("Repository migrated: %s/%s", ctxUser.Name, form.RepoName) - ctx.Redirect(setting.AppRootSubUrl + "/" + ctxUser.Name + "/" + form.RepoName) + ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + form.RepoName) return } else if err == models.ErrRepoAlreadyExist { ctx.Data["Err_RepoName"] = true diff --git a/routers/repo/setting.go b/routers/repo/setting.go index 926b543202..137d104f9d 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -97,7 +97,7 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) { } ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success")) - ctx.Redirect(fmt.Sprintf("%s/%s/%s/settings", setting.AppRootSubUrl, ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)) + ctx.Redirect(fmt.Sprintf("%s/%s/%s/settings", setting.AppSubUrl, ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)) case "transfer": if ctx.Repo.Repository.Name != form.RepoName { ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), SETTINGS_OPTIONS, nil) @@ -122,7 +122,7 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) { } log.Trace("Repository transfered: %s/%s -> %s", ctx.Repo.Owner.Name, ctx.Repo.Repository.Name, newOwner) ctx.Flash.Success(ctx.Tr("repo.settings.transfer_succeed")) - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") case "delete": if ctx.Repo.Repository.Name != form.RepoName { ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), SETTINGS_OPTIONS, nil) @@ -151,9 +151,9 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) { } log.Trace("Repository deleted: %s/%s", ctx.Repo.Owner.Name, ctx.Repo.Repository.Name) if ctx.Repo.Owner.IsOrganization() { - ctx.Redirect(setting.AppRootSubUrl + "/org/" + ctx.Repo.Owner.Name + "/dashboard") + ctx.Redirect(setting.AppSubUrl + "/org/" + ctx.Repo.Owner.Name + "/dashboard") } else { - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") } } } @@ -167,7 +167,7 @@ func SettingsCollaboration(ctx *middleware.Context) { if ctx.Req.Method == "POST" { name := strings.ToLower(ctx.Query("collaborator")) if len(name) == 0 || ctx.Repo.Owner.LowerName == name { - ctx.Redirect(setting.AppRootSubUrl + ctx.Req.URL.Path) + ctx.Redirect(setting.AppSubUrl + ctx.Req.URL.Path) return } has, err := models.HasAccess(name, repoLink, models.WRITABLE) @@ -175,7 +175,7 @@ func SettingsCollaboration(ctx *middleware.Context) { ctx.Handle(500, "HasAccess", err) return } else if has { - ctx.Redirect(setting.AppRootSubUrl + ctx.Req.URL.Path) + ctx.Redirect(setting.AppSubUrl + ctx.Req.URL.Path) return } @@ -183,7 +183,7 @@ func SettingsCollaboration(ctx *middleware.Context) { if err != nil { if err == models.ErrUserNotExist { ctx.Flash.Error(ctx.Tr("form.user_not_exist")) - ctx.Redirect(setting.AppRootSubUrl + ctx.Req.URL.Path) + ctx.Redirect(setting.AppSubUrl + ctx.Req.URL.Path) } else { ctx.Handle(500, "GetUserByName", err) } @@ -204,7 +204,7 @@ func SettingsCollaboration(ctx *middleware.Context) { } ctx.Flash.Success(ctx.Tr("repo.settings.add_collaborator_success")) - ctx.Redirect(setting.AppRootSubUrl + ctx.Req.URL.Path) + ctx.Redirect(setting.AppSubUrl + ctx.Req.URL.Path) return } diff --git a/routers/user/auth.go b/routers/user/auth.go index 1dbc3300dd..71622e5543 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -82,7 +82,7 @@ func SignIn(ctx *middleware.Context) { return } - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") } func SignInPost(ctx *middleware.Context, form auth.SignInForm) { @@ -140,7 +140,7 @@ func SignInPost(ctx *middleware.Context, form auth.SignInForm) { return } - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") } func SignOut(ctx *middleware.Context) { @@ -151,7 +151,7 @@ func SignOut(ctx *middleware.Context) { ctx.Session.Delete("socialEmail") ctx.SetCookie(setting.CookieUserName, "", -1) ctx.SetCookie(setting.CookieRememberName, "", -1) - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") } func oauthSignUp(ctx *middleware.Context, sid int64) { @@ -288,7 +288,7 @@ func SignUpPost(ctx *middleware.Context, cpt *captcha.Captcha, form auth.Registe return } - ctx.Redirect(setting.AppRootSubUrl + "/user/login") + ctx.Redirect(setting.AppSubUrl + "/user/login") } func Activate(ctx *middleware.Context) { @@ -335,7 +335,7 @@ func Activate(ctx *middleware.Context) { ctx.Session.Set("uid", user.Id) ctx.Session.Set("uname", user.Name) - ctx.Redirect(setting.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") return } @@ -437,7 +437,7 @@ func ResetPasswdPost(ctx *middleware.Context) { } log.Trace("User password reset: %s", u.Name) - ctx.Redirect(setting.AppRootSubUrl + "/user/login") + ctx.Redirect(setting.AppSubUrl + "/user/login") return } diff --git a/routers/user/home.go b/routers/user/home.go index b411b8fc1f..031872fca9 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -127,7 +127,7 @@ func Profile(ctx *middleware.Context) { uname := ctx.Params(":username") // Special handle for FireFox requests favicon.ico. if uname == "favicon.ico" { - ctx.Redirect(setting.AppRootSubUrl + "/img/favicon.png") + ctx.Redirect(setting.AppSubUrl + "/img/favicon.png") return } @@ -142,7 +142,7 @@ func Profile(ctx *middleware.Context) { } if u.IsOrganization() { - ctx.Redirect(setting.AppRootSubUrl + "/org/" + u.Name) + ctx.Redirect(setting.AppSubUrl + "/org/" + u.Name) return } @@ -182,7 +182,7 @@ func Email2User(ctx *middleware.Context) { } return } - ctx.Redirect(setting.AppRootSubUrl + "/user/" + u.Name) + ctx.Redirect(setting.AppSubUrl + "/user/" + u.Name) } const ( diff --git a/routers/user/setting.go b/routers/user/setting.go index a540f054f8..8f778acd0d 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -56,7 +56,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateProfileForm) { } else if err = models.ChangeUserName(ctx.User, form.UserName); err != nil { if err == models.ErrUserNameIllegal { ctx.Flash.Error(ctx.Tr("form.illegal_username")) - ctx.Redirect(setting.AppRootSubUrl + "/user/settings") + ctx.Redirect(setting.AppSubUrl + "/user/settings") return } else { ctx.Handle(500, "ChangeUserName", err) @@ -79,7 +79,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateProfileForm) { } log.Trace("User setting updated: %s", ctx.User.Name) ctx.Flash.Success(ctx.Tr("settings.update_profile_success")) - ctx.Redirect(setting.AppRootSubUrl + "/user/settings") + ctx.Redirect(setting.AppSubUrl + "/user/settings") } func SettingsPassword(ctx *middleware.Context) { @@ -120,7 +120,7 @@ func SettingsPasswordPost(ctx *middleware.Context, form auth.ChangePasswordForm) ctx.Flash.Success(ctx.Tr("settings.change_password_success")) } - ctx.Redirect(setting.AppRootSubUrl + "/user/settings/password") + ctx.Redirect(setting.AppSubUrl + "/user/settings/password") } func SettingsSSHKeys(ctx *middleware.Context) { @@ -161,7 +161,7 @@ func SettingsSSHKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) { ctx.Handle(500, "DeletePublicKey", err) } else { log.Trace("SSH key deleted: %s", ctx.User.Name) - ctx.Redirect(setting.AppRootSubUrl + "/user/settings/ssh") + ctx.Redirect(setting.AppSubUrl + "/user/settings/ssh") } return } @@ -178,7 +178,7 @@ func SettingsSSHKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) { if ok, err := models.CheckPublicKeyString(cleanContent); !ok { ctx.Flash.Error(ctx.Tr("form.invalid_ssh_key", err.Error())) - ctx.Redirect(setting.AppRootSubUrl + "/user/settings/ssh") + ctx.Redirect(setting.AppSubUrl + "/user/settings/ssh") return } @@ -197,7 +197,7 @@ func SettingsSSHKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) { } else { log.Trace("SSH key added: %s", ctx.User.Name) ctx.Flash.Success(ctx.Tr("settings.add_key_success")) - ctx.Redirect(setting.AppRootSubUrl + "/user/settings/ssh") + ctx.Redirect(setting.AppSubUrl + "/user/settings/ssh") return } } @@ -218,7 +218,7 @@ func SettingsSocial(ctx *middleware.Context) { return } ctx.Flash.Success(ctx.Tr("settings.unbind_success")) - ctx.Redirect(setting.AppRootSubUrl + "/user/settings/social") + ctx.Redirect(setting.AppSubUrl + "/user/settings/social") return } @@ -249,13 +249,13 @@ func SettingsDelete(ctx *middleware.Context) { switch err { case models.ErrUserOwnRepos: ctx.Flash.Error(ctx.Tr("form.still_own_repo")) - ctx.Redirect(setting.AppRootSubUrl + "/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.AppRootSubUrl + "/") + ctx.Redirect(setting.AppSubUrl + "/") } return } diff --git a/routers/user/social.go b/routers/user/social.go index fc2ea5fb49..0bc1fa592f 100644 --- a/routers/user/social.go +++ b/routers/user/social.go @@ -22,7 +22,7 @@ import ( func extractPath(next string) string { n, err := url.Parse(next) if err != nil { - return setting.AppRootSubUrl + "/" + return setting.AppSubUrl + "/" } return n.Path } @@ -88,7 +88,7 @@ func SocialSignIn(ctx *middleware.Context) { return } case models.ErrOauth2NotAssociated: - next = setting.AppRootSubUrl + "/user/sign_up" + next = setting.AppSubUrl + "/user/sign_up" default: ctx.Handle(500, "social.SocialSignIn(GetOauth2)", err) return diff --git a/templates/.VERSION b/templates/.VERSION index 29de2fdfe1..9df945b783 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.5.2.0917 Beta \ No newline at end of file +0.5.3.0919 Beta \ No newline at end of file diff --git a/templates/admin/auth/edit.tmpl b/templates/admin/auth/edit.tmpl index 4dead7f079..9697b77369 100644 --- a/templates/admin/auth/edit.tmpl +++ b/templates/admin/auth/edit.tmpl @@ -12,7 +12,7 @@