From 4c476fa41dc29dc24afda0925023ae3d0b9707cd 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" --- 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 1e552fba88..660df55999 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 efb0a8847e..4609d1b8b4 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 17c8bcb6a3..7de3df5bee 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 54d995989a..c1d114125e 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 414c9dca2e..d87e7e0663 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 62d30305b3..55c0494566 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 39df6faea5..d2ee5db1b8 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 @@ -184,7 +184,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"}} @@ -220,7 +220,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 bb13f63b98..696b7db46b 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 ca8d40f1e0..ca28e3af2d 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 0eea42d6ee..45f9866a16 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 cdd415a47a..8c1e7982eb 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 fb502413fa..adb2f61c54 100644 --- a/templates/shared/issuelist.tmpl +++ b/templates/shared/issuelist.tmpl @@ -21,7 +21,7 @@ {{end}} {{range .Labels}} - {{RenderLabel $.Context ctx.Locale .}} + {{RenderLabel $.Context ctx.Locale .}} {{end}}
diff --git a/templates/shared/search/code/results.tmpl b/templates/shared/search/code/results.tmpl index de5ee0c311..68b183e9bf 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 0fbf9a7361..c9972f9426 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 7b62c9fc27..944043e806 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 a37f0c352e..d39e628263 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 e57658b197..2f90d0bdad 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 94ee2a1a55..5577cd0ffd 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 046caf378e..441d89cea5 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) }