Skip to content

Commit 90b9f7e

Browse files
committed
pkg/setting: rename {AppUrl, AppSubUrl} -> {AppURL, AppSubURL}
1 parent 2c404da commit 90b9f7e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+351
-349
lines changed

cmd/web.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func newMacaron() *macaron.Macaron {
8585
m.Use(gzip.Gziper())
8686
}
8787
if setting.Protocol == setting.SCHEME_FCGI {
88-
m.SetURLPrefix(setting.AppSubUrl)
88+
m.SetURLPrefix(setting.AppSubURL)
8989
}
9090
m.Use(macaron.Static(
9191
path.Join(setting.StaticRootPath, "public"),
@@ -120,7 +120,7 @@ func newMacaron() *macaron.Macaron {
120120
localFiles[name] = bindata.MustAsset("conf/locale/" + name)
121121
}
122122
m.Use(i18n.I18n(i18n.Options{
123-
SubURL: setting.AppSubUrl,
123+
SubURL: setting.AppSubURL,
124124
Files: localFiles,
125125
CustomDirectory: path.Join(setting.CustomPath, "conf/locale"),
126126
Langs: setting.Langs,
@@ -134,15 +134,15 @@ func newMacaron() *macaron.Macaron {
134134
Interval: setting.CacheInterval,
135135
}))
136136
m.Use(captcha.Captchaer(captcha.Options{
137-
SubURL: setting.AppSubUrl,
137+
SubURL: setting.AppSubURL,
138138
}))
139139
m.Use(session.Sessioner(setting.SessionConfig))
140140
m.Use(csrf.Csrfer(csrf.Options{
141141
Secret: setting.SecretKey,
142142
Cookie: setting.CSRFCookieName,
143143
SetCookie: true,
144144
Header: "X-Csrf-Token",
145-
CookiePath: setting.AppSubUrl,
145+
CookiePath: setting.AppSubURL,
146146
}))
147147
m.Use(toolbox.Toolboxer(m, toolbox.Options{
148148
HealthCheckFuncs: []*toolbox.HealthCheckFuncDesc{
@@ -178,7 +178,7 @@ func runWeb(ctx *cli.Context) error {
178178
m.Get("/", ignSignIn, routers.Home)
179179
m.Group("/explore", func() {
180180
m.Get("", func(ctx *context.Context) {
181-
ctx.Redirect(setting.AppSubUrl + "/explore/repos")
181+
ctx.Redirect(setting.AppSubURL + "/explore/repos")
182182
})
183183
m.Get("/repos", routers.ExploreRepos)
184184
m.Get("/users", routers.ExploreUsers)
@@ -655,7 +655,7 @@ func runWeb(ctx *cli.Context) error {
655655

656656
// Flag for port number in case first time run conflict.
657657
if ctx.IsSet("port") {
658-
setting.AppUrl = strings.Replace(setting.AppUrl, setting.HTTPPort, ctx.String("port"), 1)
658+
setting.AppURL = strings.Replace(setting.AppURL, setting.HTTPPort, ctx.String("port"), 1)
659659
setting.HTTPPort = ctx.String("port")
660660
}
661661

@@ -665,7 +665,7 @@ func runWeb(ctx *cli.Context) error {
665665
} else {
666666
listenAddr = fmt.Sprintf("%s:%s", setting.HTTPAddr, setting.HTTPPort)
667667
}
668-
log.Info("Listen: %v://%s%s", setting.Protocol, listenAddr, setting.AppSubUrl)
668+
log.Info("Listen: %v://%s%s", setting.Protocol, listenAddr, setting.AppSubURL)
669669

670670
var err error
671671
switch setting.Protocol {

models/action.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ func (a *Action) ShortRepoPath() string {
136136
}
137137

138138
func (a *Action) GetRepoLink() string {
139-
if len(setting.AppSubUrl) > 0 {
140-
return path.Join(setting.AppSubUrl, a.GetRepoPath())
139+
if len(setting.AppSubURL) > 0 {
140+
return path.Join(setting.AppSubURL, a.GetRepoPath())
141141
}
142142
return "/" + a.GetRepoPath()
143143
}
@@ -540,7 +540,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
540540
return nil
541541
}
542542

543-
compareURL := setting.AppUrl + opts.Commits.CompareURL
543+
compareURL := setting.AppURL + opts.Commits.CompareURL
544544
if isNewRef {
545545
compareURL = ""
546546
if err = PrepareWebhooks(repo, HOOK_EVENT_CREATE, &api.CreatePayload{

models/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error
324324
Ref: git.BRANCH_PREFIX + pr.BaseBranch,
325325
Before: pr.MergeBase,
326326
After: pr.MergedCommitID,
327-
CompareURL: setting.AppUrl + pr.BaseRepo.ComposeCompareURL(pr.MergeBase, pr.MergedCommitID),
327+
CompareURL: setting.AppURL + pr.BaseRepo.ComposeCompareURL(pr.MergeBase, pr.MergedCommitID),
328328
Commits: commits,
329329
Repo: pr.BaseRepo.APIFormat(nil),
330330
Pusher: pr.HeadRepo.MustOwner().APIFormat(),

models/repo.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ func (repo *Repository) FullName() string {
279279
}
280280

281281
func (repo *Repository) HTMLURL() string {
282-
return setting.AppUrl + repo.FullName()
282+
return setting.AppURL + repo.FullName()
283283
}
284284

285285
// Arguments that are allowed to be nil: permission
@@ -458,7 +458,7 @@ func (repo *Repository) RelLink() string {
458458
}
459459

460460
func (repo *Repository) Link() string {
461-
return setting.AppSubUrl + "/" + repo.FullName()
461+
return setting.AppSubURL + "/" + repo.FullName()
462462
}
463463

464464
func (repo *Repository) ComposeCompareURL(oldCommitID, newCommitID string) string {
@@ -597,7 +597,7 @@ type CloneLink struct {
597597

598598
// ComposeHTTPSCloneURL returns HTTPS clone URL based on given owner and repository name.
599599
func ComposeHTTPSCloneURL(owner, repo string) string {
600-
return fmt.Sprintf("%s%s/%s.git", setting.AppUrl, owner, repo)
600+
return fmt.Sprintf("%s%s/%s.git", setting.AppURL, owner, repo)
601601
}
602602

603603
func (repo *Repository) cloneLink(isWiki bool) *CloneLink {

models/user.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,18 @@ func (u *User) CanImportLocal() bool {
175175
// DashboardLink returns the user dashboard page link.
176176
func (u *User) DashboardLink() string {
177177
if u.IsOrganization() {
178-
return setting.AppSubUrl + "/org/" + u.Name + "/dashboard/"
178+
return setting.AppSubURL + "/org/" + u.Name + "/dashboard/"
179179
}
180-
return setting.AppSubUrl + "/"
180+
return setting.AppSubURL + "/"
181181
}
182182

183183
// HomeLink returns the user or organization home page link.
184184
func (u *User) HomeLink() string {
185-
return setting.AppSubUrl + "/" + u.Name
185+
return setting.AppSubURL + "/" + u.Name
186186
}
187187

188188
func (u *User) HTMLURL() string {
189-
return setting.AppUrl + u.Name
189+
return setting.AppURL + u.Name
190190
}
191191

192192
// GenerateEmailActivateCode generates an activate code based on user information and given e-mail.
@@ -242,7 +242,7 @@ func (u *User) GenerateRandomAvatar() error {
242242
// which includes app sub-url as prefix. However, it is possible
243243
// to return full URL if user enables Gravatar-like service.
244244
func (u *User) RelAvatarLink() string {
245-
defaultImgUrl := setting.AppSubUrl + "/img/avatar_default.png"
245+
defaultImgUrl := setting.AppSubURL + "/img/avatar_default.png"
246246
if u.ID == -1 {
247247
return defaultImgUrl
248248
}
@@ -252,15 +252,15 @@ func (u *User) RelAvatarLink() string {
252252
if !com.IsExist(u.CustomAvatarPath()) {
253253
return defaultImgUrl
254254
}
255-
return setting.AppSubUrl + "/avatars/" + com.ToStr(u.ID)
255+
return setting.AppSubURL + "/avatars/" + com.ToStr(u.ID)
256256
case setting.DisableGravatar, setting.OfflineMode:
257257
if !com.IsExist(u.CustomAvatarPath()) {
258258
if err := u.GenerateRandomAvatar(); err != nil {
259259
log.Error(3, "GenerateRandomAvatar: %v", err)
260260
}
261261
}
262262

263-
return setting.AppSubUrl + "/avatars/" + com.ToStr(u.ID)
263+
return setting.AppSubURL + "/avatars/" + com.ToStr(u.ID)
264264
}
265265
return tool.AvatarLink(u.AvatarEmail)
266266
}
@@ -269,7 +269,7 @@ func (u *User) RelAvatarLink() string {
269269
func (u *User) AvatarLink() string {
270270
link := u.RelAvatarLink()
271271
if link[0] == '/' && link[1] != '/' {
272-
return setting.AppUrl + strings.TrimPrefix(link, setting.AppSubUrl)[1:]
272+
return setting.AppURL + strings.TrimPrefix(link, setting.AppSubURL)[1:]
273273
}
274274
return link
275275
}

models/webhook_discord.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func getDiscordCreatePayload(p *api.CreatePayload) (*DiscordPayload, error) {
7777
return &DiscordPayload{
7878
Embeds: []*DiscordEmbedObject{{
7979
Description: content,
80-
URL: setting.AppUrl + p.Sender.UserName,
80+
URL: setting.AppURL + p.Sender.UserName,
8181
Author: &DiscordEmbedAuthorObject{
8282
Name: p.Sender.UserName,
8383
IconURL: p.Sender.AvatarUrl,
@@ -94,7 +94,7 @@ func getDiscordDeletePayload(p *api.DeletePayload) (*DiscordPayload, error) {
9494
return &DiscordPayload{
9595
Embeds: []*DiscordEmbedObject{{
9696
Description: content,
97-
URL: setting.AppUrl + p.Sender.UserName,
97+
URL: setting.AppURL + p.Sender.UserName,
9898
Author: &DiscordEmbedAuthorObject{
9999
Name: p.Sender.UserName,
100100
IconURL: p.Sender.AvatarUrl,
@@ -111,7 +111,7 @@ func getDiscordForkPayload(p *api.ForkPayload) (*DiscordPayload, error) {
111111
return &DiscordPayload{
112112
Embeds: []*DiscordEmbedObject{{
113113
Description: content,
114-
URL: setting.AppUrl + p.Sender.UserName,
114+
URL: setting.AppURL + p.Sender.UserName,
115115
Author: &DiscordEmbedAuthorObject{
116116
Name: p.Sender.UserName,
117117
IconURL: p.Sender.AvatarUrl,
@@ -159,7 +159,7 @@ func getDiscordPushPayload(p *api.PushPayload, slack *SlackMeta) (*DiscordPayloa
159159
AvatarURL: slack.IconURL,
160160
Embeds: []*DiscordEmbedObject{{
161161
Description: content,
162-
URL: setting.AppUrl + p.Sender.UserName,
162+
URL: setting.AppURL + p.Sender.UserName,
163163
Color: int(color),
164164
Author: &DiscordEmbedAuthorObject{
165165
Name: p.Sender.UserName,
@@ -360,7 +360,7 @@ func getDiscordReleasePayload(p *api.ReleasePayload) (*DiscordPayload, error) {
360360
return &DiscordPayload{
361361
Embeds: []*DiscordEmbedObject{{
362362
Description: content,
363-
URL: setting.AppUrl + p.Sender.UserName,
363+
URL: setting.AppURL + p.Sender.UserName,
364364
Author: &DiscordEmbedAuthorObject{
365365
Name: p.Sender.UserName,
366366
IconURL: p.Sender.AvatarUrl,

models/webhook_slack.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func getSlackPushPayload(p *api.PushPayload, slack *SlackMeta) (*SlackPayload, e
146146
}
147147

148148
func getSlackIssuesPayload(p *api.IssuesPayload, slack *SlackMeta) (*SlackPayload, error) {
149-
senderLink := SlackLinkFormatter(setting.AppUrl+p.Sender.UserName, p.Sender.UserName)
149+
senderLink := SlackLinkFormatter(setting.AppURL+p.Sender.UserName, p.Sender.UserName)
150150
titleLink := SlackLinkFormatter(fmt.Sprintf("%s/issues/%d", p.Repository.HTMLURL, p.Index),
151151
fmt.Sprintf("#%d %s", p.Index, p.Issue.Title))
152152
var text, title, attachmentText string
@@ -164,7 +164,7 @@ func getSlackIssuesPayload(p *api.IssuesPayload, slack *SlackMeta) (*SlackPayloa
164164
attachmentText = SlackTextFormatter(p.Issue.Body)
165165
case api.HOOK_ISSUE_ASSIGNED:
166166
text = fmt.Sprintf("[%s] Issue assigned to %s: %s by %s", p.Repository.FullName,
167-
SlackLinkFormatter(setting.AppUrl+p.Issue.Assignee.UserName, p.Issue.Assignee.UserName),
167+
SlackLinkFormatter(setting.AppURL+p.Issue.Assignee.UserName, p.Issue.Assignee.UserName),
168168
titleLink, senderLink)
169169
case api.HOOK_ISSUE_UNASSIGNED:
170170
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
192192
}
193193

194194
func getSlackIssueCommentPayload(p *api.IssueCommentPayload, slack *SlackMeta) (*SlackPayload, error) {
195-
senderLink := SlackLinkFormatter(setting.AppUrl+p.Sender.UserName, p.Sender.UserName)
195+
senderLink := SlackLinkFormatter(setting.AppURL+p.Sender.UserName, p.Sender.UserName)
196196
titleLink := SlackLinkFormatter(fmt.Sprintf("%s/issues/%d#%s", p.Repository.HTMLURL, p.Issue.Index, CommentHashTag(p.Comment.ID)),
197197
fmt.Sprintf("#%d %s", p.Issue.Index, p.Issue.Title))
198198
var text, title, attachmentText string
@@ -226,7 +226,7 @@ func getSlackIssueCommentPayload(p *api.IssueCommentPayload, slack *SlackMeta) (
226226
}
227227

228228
func getSlackPullRequestPayload(p *api.PullRequestPayload, slack *SlackMeta) (*SlackPayload, error) {
229-
senderLink := SlackLinkFormatter(setting.AppUrl+p.Sender.UserName, p.Sender.UserName)
229+
senderLink := SlackLinkFormatter(setting.AppURL+p.Sender.UserName, p.Sender.UserName)
230230
titleLink := SlackLinkFormatter(fmt.Sprintf("%s/pulls/%d", p.Repository.HTMLURL, p.Index),
231231
fmt.Sprintf("#%d %s", p.Index, p.PullRequest.Title))
232232
var text, title, attachmentText string
@@ -248,7 +248,7 @@ func getSlackPullRequestPayload(p *api.PullRequestPayload, slack *SlackMeta) (*S
248248
attachmentText = SlackTextFormatter(p.PullRequest.Body)
249249
case api.HOOK_ISSUE_ASSIGNED:
250250
text = fmt.Sprintf("[%s] Pull request assigned to %s: %s by %s", p.Repository.FullName,
251-
SlackLinkFormatter(setting.AppUrl+p.PullRequest.Assignee.UserName, p.PullRequest.Assignee.UserName),
251+
SlackLinkFormatter(setting.AppURL+p.PullRequest.Assignee.UserName, p.PullRequest.Assignee.UserName),
252252
titleLink, senderLink)
253253
case api.HOOK_ISSUE_UNASSIGNED:
254254
text = fmt.Sprintf("[%s] Pull request unassigned: %s by %s", p.Repository.FullName, titleLink, senderLink)

pkg/context/api.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ func (ctx *APIContext) SetLinkHeader(total, pageSize int) {
4848
page := paginater.New(total, pageSize, ctx.QueryInt("page"), 0)
4949
links := make([]string, 0, 4)
5050
if page.HasNext() {
51-
links = append(links, fmt.Sprintf("<%s%s?page=%d>; rel=\"next\"", setting.AppUrl, ctx.Req.URL.Path[1:], page.Next()))
51+
links = append(links, fmt.Sprintf("<%s%s?page=%d>; rel=\"next\"", setting.AppURL, ctx.Req.URL.Path[1:], page.Next()))
5252
}
5353
if !page.IsLast() {
54-
links = append(links, fmt.Sprintf("<%s%s?page=%d>; rel=\"last\"", setting.AppUrl, ctx.Req.URL.Path[1:], page.TotalPages()))
54+
links = append(links, fmt.Sprintf("<%s%s?page=%d>; rel=\"last\"", setting.AppURL, ctx.Req.URL.Path[1:], page.TotalPages()))
5555
}
5656
if !page.IsFirst() {
57-
links = append(links, fmt.Sprintf("<%s%s?page=1>; rel=\"first\"", setting.AppUrl, ctx.Req.URL.Path[1:]))
57+
links = append(links, fmt.Sprintf("<%s%s?page=1>; rel=\"first\"", setting.AppURL, ctx.Req.URL.Path[1:]))
5858
}
5959
if page.HasPrevious() {
60-
links = append(links, fmt.Sprintf("<%s%s?page=%d>; rel=\"prev\"", setting.AppUrl, ctx.Req.URL.Path[1:], page.Previous()))
60+
links = append(links, fmt.Sprintf("<%s%s?page=%d>; rel=\"prev\"", setting.AppURL, ctx.Req.URL.Path[1:], page.Previous()))
6161
}
6262

6363
if len(links) > 0 {

pkg/context/auth.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func Toggle(options *ToggleOptions) macaron.Handler {
2525
return func(ctx *Context) {
2626
// Cannot view any page before installation.
2727
if !setting.InstallLock {
28-
ctx.Redirect(setting.AppSubUrl + "/install")
28+
ctx.Redirect(setting.AppSubURL + "/install")
2929
return
3030
}
3131

@@ -38,13 +38,13 @@ func Toggle(options *ToggleOptions) macaron.Handler {
3838

3939
// Check non-logged users landing page.
4040
if !ctx.IsSigned && ctx.Req.RequestURI == "/" && setting.LandingPageURL != setting.LANDING_PAGE_HOME {
41-
ctx.Redirect(setting.AppSubUrl + string(setting.LandingPageURL))
41+
ctx.Redirect(setting.AppSubURL + string(setting.LandingPageURL))
4242
return
4343
}
4444

4545
// Redirect to dashboard if user tries to visit any non-login page.
4646
if options.SignOutRequired && ctx.IsSigned && ctx.Req.RequestURI != "/" {
47-
ctx.Redirect(setting.AppSubUrl + "/")
47+
ctx.Redirect(setting.AppSubURL + "/")
4848
return
4949
}
5050

@@ -65,8 +65,8 @@ func Toggle(options *ToggleOptions) macaron.Handler {
6565
return
6666
}
6767

68-
ctx.SetCookie("redirect_to", url.QueryEscape(setting.AppSubUrl+ctx.Req.RequestURI), 0, setting.AppSubUrl)
69-
ctx.Redirect(setting.AppSubUrl + "/user/login")
68+
ctx.SetCookie("redirect_to", url.QueryEscape(setting.AppSubURL+ctx.Req.RequestURI), 0, setting.AppSubURL)
69+
ctx.Redirect(setting.AppSubURL + "/user/login")
7070
return
7171
} else if !ctx.User.IsActive && setting.Service.RegisterEmailConfirm {
7272
ctx.Data["Title"] = ctx.Tr("auth.active_your_account")
@@ -78,8 +78,8 @@ func Toggle(options *ToggleOptions) macaron.Handler {
7878
// Redirect to log in page if auto-signin info is provided and has not signed in.
7979
if !options.SignOutRequired && !ctx.IsSigned && !auth.IsAPIPath(ctx.Req.URL.Path) &&
8080
len(ctx.GetCookie(setting.CookieUserName)) > 0 {
81-
ctx.SetCookie("redirect_to", url.QueryEscape(setting.AppSubUrl+ctx.Req.RequestURI), 0, setting.AppSubUrl)
82-
ctx.Redirect(setting.AppSubUrl + "/user/login")
81+
ctx.SetCookie("redirect_to", url.QueryEscape(setting.AppSubURL+ctx.Req.RequestURI), 0, setting.AppSubURL)
82+
ctx.Redirect(setting.AppSubURL + "/user/login")
8383
return
8484
}
8585

pkg/context/context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ func Contexter() macaron.Handler {
185185
}
186186

187187
// Compute current URL for real-time change language.
188-
ctx.Data["Link"] = setting.AppSubUrl + strings.TrimSuffix(ctx.Req.URL.Path, "/")
188+
ctx.Data["Link"] = setting.AppSubURL + strings.TrimSuffix(ctx.Req.URL.Path, "/")
189189

190190
ctx.Data["PageStartTime"] = time.Now()
191191

0 commit comments

Comments
 (0)