Clarify the suffices and prefixes of setting.AppSubURL and setting.AppURL (#12999)
Also removes some unnecessary uses of fmt.Sprintf and adds documentation strings Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
parent
39aa11f9c0
commit
aa4f9180e4
11 changed files with 53 additions and 42 deletions
|
@ -364,7 +364,7 @@ func WorkerCancel(ctx *context.Context) {
|
|||
mq.CancelWorkers(pid)
|
||||
ctx.Flash.Info(ctx.Tr("admin.monitor.queue.pool.cancelling"))
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
"redirect": setting.AppSubURL + fmt.Sprintf("/admin/monitor/queue/%d", qid),
|
||||
"redirect": setting.AppSubURL + "/admin/monitor/queue/" + strconv.FormatInt(qid, 10),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -387,7 +387,7 @@ func Flush(ctx *context.Context) {
|
|||
log.Error("Flushing failure for %s: Error %v", mq.Name, err)
|
||||
}
|
||||
}()
|
||||
ctx.Redirect(setting.AppSubURL + fmt.Sprintf("/admin/monitor/queue/%d", qid))
|
||||
ctx.Redirect(setting.AppSubURL + "/admin/monitor/queue/" + strconv.FormatInt(qid, 10))
|
||||
}
|
||||
|
||||
// AddWorkers adds workers to a worker group
|
||||
|
@ -401,23 +401,23 @@ func AddWorkers(ctx *context.Context) {
|
|||
number := ctx.QueryInt("number")
|
||||
if number < 1 {
|
||||
ctx.Flash.Error(ctx.Tr("admin.monitor.queue.pool.addworkers.mustnumbergreaterzero"))
|
||||
ctx.Redirect(setting.AppSubURL + fmt.Sprintf("/admin/monitor/queue/%d", qid))
|
||||
ctx.Redirect(setting.AppSubURL + "/admin/monitor/queue/" + strconv.FormatInt(qid, 10))
|
||||
return
|
||||
}
|
||||
timeout, err := time.ParseDuration(ctx.Query("timeout"))
|
||||
if err != nil {
|
||||
ctx.Flash.Error(ctx.Tr("admin.monitor.queue.pool.addworkers.musttimeoutduration"))
|
||||
ctx.Redirect(setting.AppSubURL + fmt.Sprintf("/admin/monitor/queue/%d", qid))
|
||||
ctx.Redirect(setting.AppSubURL + "/admin/monitor/queue/" + strconv.FormatInt(qid, 10))
|
||||
return
|
||||
}
|
||||
if _, ok := mq.Managed.(queue.ManagedPool); !ok {
|
||||
ctx.Flash.Error(ctx.Tr("admin.monitor.queue.pool.none"))
|
||||
ctx.Redirect(setting.AppSubURL + fmt.Sprintf("/admin/monitor/queue/%d", qid))
|
||||
ctx.Redirect(setting.AppSubURL + "/admin/monitor/queue/" + strconv.FormatInt(qid, 10))
|
||||
return
|
||||
}
|
||||
mq.AddWorkers(number, timeout)
|
||||
ctx.Flash.Success(ctx.Tr("admin.monitor.queue.pool.added"))
|
||||
ctx.Redirect(setting.AppSubURL + fmt.Sprintf("/admin/monitor/queue/%d", qid))
|
||||
ctx.Redirect(setting.AppSubURL + "/admin/monitor/queue/" + strconv.FormatInt(qid, 10))
|
||||
}
|
||||
|
||||
// SetQueueSettings sets the maximum number of workers and other settings for this queue
|
||||
|
@ -430,7 +430,7 @@ func SetQueueSettings(ctx *context.Context) {
|
|||
}
|
||||
if _, ok := mq.Managed.(queue.ManagedPool); !ok {
|
||||
ctx.Flash.Error(ctx.Tr("admin.monitor.queue.pool.none"))
|
||||
ctx.Redirect(setting.AppSubURL + fmt.Sprintf("/admin/monitor/queue/%d", qid))
|
||||
ctx.Redirect(setting.AppSubURL + "/admin/monitor/queue/" + strconv.FormatInt(qid, 10))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -445,7 +445,7 @@ func SetQueueSettings(ctx *context.Context) {
|
|||
maxNumber, err = strconv.Atoi(maxNumberStr)
|
||||
if err != nil {
|
||||
ctx.Flash.Error(ctx.Tr("admin.monitor.queue.settings.maxnumberworkers.error"))
|
||||
ctx.Redirect(setting.AppSubURL + fmt.Sprintf("/admin/monitor/queue/%d", qid))
|
||||
ctx.Redirect(setting.AppSubURL + "/admin/monitor/queue/" + strconv.FormatInt(qid, 10))
|
||||
return
|
||||
}
|
||||
if maxNumber < -1 {
|
||||
|
@ -459,7 +459,7 @@ func SetQueueSettings(ctx *context.Context) {
|
|||
number, err = strconv.Atoi(numberStr)
|
||||
if err != nil || number < 0 {
|
||||
ctx.Flash.Error(ctx.Tr("admin.monitor.queue.settings.numberworkers.error"))
|
||||
ctx.Redirect(setting.AppSubURL + fmt.Sprintf("/admin/monitor/queue/%d", qid))
|
||||
ctx.Redirect(setting.AppSubURL + "/admin/monitor/queue/" + strconv.FormatInt(qid, 10))
|
||||
return
|
||||
}
|
||||
} else {
|
||||
|
@ -470,7 +470,7 @@ func SetQueueSettings(ctx *context.Context) {
|
|||
timeout, err = time.ParseDuration(timeoutStr)
|
||||
if err != nil {
|
||||
ctx.Flash.Error(ctx.Tr("admin.monitor.queue.settings.timeout.error"))
|
||||
ctx.Redirect(setting.AppSubURL + fmt.Sprintf("/admin/monitor/queue/%d", qid))
|
||||
ctx.Redirect(setting.AppSubURL + "/admin/monitor/queue/" + strconv.FormatInt(qid, 10))
|
||||
return
|
||||
}
|
||||
} else {
|
||||
|
@ -479,5 +479,5 @@ func SetQueueSettings(ctx *context.Context) {
|
|||
|
||||
mq.SetPoolSettings(maxNumber, number, timeout)
|
||||
ctx.Flash.Success(ctx.Tr("admin.monitor.queue.settings.changed"))
|
||||
ctx.Redirect(setting.AppSubURL + fmt.Sprintf("/admin/monitor/queue/%d", qid))
|
||||
ctx.Redirect(setting.AppSubURL + "/admin/monitor/queue/" + strconv.FormatInt(qid, 10))
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
package org
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
|
@ -153,8 +152,7 @@ func IsMember(ctx *context.APIContext) {
|
|||
}
|
||||
}
|
||||
|
||||
redirectURL := fmt.Sprintf("%sapi/v1/orgs/%s/public_members/%s",
|
||||
setting.AppURL, ctx.Org.Organization.Name, userToCheck.Name)
|
||||
redirectURL := setting.AppURL + "api/v1/orgs/" + ctx.Org.Organization.Name + "/public_members/" + userToCheck.Name
|
||||
ctx.Redirect(redirectURL, 302)
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,7 @@ func Search(ctx *context.Context) {
|
|||
ctx.Data["Keyword"] = keyword
|
||||
ctx.Data["Language"] = language
|
||||
ctx.Data["queryType"] = queryType
|
||||
ctx.Data["SourcePath"] = setting.AppSubURL + "/" +
|
||||
path.Join(ctx.Repo.Repository.Owner.Name, ctx.Repo.Repository.Name)
|
||||
ctx.Data["SourcePath"] = path.Join(setting.AppSubURL, ctx.Repo.Repository.Owner.Name, ctx.Repo.Repository.Name)
|
||||
ctx.Data["SearchResults"] = searchResults
|
||||
ctx.Data["SearchResultLanguages"] = searchResultLanguages
|
||||
ctx.Data["RequireHighlightJS"] = true
|
||||
|
|
|
@ -174,7 +174,7 @@ func NotificationStatusPost(c *context.Context) {
|
|||
if c.Written() {
|
||||
return
|
||||
}
|
||||
c.Data["Link"] = fmt.Sprintf("%snotifications", setting.AppURL)
|
||||
c.Data["Link"] = setting.AppURL + "notifications"
|
||||
|
||||
c.HTML(http.StatusOK, tplNotificationDiv)
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ func TestIsValidSlackChannel(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestIsExternalURL(t *testing.T) {
|
||||
setting.AppURL = "https://try.gitea.io"
|
||||
setting.AppURL = "https://try.gitea.io/"
|
||||
type test struct {
|
||||
Expected bool
|
||||
RawURL string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue