1
1
ミラー元 https://github.com/go-gitea/gitea 前回の同期 2025-09-17 14:18:15 +00:00

Refactor AddParam to AddParamIfExist (#29834)

When read the code: `pager.AddParam(ctx, "search", "search")`, the
question always comes: What is it doing? Where is the value from? Why
"search" / "search" ?

Now it is clear: `pager.AddParamIfExist("search", ctx.Data["search"])`
このコミットが含まれているのは:
wxiaoguang
2024-03-16 17:20:13 +08:00
committed by GitHub
コミット e0ea3811c4
17個のファイルの変更53行の追加54行の削除

ファイルの表示

@@ -163,8 +163,8 @@ func Graph(ctx *context.Context) {
ctx.Data["CommitCount"] = commitsCount
paginator := context.NewPagination(int(graphCommitsCount), setting.UI.GraphMaxCommitNum, page, 5)
paginator.AddParam(ctx, "mode", "Mode")
paginator.AddParam(ctx, "hide-pr-refs", "HidePRRefs")
paginator.AddParamIfExist("mode", ctx.Data["Mode"])
paginator.AddParamIfExist("hide-pr-refs", ctx.Data["HidePRRefs"])
for _, branch := range branches {
paginator.AddParamString("branch", branch)
}

ファイルの表示

@@ -472,16 +472,16 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption opt
}
ctx.Data["ShowArchivedLabels"] = archived
pager.AddParam(ctx, "q", "Keyword")
pager.AddParam(ctx, "type", "ViewType")
pager.AddParam(ctx, "sort", "SortType")
pager.AddParam(ctx, "state", "State")
pager.AddParam(ctx, "labels", "SelectLabels")
pager.AddParam(ctx, "milestone", "MilestoneID")
pager.AddParam(ctx, "project", "ProjectID")
pager.AddParam(ctx, "assignee", "AssigneeID")
pager.AddParam(ctx, "poster", "PosterID")
pager.AddParam(ctx, "archived", "ShowArchivedLabels")
pager.AddParamIfExist("q", ctx.Data["Keyword"])
pager.AddParamIfExist("type", ctx.Data["ViewType"])
pager.AddParamIfExist("sort", ctx.Data["SortType"])
pager.AddParamIfExist("state", ctx.Data["State"])
pager.AddParamIfExist("labels", ctx.Data["SelectLabels"])
pager.AddParamIfExist("milestone", ctx.Data["MilestoneID"])
pager.AddParamIfExist("project", ctx.Data["ProjectID"])
pager.AddParamIfExist("assignee", ctx.Data["AssigneeID"])
pager.AddParamIfExist("poster", ctx.Data["PosterID"])
pager.AddParamIfExist("archived", ctx.Data["ShowArchivedLabels"])
ctx.Data["Page"] = pager
}

ファイルの表示

@@ -106,8 +106,8 @@ func Milestones(ctx *context.Context) {
ctx.Data["IsShowClosed"] = isShowClosed
pager := context.NewPagination(int(total), setting.UI.IssuePagingNum, page, 5)
pager.AddParam(ctx, "state", "State")
pager.AddParam(ctx, "q", "Keyword")
pager.AddParamIfExist("state", ctx.Data["State"])
pager.AddParamIfExist("q", ctx.Data["Keyword"])
ctx.Data["Page"] = pager
ctx.HTML(http.StatusOK, tplMilestone)

ファイルの表示

@@ -70,8 +70,8 @@ func Packages(ctx *context.Context) {
ctx.Data["RepositoryAccessMap"] = map[int64]bool{ctx.Repo.Repository.ID: true} // There is only the current repository
pager := context.NewPagination(int(total), setting.UI.PackagesPagingNum, page, 5)
pager.AddParam(ctx, "q", "Query")
pager.AddParam(ctx, "type", "PackageType")
pager.AddParamIfExist("q", ctx.Data["Query"])
pager.AddParamIfExist("type", ctx.Data["PackageType"])
ctx.Data["Page"] = pager
ctx.HTML(http.StatusOK, tplPackagesList)

ファイルの表示

@@ -118,7 +118,7 @@ func Projects(ctx *context.Context) {
}
pager := context.NewPagination(total, setting.UI.IssuePagingNum, page, numPages)
pager.AddParam(ctx, "state", "State")
pager.AddParamIfExist("state", ctx.Data["State"])
ctx.Data["Page"] = pager
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)

ファイルの表示

@@ -59,7 +59,7 @@ func Search(ctx *context.Context) {
pager := context.NewPagination(total, setting.UI.RepoSearchPagingNum, page, 5)
pager.SetDefaultParams(ctx)
pager.AddParam(ctx, "l", "Language")
pager.AddParamIfExist("l", ctx.Data["Language"])
ctx.Data["Page"] = pager
ctx.HTML(http.StatusOK, tplSearch)