Skip to content

Commit c221767

Browse files
lunnywxiaoguang
andauthored
Move admin routers from /admin to /-/admin (#32189)
Resolve #32181 --------- Co-authored-by: wxiaoguang <[email protected]>
1 parent dd83cfc commit c221767

Some content is hidden

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

42 files changed

+103
-105
lines changed

models/user/user.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,6 @@ var (
565565
".",
566566
"..",
567567
".well-known",
568-
"admin",
569568
"api",
570569
"assets",
571570
"attachments",

routers/api/v1/admin/hooks.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func ListHooks(ctx *context.APIContext) {
4545
}
4646
hooks := make([]*api.Hook, len(sysHooks))
4747
for i, hook := range sysHooks {
48-
h, err := webhook_service.ToHook(setting.AppURL+"/admin", hook)
48+
h, err := webhook_service.ToHook(setting.AppURL+"/-/admin", hook)
4949
if err != nil {
5050
ctx.Error(http.StatusInternalServerError, "convert.ToHook", err)
5151
return
@@ -83,7 +83,7 @@ func GetHook(ctx *context.APIContext) {
8383
}
8484
return
8585
}
86-
h, err := webhook_service.ToHook("/admin/", hook)
86+
h, err := webhook_service.ToHook("/-/admin/", hook)
8787
if err != nil {
8888
ctx.Error(http.StatusInternalServerError, "convert.ToHook", err)
8989
return

routers/api/v1/utils/hook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func checkCreateHookOption(ctx *context.APIContext, form *api.CreateHookOption)
100100
func AddSystemHook(ctx *context.APIContext, form *api.CreateHookOption) {
101101
hook, ok := addHook(ctx, form, 0, 0)
102102
if ok {
103-
h, err := webhook_service.ToHook(setting.AppSubURL+"/admin", hook)
103+
h, err := webhook_service.ToHook(setting.AppSubURL+"/-/admin", hook)
104104
if err != nil {
105105
ctx.Error(http.StatusInternalServerError, "convert.ToHook", err)
106106
return
@@ -268,7 +268,7 @@ func EditSystemHook(ctx *context.APIContext, form *api.EditHookOption, hookID in
268268
ctx.Error(http.StatusInternalServerError, "GetSystemOrDefaultWebhook", err)
269269
return
270270
}
271-
h, err := webhook_service.ToHook(setting.AppURL+"/admin", updated)
271+
h, err := webhook_service.ToHook(setting.AppURL+"/-/admin", updated)
272272
if err != nil {
273273
ctx.Error(http.StatusInternalServerError, "convert.ToHook", err)
274274
return

routers/web/admin/admin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ func DashboardPost(ctx *context.Context) {
185185
}
186186
}
187187
if form.From == "monitor" {
188-
ctx.Redirect(setting.AppSubURL + "/admin/monitor/cron")
188+
ctx.Redirect(setting.AppSubURL + "/-/admin/monitor/cron")
189189
} else {
190-
ctx.Redirect(setting.AppSubURL + "/admin")
190+
ctx.Redirect(setting.AppSubURL + "/-/admin")
191191
}
192192
}
193193

routers/web/admin/applications.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ var (
2323
func newOAuth2CommonHandlers() *user_setting.OAuth2CommonHandlers {
2424
return &user_setting.OAuth2CommonHandlers{
2525
OwnerID: 0,
26-
BasePathList: fmt.Sprintf("%s/admin/applications", setting.AppSubURL),
27-
BasePathEditPrefix: fmt.Sprintf("%s/admin/applications/oauth2", setting.AppSubURL),
26+
BasePathList: fmt.Sprintf("%s/-/admin/applications", setting.AppSubURL),
27+
BasePathEditPrefix: fmt.Sprintf("%s/-/admin/applications/oauth2", setting.AppSubURL),
2828
TplAppEdit: tplSettingsOauth2ApplicationEdit,
2929
}
3030
}

routers/web/admin/auths.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ func NewAuthSourcePost(ctx *context.Context) {
324324
log.Trace("Authentication created by admin(%s): %s", ctx.Doer.Name, form.Name)
325325

326326
ctx.Flash.Success(ctx.Tr("admin.auths.new_success", form.Name))
327-
ctx.Redirect(setting.AppSubURL + "/admin/auths")
327+
ctx.Redirect(setting.AppSubURL + "/-/admin/auths")
328328
}
329329

330330
// EditAuthSource render editing auth source page
@@ -437,7 +437,7 @@ func EditAuthSourcePost(ctx *context.Context) {
437437
log.Trace("Authentication changed by admin(%s): %d", ctx.Doer.Name, source.ID)
438438

439439
ctx.Flash.Success(ctx.Tr("admin.auths.update_success"))
440-
ctx.Redirect(setting.AppSubURL + "/admin/auths/" + strconv.FormatInt(form.ID, 10))
440+
ctx.Redirect(setting.AppSubURL + "/-/admin/auths/" + strconv.FormatInt(form.ID, 10))
441441
}
442442

443443
// DeleteAuthSource response for deleting an auth source
@@ -454,11 +454,11 @@ func DeleteAuthSource(ctx *context.Context) {
454454
} else {
455455
ctx.Flash.Error(fmt.Sprintf("auth_service.DeleteSource: %v", err))
456456
}
457-
ctx.JSONRedirect(setting.AppSubURL + "/admin/auths/" + url.PathEscape(ctx.PathParam(":authid")))
457+
ctx.JSONRedirect(setting.AppSubURL + "/-/admin/auths/" + url.PathEscape(ctx.PathParam(":authid")))
458458
return
459459
}
460460
log.Trace("Authentication deleted by admin(%s): %d", ctx.Doer.Name, source.ID)
461461

462462
ctx.Flash.Success(ctx.Tr("admin.auths.deletion_success"))
463-
ctx.JSONRedirect(setting.AppSubURL + "/admin/auths")
463+
ctx.JSONRedirect(setting.AppSubURL + "/-/admin/auths")
464464
}

routers/web/admin/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func SendTestMail(ctx *context.Context) {
4040
ctx.Flash.Info(ctx.Tr("admin.config.test_mail_sent", email))
4141
}
4242

43-
ctx.Redirect(setting.AppSubURL + "/admin/config")
43+
ctx.Redirect(setting.AppSubURL + "/-/admin/config")
4444
}
4545

4646
// TestCache test the cache settings
@@ -56,7 +56,7 @@ func TestCache(ctx *context.Context) {
5656
}
5757
}
5858

59-
ctx.Redirect(setting.AppSubURL + "/admin/config")
59+
ctx.Redirect(setting.AppSubURL + "/-/admin/config")
6060
}
6161

6262
func shadowPasswordKV(cfgItem, splitter string) string {

routers/web/admin/emails.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func ActivateEmail(ctx *context.Context) {
134134
ctx.Flash.Info(ctx.Tr("admin.emails.updated"))
135135
}
136136

137-
redirect, _ := url.Parse(setting.AppSubURL + "/admin/emails")
137+
redirect, _ := url.Parse(setting.AppSubURL + "/-/admin/emails")
138138
q := url.Values{}
139139
if val := ctx.FormTrim("q"); len(val) > 0 {
140140
q.Set("q", val)

routers/web/admin/hooks.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ func DefaultOrSystemWebhooks(ctx *context.Context) {
3636
sys["Title"] = ctx.Tr("admin.systemhooks")
3737
sys["Description"] = ctx.Tr("admin.systemhooks.desc", "https://docs.gitea.com/usage/webhooks")
3838
sys["Webhooks"], err = webhook.GetSystemWebhooks(ctx, optional.None[bool]())
39-
sys["BaseLink"] = setting.AppSubURL + "/admin/hooks"
40-
sys["BaseLinkNew"] = setting.AppSubURL + "/admin/system-hooks"
39+
sys["BaseLink"] = setting.AppSubURL + "/-/admin/hooks"
40+
sys["BaseLinkNew"] = setting.AppSubURL + "/-/admin/system-hooks"
4141
if err != nil {
4242
ctx.ServerError("GetWebhooksAdmin", err)
4343
return
@@ -46,8 +46,8 @@ func DefaultOrSystemWebhooks(ctx *context.Context) {
4646
def["Title"] = ctx.Tr("admin.defaulthooks")
4747
def["Description"] = ctx.Tr("admin.defaulthooks.desc", "https://docs.gitea.com/usage/webhooks")
4848
def["Webhooks"], err = webhook.GetDefaultWebhooks(ctx)
49-
def["BaseLink"] = setting.AppSubURL + "/admin/hooks"
50-
def["BaseLinkNew"] = setting.AppSubURL + "/admin/default-hooks"
49+
def["BaseLink"] = setting.AppSubURL + "/-/admin/hooks"
50+
def["BaseLinkNew"] = setting.AppSubURL + "/-/admin/default-hooks"
5151
if err != nil {
5252
ctx.ServerError("GetWebhooksAdmin", err)
5353
return
@@ -67,5 +67,5 @@ func DeleteDefaultOrSystemWebhook(ctx *context.Context) {
6767
ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success"))
6868
}
6969

70-
ctx.JSONRedirect(setting.AppSubURL + "/admin/hooks")
70+
ctx.JSONRedirect(setting.AppSubURL + "/-/admin/hooks")
7171
}

routers/web/admin/notice.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,5 @@ func EmptyNotices(ctx *context.Context) {
7474

7575
log.Trace("System notices deleted by admin (%s): [start: %d]", ctx.Doer.Name, 0)
7676
ctx.Flash.Success(ctx.Tr("admin.notices.delete_success"))
77-
ctx.Redirect(setting.AppSubURL + "/admin/notices")
77+
ctx.Redirect(setting.AppSubURL + "/-/admin/notices")
7878
}

0 commit comments

Comments
 (0)