loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request 'feat(ui): Add `rel="nofollow"` to in-list labels' (#5002) from xlii/forgejo:forgejo into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5002
Reviewed-by: Gusted <gusted@noreply.codeberg.org>

Gusted e3243a94 0c2ec195

+29 -12
+1 -1
modules/templates/util_render.go
··· 245 245 if isPull { 246 246 issuesOrPull = "pulls" 247 247 } 248 - htmlCode += fmt.Sprintf("<a href='%s/%s?labels=%d'>%s</a> ", 248 + htmlCode += fmt.Sprintf("<a href='%s/%s?labels=%d' rel='nofollow'>%s</a> ", 249 249 repoLink, issuesOrPull, label.ID, RenderLabel(ctx, locale, label)) 250 250 } 251 251 htmlCode += "</span>"
+1
templates/repo/issue/labels/label.tmpl
··· 2 2 class="item {{if not .label.IsChecked}}tw-hidden{{end}}" 3 3 id="label_{{.label.ID}}" 4 4 href="{{.root.RepoLink}}/{{if or .root.IsPull .root.Issue.IsPull}}pulls{{else}}issues{{end}}?labels={{.label.ID}}"{{/* FIXME: use .root.Issue.Link or create .root.Link */}} 5 + rel="nofollow" 5 6 > 6 7 {{- RenderLabel $.Context ctx.Locale .label -}} 7 8 </a>
+1 -1
templates/shared/issuelist.tmpl
··· 21 21 {{end}} 22 22 <span class="labels-list tw-ml-1"> 23 23 {{range .Labels}} 24 - <a href="?q={{$.Keyword}}&type={{$.ViewType}}&state={{$.State}}&labels={{.ID}}{{if ne $.listType "milestone"}}&milestone={{$.MilestoneID}}{{end}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{RenderLabel $.Context ctx.Locale .}}</a> 24 + <a href="?q={{$.Keyword}}&type={{$.ViewType}}&state={{$.State}}&labels={{.ID}}{{if ne $.listType "milestone"}}&milestone={{$.MilestoneID}}{{end}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}" rel="nofollow">{{RenderLabel $.Context ctx.Locale .}}</a> 25 25 {{end}} 26 26 </span> 27 27 </div>
+26 -10
tests/integration/issue_test.go
··· 1166 1166 func TestIssueFilterNoFollow(t *testing.T) { 1167 1167 defer tests.PrepareTestEnv(t)() 1168 1168 1169 - req := NewRequest(t, "GET", "/user2/repo1/issues") 1170 - resp := MakeRequest(t, req, http.StatusOK) 1171 - htmlDoc := NewHTMLParser(t, resp.Body) 1172 - 1173 1169 // Check that every link in the filter list has rel="nofollow". 1174 - filterLinks := htmlDoc.Find(".issue-list-toolbar-right a[href*=\"?q=\"]") 1175 - assert.Positive(t, filterLinks.Length()) 1176 - filterLinks.Each(func(i int, link *goquery.Selection) { 1177 - rel, has := link.Attr("rel") 1178 - assert.True(t, has) 1179 - assert.Equal(t, "nofollow", rel) 1170 + t.Run("Issue lists", func(t *testing.T) { 1171 + req := NewRequest(t, "GET", "/user2/repo1/issues") 1172 + resp := MakeRequest(t, req, http.StatusOK) 1173 + htmlDoc := NewHTMLParser(t, resp.Body) 1174 + 1175 + filterLinks := htmlDoc.Find(".issue-list-toolbar-right a[href*=\"?q=\"], .labels-list a[href*=\"?q=\"]") 1176 + assert.Positive(t, filterLinks.Length()) 1177 + filterLinks.Each(func(i int, link *goquery.Selection) { 1178 + rel, has := link.Attr("rel") 1179 + assert.True(t, has) 1180 + assert.Equal(t, "nofollow", rel) 1181 + }) 1182 + }) 1183 + 1184 + t.Run("Issue page", func(t *testing.T) { 1185 + req := NewRequest(t, "GET", "/user2/repo1/issues/1") 1186 + resp := MakeRequest(t, req, http.StatusOK) 1187 + htmlDoc := NewHTMLParser(t, resp.Body) 1188 + 1189 + filterLinks := htmlDoc.Find(".timeline .labels-list a[href*=\"?labels=\"], .issue-content-right .labels-list a[href*=\"?labels=\"]") 1190 + assert.Positive(t, filterLinks.Length()) 1191 + filterLinks.Each(func(i int, link *goquery.Selection) { 1192 + rel, has := link.Attr("rel") 1193 + assert.True(t, has) 1194 + assert.Equal(t, "nofollow", rel) 1195 + }) 1180 1196 }) 1181 1197 } 1182 1198