From e71eb8930a5d0f60874b038c223498b41ad65592 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 1 Mar 2024 15:11:51 +0800 Subject: Refactor some Str2html code (#29397) This PR touches the most interesting part of the "template refactoring". 1. Unclear variable type. Especially for "web/feed/convert.go": sometimes it uses text, sometimes it uses HTML. 2. Assign text content to "RenderedContent" field, for example: ` project.RenderedContent = project.Description` in web/org/projects.go 3. Assign rendered content to text field, for example: `r.Note = rendered content` in web/repo/release.go 4. (possible) Incorrectly calling `{{Str2html .PackageDescriptor.Metadata.ReleaseNotes}}` in package/content/nuget.tmpl, I guess the name Str2html misleads developers to use it to "render string to html", but it only sanitizes. if ReleaseNotes really contains HTML, then this is not a problem. --- templates/repo/issue/milestone_issues.tmpl | 2 +- templates/repo/issue/milestones.tmpl | 2 +- templates/repo/issue/view_content.tmpl | 2 +- templates/repo/issue/view_content/attachments.tmpl | 4 ++-- templates/repo/issue/view_content/comments.tmpl | 6 +++--- templates/repo/issue/view_content/conversation.tmpl | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) (limited to 'templates/repo/issue') diff --git a/templates/repo/issue/milestone_issues.tmpl b/templates/repo/issue/milestone_issues.tmpl index d9495d9b77..35a8a77680 100644 --- a/templates/repo/issue/milestone_issues.tmpl +++ b/templates/repo/issue/milestone_issues.tmpl @@ -22,7 +22,7 @@ {{if .Milestone.RenderedContent}}
- {{.Milestone.RenderedContent|Str2html}} + {{.Milestone.RenderedContent}}
{{end}}
diff --git a/templates/repo/issue/milestones.tmpl b/templates/repo/issue/milestones.tmpl index 698e3fffba..363ba7e3a2 100644 --- a/templates/repo/issue/milestones.tmpl +++ b/templates/repo/issue/milestones.tmpl @@ -82,7 +82,7 @@
{{if .Content}}
- {{.RenderedContent|Str2html}} + {{.RenderedContent}}
{{end}} diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index b5441872a3..ee824b76b1 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -54,7 +54,7 @@
{{if .Issue.RenderedContent}} - {{.Issue.RenderedContent|Str2html}} + {{.Issue.RenderedContent}} {{else}} {{ctx.Locale.Tr "repo.issues.no_content"}} {{end}} diff --git a/templates/repo/issue/view_content/attachments.tmpl b/templates/repo/issue/view_content/attachments.tmpl index 1fb6f2f2c2..58f4c702b3 100644 --- a/templates/repo/issue/view_content/attachments.tmpl +++ b/templates/repo/issue/view_content/attachments.tmpl @@ -8,7 +8,7 @@
{{if FilenameIsImage .Name}} - {{if not (StringUtils.Contains $.Content .UUID)}} + {{if not (StringUtils.Contains (StringUtils.ToString $.Content) .UUID)}} {{$hasThumbnails = true}} {{end}} {{svg "octicon-file"}} @@ -29,7 +29,7 @@
{{- range .Attachments -}} {{if FilenameIsImage .Name}} - {{if not (StringUtils.Contains $.Content .UUID)}} + {{if not (StringUtils.Contains (StringUtils.ToString $.Content) .UUID)}} {{.Name}} diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 562e44c791..36ef5751ae 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -61,7 +61,7 @@
{{if .RenderedContent}} - {{.RenderedContent|Str2html}} + {{.RenderedContent}} {{else}} {{ctx.Locale.Tr "repo.issues.no_content"}} {{end}} @@ -432,7 +432,7 @@
{{if .RenderedContent}} - {{.RenderedContent|Str2html}} + {{.RenderedContent}} {{else}} {{ctx.Locale.Tr "repo.issues.no_content"}} {{end}} @@ -631,7 +631,7 @@
{{if .RenderedContent}} - {{.RenderedContent|Str2html}} + {{.RenderedContent}} {{else}} {{ctx.Locale.Tr "repo.issues.no_content"}} {{end}} diff --git a/templates/repo/issue/view_content/conversation.tmpl b/templates/repo/issue/view_content/conversation.tmpl index 1bad0e9b55..1afc744aee 100644 --- a/templates/repo/issue/view_content/conversation.tmpl +++ b/templates/repo/issue/view_content/conversation.tmpl @@ -87,7 +87,7 @@
{{if .RenderedContent}} - {{.RenderedContent|Str2html}} + {{.RenderedContent}} {{else}} {{ctx.Locale.Tr "repo.issues.no_content"}} {{end}} -- cgit v1.2.3