From c758c5612e91e6f8367c5c7751ab122f9266317d Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 20 Mar 2024 13:56:42 +0800 Subject: [PATCH] Remove unnecessary ".Link" usages (#29909) In HTML, `?key=val` already means "use the current link with new query parameters" (cherry picked from commit 4c476fa41dc29dc24afda0925023ae3d0b9707cd) Conflicts: templates/repo/issue/filter_list.tmpl templates/shared/issuelist.tmpl trivial context conflict because the lines in Forgejo have rel=nofollow --- templates/admin/emails/list.tmpl | 8 +-- templates/admin/org/list.tmpl | 12 ++-- templates/explore/repo_list.tmpl | 2 +- templates/explore/search.tmpl | 8 +-- templates/projects/list.tmpl | 10 ++-- templates/repo/actions/list.tmpl | 12 ++-- templates/repo/diff/box.tmpl | 6 +- templates/repo/issue/filter_list.tmpl | 58 +++++++++---------- templates/repo/issue/labels/label_list.tmpl | 8 +-- .../repo/issue/milestone/filter_list.tmpl | 12 ++-- templates/repo/view_file.tmpl | 2 +- templates/shared/issuelist.tmpl | 2 +- templates/shared/search/code/results.tmpl | 2 +- templates/user/dashboard/issues.tmpl | 16 ++--- templates/user/dashboard/milestones.tmpl | 14 ++--- .../notification_subscriptions.tmpl | 28 ++++----- templates/user/settings/keys_gpg.tmpl | 2 +- templates/user/settings/keys_ssh.tmpl | 2 +- tests/integration/explore_user_test.go | 12 ++-- 19 files changed, 108 insertions(+), 108 deletions(-) diff --git a/templates/admin/emails/list.tmpl b/templates/admin/emails/list.tmpl index 1e552fba8..660df5599 100644 --- a/templates/admin/emails/list.tmpl +++ b/templates/admin/emails/list.tmpl @@ -15,10 +15,10 @@ {{svg "octicon-triangle-down" 14 "dropdown icon"}} diff --git a/templates/admin/org/list.tmpl b/templates/admin/org/list.tmpl index efb0a8847..4609d1b8b 100644 --- a/templates/admin/org/list.tmpl +++ b/templates/admin/org/list.tmpl @@ -18,12 +18,12 @@ {{svg "octicon-triangle-down" 14 "dropdown icon"}} diff --git a/templates/explore/repo_list.tmpl b/templates/explore/repo_list.tmpl index 2bda50671..505387988 100644 --- a/templates/explore/repo_list.tmpl +++ b/templates/explore/repo_list.tmpl @@ -32,7 +32,7 @@
{{if .PrimaryLanguage}} - + {{.PrimaryLanguage.Language}} {{end}} diff --git a/templates/explore/search.tmpl b/templates/explore/search.tmpl index 54d995989..c1d114125 100644 --- a/templates/explore/search.tmpl +++ b/templates/explore/search.tmpl @@ -13,10 +13,10 @@ {{svg "octicon-triangle-down" 14 "dropdown icon"}}
diff --git a/templates/projects/list.tmpl b/templates/projects/list.tmpl index 414c9dca2..d87e7e066 100644 --- a/templates/projects/list.tmpl +++ b/templates/projects/list.tmpl @@ -1,11 +1,11 @@ {{if and $.CanWriteProjects (not $.Repository.IsArchived)}}
diff --git a/templates/repo/actions/list.tmpl b/templates/repo/actions/list.tmpl index 62d30305b..55c049456 100644 --- a/templates/repo/actions/list.tmpl +++ b/templates/repo/actions/list.tmpl @@ -8,9 +8,9 @@
- + {{ctx.Locale.Tr "actions.runs.status_no_select"}} {{range .StatusInfoList}} - + {{.DisplayedStatus}} {{end}} diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl index 886004ea6..3daac1c2c 100644 --- a/templates/repo/diff/box.tmpl +++ b/templates/repo/diff/box.tmpl @@ -68,7 +68,7 @@ binaryFileMessage: "{{ctx.Locale.Tr "repo.diff.bin"}}", showMoreMessage: "{{ctx.Locale.Tr "repo.diff.show_more"}}", statisticsMessage: "{{ctx.Locale.Tr "repo.diff.stats_desc_file"}}", - linkLoadMore: "{{$.Link}}?skip-to={{.Diff.End}}&file-only=true", + linkLoadMore: "?skip-to={{.Diff.End}}&file-only=true", }; // for first time loading, the diffFileInfo is a plain object @@ -187,7 +187,7 @@ {{ctx.Locale.Tr "repo.diff.file_suppressed_line_too_long"}} {{else}} {{ctx.Locale.Tr "repo.diff.file_suppressed"}} - {{ctx.Locale.Tr "repo.diff.load"}} + {{ctx.Locale.Tr "repo.diff.load"}} {{end}} {{else}} {{ctx.Locale.Tr "repo.diff.bin_not_shown"}} @@ -223,7 +223,7 @@

