summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/base/markdown.go2
-rw-r--r--modules/base/template.go16
-rw-r--r--modules/middleware/auth.go8
-rw-r--r--modules/middleware/context.go2
-rw-r--r--modules/middleware/org.go6
-rw-r--r--modules/middleware/repo.go12
-rw-r--r--modules/setting/setting.go13
7 files changed, 30 insertions, 29 deletions
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(`<a href="%s/user/%s">%s</a>`, setting.AppRootSubUrl, m[1:], m)), -1)
+ []byte(fmt.Sprintf(`<a href="%s/user/%s">%s</a>`, 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(`<div><a href="{{AppRootSubUrl}}/%s/%s/commits/%s" rel="nofollow">%d other commits >></a></div>`, 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" {