Rename ctx.Form() to ctx.FormString() and move code into own file (#16571)

Followup from #16562 prepare for #16567

* Rename ctx.Form() to ctx.FormString()
* Reimplement FormX func to need less code and cpu cycles
* Move code into own file
This commit is contained in:
6543 2021-08-11 02:31:13 +02:00 committed by GitHub
parent 2eeae4edb6
commit c4d70a0325
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
64 changed files with 236 additions and 449 deletions

View file

@ -143,7 +143,7 @@ func Profile(ctx *context.Context) {
ctx.Data["Orgs"] = orgs
ctx.Data["HasOrgsVisible"] = models.HasOrgsVisible(orgs, ctx.User)
tab := ctx.Form("tab")
tab := ctx.FormString("tab")
ctx.Data["TabName"] = tab
page := ctx.FormInt("page")
@ -160,8 +160,8 @@ func Profile(ctx *context.Context) {
orderBy models.SearchOrderBy
)
ctx.Data["SortType"] = ctx.Form("sort")
switch ctx.Form("sort") {
ctx.Data["SortType"] = ctx.FormString("sort")
switch ctx.FormString("sort") {
case "newest":
orderBy = models.SearchOrderByNewest
case "oldest":
@ -187,7 +187,7 @@ func Profile(ctx *context.Context) {
orderBy = models.SearchOrderByRecentUpdated
}
keyword := strings.Trim(ctx.Form("q"), " ")
keyword := strings.Trim(ctx.FormString("q"), " ")
ctx.Data["Keyword"] = keyword
switch tab {
case "followers":
@ -220,7 +220,7 @@ func Profile(ctx *context.Context) {
IncludePrivate: showPrivate,
OnlyPerformedBy: true,
IncludeDeleted: false,
Date: ctx.Form("date"),
Date: ctx.FormString("date"),
})
if ctx.Written() {
return
@ -332,5 +332,5 @@ func Action(ctx *context.Context) {
return
}
ctx.RedirectToFirst(ctx.Form("redirect_to"), u.HomeLink())
ctx.RedirectToFirst(ctx.FormString("redirect_to"), u.HomeLink())
}