{{ctx.Locale.Tr "repo.diff.too_many_files"}} - {{ctx.Locale.Tr "repo.diff.show_more"}} + {{ctx.Locale.Tr "repo.diff.show_more"}}

{{end}} diff --git a/templates/repo/issue/filter_list.tmpl b/templates/repo/issue/filter_list.tmpl index c95ce6b2b..0349737c0 100644 --- a/templates/repo/issue/filter_list.tmpl +++ b/templates/repo/issue/filter_list.tmpl @@ -23,8 +23,8 @@
{{ctx.Locale.Tr "repo.issues.filter_label_exclude"}}
- {{ctx.Locale.Tr "repo.issues.filter_label_no_select"}} - {{ctx.Locale.Tr "repo.issues.filter_label_select_no_label"}} + {{ctx.Locale.Tr "repo.issues.filter_label_no_select"}} + {{ctx.Locale.Tr "repo.issues.filter_label_select_no_label"}} {{$previousExclusiveScope := "_no_scope"}} {{range .Labels}} {{$exclusiveScope := .ExclusiveScope}} @@ -32,7 +32,7 @@
{{end}} {{$previousExclusiveScope = $exclusiveScope}} - + {{if .IsExcluded}} {{svg "octicon-circle-slash"}} {{else if .IsSelected}} @@ -62,13 +62,13 @@
-
{{ctx.Locale.Tr "repo.issues.filter_milestone_all"}} - {{ctx.Locale.Tr "repo.issues.filter_milestone_none"}} + {{ctx.Locale.Tr "repo.issues.filter_milestone_all"}} + {{ctx.Locale.Tr "repo.issues.filter_milestone_none"}} {{if .OpenMilestones}}
{{ctx.Locale.Tr "repo.issues.filter_milestone_open"}}
{{range .OpenMilestones}} - + {{svg "octicon-milestone" 16 "mr-2"}} {{.Name}} @@ -78,7 +78,7 @@
{{ctx.Locale.Tr "repo.issues.filter_milestone_closed"}}
{{range .ClosedMilestones}} - + {{svg "octicon-milestone" 16 "mr-2"}} {{.Name}} @@ -99,15 +99,15 @@ {{svg "octicon-search" 16}} - {{ctx.Locale.Tr "repo.issues.filter_project_all"}} - {{ctx.Locale.Tr "repo.issues.filter_project_none"}} + {{ctx.Locale.Tr "repo.issues.filter_project_all"}} + {{ctx.Locale.Tr "repo.issues.filter_project_none"}} {{if .OpenProjects}}
{{ctx.Locale.Tr "repo.issues.new.open_projects"}}
{{range .OpenProjects}} - + {{svg .IconName 18 "gt-mr-3 tw-shrink-0"}}{{.Title}} {{end}} @@ -118,7 +118,7 @@ {{ctx.Locale.Tr "repo.issues.new.closed_projects"}} {{range .ClosedProjects}} - + {{svg .IconName 18 "gt-mr-3"}}{{.Title}} {{end}} @@ -130,7 +130,7 @@ - {{ctx.Locale.Tr "repo.issues.filter_assginee_no_select"}} - {{ctx.Locale.Tr "repo.issues.filter_assginee_no_assignee"}} + {{ctx.Locale.Tr "repo.issues.filter_assginee_no_select"}} + {{ctx.Locale.Tr "repo.issues.filter_assginee_no_assignee"}}
{{range .Assignees}} - + {{ctx.AvatarUtils.Avatar . 20}}{{template "repo/search_name" .}} {{end}} @@ -175,14 +175,14 @@ {{svg "octicon-triangle-down" 14 "dropdown icon"}} {{end}} @@ -194,13 +194,13 @@ {{svg "octicon-triangle-down" 14 "dropdown icon"}} diff --git a/templates/repo/issue/labels/label_list.tmpl b/templates/repo/issue/labels/label_list.tmpl index 284c0d3bf..fbfc88588 100644 --- a/templates/repo/issue/labels/label_list.tmpl +++ b/templates/repo/issue/labels/label_list.tmpl @@ -9,10 +9,10 @@ {{svg "octicon-triangle-down" 14 "dropdown icon"}} diff --git a/templates/repo/issue/milestone/filter_list.tmpl b/templates/repo/issue/milestone/filter_list.tmpl index 0eea42d6e..45f9866a1 100644 --- a/templates/repo/issue/milestone/filter_list.tmpl +++ b/templates/repo/issue/milestone/filter_list.tmpl @@ -5,11 +5,11 @@ {{svg "octicon-triangle-down" 14 "dropdown icon"}} diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl index 851e67db6..9d116c7b4 100644 --- a/templates/repo/view_file.tmpl +++ b/templates/repo/view_file.tmpl @@ -37,7 +37,7 @@
{{if .HasSourceRenderedToggle}} {{end}} diff --git a/templates/shared/issuelist.tmpl b/templates/shared/issuelist.tmpl index 2969efa6b..639221abb 100644 --- a/templates/shared/issuelist.tmpl +++ b/templates/shared/issuelist.tmpl @@ -21,7 +21,7 @@ {{end}} {{range .Labels}} - {{RenderLabel $.Context .}} + {{RenderLabel $.Context .}} {{end}}
diff --git a/templates/shared/search/code/results.tmpl b/templates/shared/search/code/results.tmpl index 02d125277..11d7fbbd6 100644 --- a/templates/shared/search/code/results.tmpl +++ b/templates/shared/search/code/results.tmpl @@ -1,7 +1,7 @@
{{range $term := .SearchResultLanguages}} + href="?q={{$.Keyword}}{{if ne $.Language $term.Language}}&l={{$term.Language}}{{end}}&fuzzy={{$.IsFuzzy}}"> {{$term.Language}}
{{$term.Count}}
diff --git a/templates/user/dashboard/issues.tmpl b/templates/user/dashboard/issues.tmpl index 0fbf9a736..c9972f942 100644 --- a/templates/user/dashboard/issues.tmpl +++ b/templates/user/dashboard/issues.tmpl @@ -62,14 +62,14 @@ {{svg "octicon-triangle-down" 14 "dropdown icon"}}
diff --git a/templates/user/dashboard/milestones.tmpl b/templates/user/dashboard/milestones.tmpl index 7b62c9fc2..944043e80 100644 --- a/templates/user/dashboard/milestones.tmpl +++ b/templates/user/dashboard/milestones.tmpl @@ -12,7 +12,7 @@
{{range .Repos}} {{with $Repo := .}} - - {{ctx.Locale.Tr "repo.milestones.filter_sort.earliest_due_data"}} - {{ctx.Locale.Tr "repo.milestones.filter_sort.latest_due_date"}} - {{ctx.Locale.Tr "repo.milestones.filter_sort.least_complete"}} - {{ctx.Locale.Tr "repo.milestones.filter_sort.most_complete"}} - {{ctx.Locale.Tr "repo.milestones.filter_sort.most_issues"}} - {{ctx.Locale.Tr "repo.milestones.filter_sort.least_issues"}} + {{ctx.Locale.Tr "repo.milestones.filter_sort.earliest_due_data"}} + {{ctx.Locale.Tr "repo.milestones.filter_sort.latest_due_date"}} + {{ctx.Locale.Tr "repo.milestones.filter_sort.least_complete"}} + {{ctx.Locale.Tr "repo.milestones.filter_sort.most_complete"}} + {{ctx.Locale.Tr "repo.milestones.filter_sort.most_issues"}} + {{ctx.Locale.Tr "repo.milestones.filter_sort.least_issues"}} diff --git a/templates/user/notification/notification_subscriptions.tmpl b/templates/user/notification/notification_subscriptions.tmpl index a37f0c352..d39e62826 100644 --- a/templates/user/notification/notification_subscriptions.tmpl +++ b/templates/user/notification/notification_subscriptions.tmpl @@ -14,14 +14,14 @@
diff --git a/templates/user/settings/keys_gpg.tmpl b/templates/user/settings/keys_gpg.tmpl index 2e26d6956..b6bae8951 100644 --- a/templates/user/settings/keys_gpg.tmpl +++ b/templates/user/settings/keys_gpg.tmpl @@ -73,7 +73,7 @@ {{ctx.Locale.Tr "settings.delete_key"}} {{if and (not .Verified) (ne $.VerifyingID .KeyID)}} - {{ctx.Locale.Tr "settings.gpg_key_verify"}} + {{ctx.Locale.Tr "settings.gpg_key_verify"}} {{end}} diff --git a/templates/user/settings/keys_ssh.tmpl b/templates/user/settings/keys_ssh.tmpl index 6aa803a41..5c14d81be 100644 --- a/templates/user/settings/keys_ssh.tmpl +++ b/templates/user/settings/keys_ssh.tmpl @@ -61,7 +61,7 @@ {{ctx.Locale.Tr "settings.delete_key"}} {{if and (not .Verified) (ne $.VerifyingFingerprint .Fingerprint)}} - {{ctx.Locale.Tr "settings.ssh_key_verify"}} + {{ctx.Locale.Tr "settings.ssh_key_verify"}} {{end}} diff --git a/tests/integration/explore_user_test.go b/tests/integration/explore_user_test.go index 046caf378..441d89cea 100644 --- a/tests/integration/explore_user_test.go +++ b/tests/integration/explore_user_test.go @@ -16,17 +16,17 @@ func TestExploreUser(t *testing.T) { defer tests.PrepareTestEnv(t)() cases := []struct{ sortOrder, expected string }{ - {"", "/explore/users?sort=newest&q="}, - {"newest", "/explore/users?sort=newest&q="}, - {"oldest", "/explore/users?sort=oldest&q="}, - {"alphabetically", "/explore/users?sort=alphabetically&q="}, - {"reversealphabetically", "/explore/users?sort=reversealphabetically&q="}, + {"", "?sort=newest&q="}, + {"newest", "?sort=newest&q="}, + {"oldest", "?sort=oldest&q="}, + {"alphabetically", "?sort=alphabetically&q="}, + {"reversealphabetically", "?sort=reversealphabetically&q="}, } for _, c := range cases { req := NewRequest(t, "GET", "/explore/users?sort="+c.sortOrder) resp := MakeRequest(t, req, http.StatusOK) h := NewHTMLParser(t, resp.Body) - href, _ := h.Find(`.ui.dropdown .menu a.active.item[href^="/explore/users"]`).Attr("href") + href, _ := h.Find(`.ui.dropdown .menu a.active.item[href^="?sort="]`).Attr("href") assert.Equal(t, c.expected, href) }