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.

Fix linting issues

+14 -12
+12 -10
modules/markup/file_preview.go
··· 9 9 "strings" 10 10 11 11 "code.gitea.io/gitea/modules/charset" 12 + "code.gitea.io/gitea/modules/log" 12 13 "code.gitea.io/gitea/modules/setting" 13 14 "code.gitea.io/gitea/modules/translation" 14 15 "golang.org/x/net/html" 15 16 "golang.org/x/net/html/atom" 16 17 ) 17 18 18 - var ( 19 - // filePreviewPattern matches "http://domain/org/repo/src/commit/COMMIT/filepath#L1-L2" 20 - filePreviewPattern = regexp.MustCompile(`https?://((?:\S+/){3})src/commit/([0-9a-f]{4,64})/(\S+)#(L\d+(?:-L\d+)?)`) 21 - ) 19 + // filePreviewPattern matches "http://domain/org/repo/src/commit/COMMIT/filepath#L1-L2" 20 + var filePreviewPattern = regexp.MustCompile(`https?://((?:\S+/){3})src/commit/([0-9a-f]{4,64})/(\S+)#(L\d+(?:-L\d+)?)`) 22 21 23 22 type FilePreview struct { 24 23 fileContent []template.HTML ··· 82 81 lineCount := len(fileContent) 83 82 84 83 commitLinkBuffer := new(bytes.Buffer) 85 - html.Render(commitLinkBuffer, createLink(node.Data[m[0]:m[5]], commitSha[0:7], "text black")) 84 + err = html.Render(commitLinkBuffer, createLink(node.Data[m[0]:m[5]], commitSha[0:7], "text black")) 85 + if err != nil { 86 + log.Error("failed to render commitLink: %v", err) 87 + } 86 88 87 89 if len(lineSpecs) == 1 { 88 90 line, _ := strconv.Atoi(strings.TrimPrefix(lineSpecs[0], "L")) ··· 117 119 return preview 118 120 } 119 121 120 - func (p *FilePreview) CreateHtml(locale translation.Locale) *html.Node { 122 + func (p *FilePreview) CreateHTML(locale translation.Locale) *html.Node { 121 123 table := &html.Node{ 122 124 Type: html.ElementNode, 123 125 Data: atom.Table.String(), ··· 257 259 }) 258 260 header.AppendChild(psubtitle) 259 261 260 - preview_node := &html.Node{ 262 + node := &html.Node{ 261 263 Type: html.ElementNode, 262 264 Data: atom.Div.String(), 263 265 Attr: []html.Attribute{{Key: "class", Val: "file-preview-box"}}, 264 266 } 265 - preview_node.AppendChild(header) 266 - preview_node.AppendChild(twrapper) 267 + node.AppendChild(header) 268 + node.AppendChild(twrapper) 267 269 268 - return preview_node 270 + return node 269 271 }
+2 -2
modules/markup/html.go
··· 1075 1075 return 1076 1076 } 1077 1077 1078 - preview_node := preview.CreateHtml(locale) 1078 + previewNode := preview.CreateHTML(locale) 1079 1079 1080 1080 // Specialized version of replaceContent, so the parent paragraph element is not destroyed from our div 1081 1081 before := node.Data[:preview.start] ··· 1086 1086 Type: html.RawNode, 1087 1087 Data: "</p>", 1088 1088 }, nextSibling) 1089 - node.Parent.InsertBefore(preview_node, nextSibling) 1089 + node.Parent.InsertBefore(previewNode, nextSibling) 1090 1090 node.Parent.InsertBefore(&html.Node{ 1091 1091 Type: html.RawNode, 1092 1092 Data: "<p>" + after,