diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-05-08 17:36:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-08 17:36:54 +0800 |
commit | cb700aedd1e670fb47b8cf0cd67fb117a1ad88a2 (patch) | |
tree | 90cdc8e732b1c498bf5113accad8dc4245a059ac /routers | |
parent | ff5629268c5c01d3f460570baa571baef3f896cd (diff) | |
download | gitea-cb700aedd1e670fb47b8cf0cd67fb117a1ad88a2.tar.gz gitea-cb700aedd1e670fb47b8cf0cd67fb117a1ad88a2.zip |
Split "modules/context.go" to separate files (#24569)
The "modules/context.go" is too large to maintain.
This PR splits it to separate files, eg: context_request.go,
context_response.go, context_serve.go
This PR will help:
1. The future refactoring for Gitea's web context (eg: simplify the context)
2. Introduce proper "range request" support
3. Introduce context function
This PR only moves code, doesn't change any logic.
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/repo/repo.go | 2 | ||||
-rw-r--r-- | routers/web/admin/users.go | 4 | ||||
-rw-r--r-- | routers/web/auth/auth.go | 2 | ||||
-rw-r--r-- | routers/web/auth/password.go | 4 | ||||
-rw-r--r-- | routers/web/repo/repo.go | 2 | ||||
-rw-r--r-- | routers/web/repo/view.go | 2 | ||||
-rw-r--r-- | routers/web/user/setting/account.go | 2 |
7 files changed, 9 insertions, 9 deletions
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 36cc03f893..480ca397d4 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -178,7 +178,7 @@ func Search(ctx *context.APIContext) { if len(sortOrder) == 0 { sortOrder = "asc" } - if searchModeMap, ok := context.SearchOrderByMap[sortOrder]; ok { + if searchModeMap, ok := repo_model.SearchOrderByMap[sortOrder]; ok { if orderBy, ok := searchModeMap[sortMode]; ok { opts.OrderBy = orderBy } else { diff --git a/routers/web/admin/users.go b/routers/web/admin/users.go index bd31d9d632..3895bcfdb9 100644 --- a/routers/web/admin/users.go +++ b/routers/web/admin/users.go @@ -148,7 +148,7 @@ func NewUserPost(ctx *context.Context) { } if !password.IsComplexEnough(form.Password) { ctx.Data["Err_Password"] = true - ctx.RenderWithErr(password.BuildComplexityError(ctx), tplUserNew, &form) + ctx.RenderWithErr(password.BuildComplexityError(ctx.Locale), tplUserNew, &form) return } pwned, err := password.IsPwned(ctx, form.Password) @@ -301,7 +301,7 @@ func EditUserPost(ctx *context.Context) { return } if !password.IsComplexEnough(form.Password) { - ctx.RenderWithErr(password.BuildComplexityError(ctx), tplUserEdit, &form) + ctx.RenderWithErr(password.BuildComplexityError(ctx.Locale), tplUserEdit, &form) return } pwned, err := password.IsPwned(ctx, form.Password) diff --git a/routers/web/auth/auth.go b/routers/web/auth/auth.go index d8042afecc..e0883a2696 100644 --- a/routers/web/auth/auth.go +++ b/routers/web/auth/auth.go @@ -444,7 +444,7 @@ func SignUpPost(ctx *context.Context) { } if !password.IsComplexEnough(form.Password) { ctx.Data["Err_Password"] = true - ctx.RenderWithErr(password.BuildComplexityError(ctx), tplSignUp, &form) + ctx.RenderWithErr(password.BuildComplexityError(ctx.Locale), tplSignUp, &form) return } pwned, err := password.IsPwned(ctx, form.Password) diff --git a/routers/web/auth/password.go b/routers/web/auth/password.go index ed0412d745..b34a1d8fce 100644 --- a/routers/web/auth/password.go +++ b/routers/web/auth/password.go @@ -176,7 +176,7 @@ func ResetPasswdPost(ctx *context.Context) { } else if !password.IsComplexEnough(passwd) { ctx.Data["IsResetForm"] = true ctx.Data["Err_Password"] = true - ctx.RenderWithErr(password.BuildComplexityError(ctx), tplResetPassword, nil) + ctx.RenderWithErr(password.BuildComplexityError(ctx.Locale), tplResetPassword, nil) return } else if pwned, err := password.IsPwned(ctx, passwd); pwned || err != nil { errMsg := ctx.Tr("auth.password_pwned") @@ -305,7 +305,7 @@ func MustChangePasswordPost(ctx *context.Context) { if !password.IsComplexEnough(form.Password) { ctx.Data["Err_Password"] = true - ctx.RenderWithErr(password.BuildComplexityError(ctx), tplMustChangePassword, &form) + ctx.RenderWithErr(password.BuildComplexityError(ctx.Locale), tplMustChangePassword, &form) return } pwned, err := password.IsPwned(ctx, form.Password) diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go index c4b5351eca..2f87e19022 100644 --- a/routers/web/repo/repo.go +++ b/routers/web/repo/repo.go @@ -546,7 +546,7 @@ func SearchRepo(ctx *context.Context) { if len(sortOrder) == 0 { sortOrder = "asc" } - if searchModeMap, ok := context.SearchOrderByMap[sortOrder]; ok { + if searchModeMap, ok := repo_model.SearchOrderByMap[sortOrder]; ok { if orderBy, ok := searchModeMap[sortMode]; ok { opts.OrderBy = orderBy } else { diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index 9f2770a3ac..2bf293cbda 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -66,7 +66,7 @@ func findReadmeFileInEntries(ctx *context.Context, entries []*git.TreeEntry, try // 1. Markdown files - with and without localisation - e.g. README.en-us.md or README.md // 2. Txt files - e.g. README.txt // 3. No extension - e.g. README - exts := append(localizedExtensions(".md", ctx.Language()), ".txt", "") // sorted by priority + exts := append(localizedExtensions(".md", ctx.Locale.Language()), ".txt", "") // sorted by priority extCount := len(exts) readmeFiles := make([]*git.TreeEntry, extCount+1) diff --git a/routers/web/user/setting/account.go b/routers/web/user/setting/account.go index 0e48013b04..a67c2398fb 100644 --- a/routers/web/user/setting/account.go +++ b/routers/web/user/setting/account.go @@ -60,7 +60,7 @@ func AccountPost(ctx *context.Context) { } else if form.Password != form.Retype { ctx.Flash.Error(ctx.Tr("form.password_not_match")) } else if !password.IsComplexEnough(form.Password) { - ctx.Flash.Error(password.BuildComplexityError(ctx)) + ctx.Flash.Error(password.BuildComplexityError(ctx.Locale)) } else if pwned, err := password.IsPwned(ctx, form.Password); pwned || err != nil { errMsg := ctx.Tr("auth.password_pwned") if err != nil { |