diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2024-03-01 15:11:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-01 07:11:51 +0000 |
commit | e71eb8930a5d0f60874b038c223498b41ad65592 (patch) | |
tree | f95ac2c5ed1854929ef63dddeddf8720963477f5 /templates/repo/issue | |
parent | 58ce1de994c2a036ebf7137c143ce193694d740d (diff) | |
download | gitea-e71eb8930a5d0f60874b038c223498b41ad65592.tar.gz gitea-e71eb8930a5d0f60874b038c223498b41ad65592.zip |
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.
Diffstat (limited to 'templates/repo/issue')
-rw-r--r-- | templates/repo/issue/milestone_issues.tmpl | 2 | ||||
-rw-r--r-- | templates/repo/issue/milestones.tmpl | 2 | ||||
-rw-r--r-- | templates/repo/issue/view_content.tmpl | 2 | ||||
-rw-r--r-- | templates/repo/issue/view_content/attachments.tmpl | 4 | ||||
-rw-r--r-- | templates/repo/issue/view_content/comments.tmpl | 6 | ||||
-rw-r--r-- | templates/repo/issue/view_content/conversation.tmpl | 2 |
6 files changed, 9 insertions, 9 deletions
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 @@ </div> {{if .Milestone.RenderedContent}} <div class="markup content gt-mb-4"> - {{.Milestone.RenderedContent|Str2html}} + {{.Milestone.RenderedContent}} </div> {{end}} <div class="gt-df gt-fc gt-gap-3"> 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 @@ </div> {{if .Content}} <div class="markup content"> - {{.RenderedContent|Str2html}} + {{.RenderedContent}} </div> {{end}} </li> 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 @@ <div class="ui attached segment comment-body" role="article"> <div class="render-content markup" {{if or $.Permission.IsAdmin $.HasIssuesOrPullsWritePermission $.IsIssuePoster}}data-can-edit="true"{{end}}> {{if .Issue.RenderedContent}} - {{.Issue.RenderedContent|Str2html}} + {{.Issue.RenderedContent}} {{else}} <span class="no-content">{{ctx.Locale.Tr "repo.issues.no_content"}}</span> {{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 @@ <div class="gt-f1 gt-p-3"> <a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}" title="{{ctx.Locale.Tr "repo.issues.attachment.open_tab" .Name}}"> {{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 @@ <div class="ui small thumbnails"> {{- range .Attachments -}} {{if FilenameIsImage .Name}} - {{if not (StringUtils.Contains $.Content .UUID)}} + {{if not (StringUtils.Contains (StringUtils.ToString $.Content) .UUID)}} <a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}"> <img alt="{{.Name}}" src="{{.DownloadURL}}" title="{{ctx.Locale.Tr "repo.issues.attachment.open_tab" .Name}}"> </a> 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 @@ <div class="ui attached segment comment-body" role="article"> <div class="render-content markup" {{if or $.Permission.IsAdmin $.HasIssuesOrPullsWritePermission (and $.IsSigned (eq $.SignedUserID .PosterID))}}data-can-edit="true"{{end}}> {{if .RenderedContent}} - {{.RenderedContent|Str2html}} + {{.RenderedContent}} {{else}} <span class="no-content">{{ctx.Locale.Tr "repo.issues.no_content"}}</span> {{end}} @@ -432,7 +432,7 @@ <div class="ui attached segment comment-body"> <div class="render-content markup" {{if or $.Permission.IsAdmin $.HasIssuesOrPullsWritePermission (and $.IsSigned (eq $.SignedUserID .PosterID))}}data-can-edit="true"{{end}}> {{if .RenderedContent}} - {{.RenderedContent|Str2html}} + {{.RenderedContent}} {{else}} <span class="no-content">{{ctx.Locale.Tr "repo.issues.no_content"}}</span> {{end}} @@ -631,7 +631,7 @@ <div class="ui attached segment"> <div class="render-content markup"> {{if .RenderedContent}} - {{.RenderedContent|Str2html}} + {{.RenderedContent}} {{else}} <span class="no-content">{{ctx.Locale.Tr "repo.issues.no_content"}}</span> {{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 @@ <div class="text comment-content"> <div class="render-content markup" {{if or $.Permission.IsAdmin $.HasIssuesOrPullsWritePermission (and $.IsSigned (eq $.SignedUserID .PosterID))}}data-can-edit="true"{{end}}> {{if .RenderedContent}} - {{.RenderedContent|Str2html}} + {{.RenderedContent}} {{else}} <span class="no-content">{{ctx.Locale.Tr "repo.issues.no_content"}}</span> {{end}} |