summaryrefslogtreecommitdiffstats
path: root/templates/repo
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-03-01 08:11:51 +0100
committerEarl Warren <contact@earl-warren.org>2024-03-06 05:10:44 +0100
commit68099f2f008adf53c5f79dad82e930486fb80c03 (patch)
tree5d9ac530439b5f7e3c3ed6660568152e9a78a2c3 /templates/repo
parent[skip ci] Updated translations via Crowdin (diff)
downloadforgejo-68099f2f008adf53c5f79dad82e930486fb80c03.tar.xz
forgejo-68099f2f008adf53c5f79dad82e930486fb80c03.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. (cherry picked from commit e71eb8930a5d0f60874b038c223498b41ad65592) Conflicts: modules/templates/util_string.go trivial context conflict
Diffstat (limited to 'templates/repo')
-rw-r--r--templates/repo/diff/comments.tmpl2
-rw-r--r--templates/repo/issue/milestone_issues.tmpl2
-rw-r--r--templates/repo/issue/milestones.tmpl2
-rw-r--r--templates/repo/issue/view_content.tmpl2
-rw-r--r--templates/repo/issue/view_content/attachments.tmpl4
-rw-r--r--templates/repo/issue/view_content/comments.tmpl6
-rw-r--r--templates/repo/issue/view_content/conversation.tmpl2
-rw-r--r--templates/repo/release/list.tmpl2
8 files changed, 11 insertions, 11 deletions
diff --git a/templates/repo/diff/comments.tmpl b/templates/repo/diff/comments.tmpl
index e567417fa6..e00487a22c 100644
--- a/templates/repo/diff/comments.tmpl
+++ b/templates/repo/diff/comments.tmpl
@@ -55,7 +55,7 @@
<div class="ui attached segment comment-body">
<div class="render-content markup" {{if or $.Permission.IsAdmin $.HasIssuesOrPullsWritePermission (and $.root.IsSigned (eq $.root.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}}
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 91db68c810..9b2a29a0b7 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 79875d8176..9f3b8dbad2 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}}
@@ -436,7 +436,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}}
@@ -635,7 +635,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}}
diff --git a/templates/repo/release/list.tmpl b/templates/repo/release/list.tmpl
index d533cf6757..c26a58f23a 100644
--- a/templates/repo/release/list.tmpl
+++ b/templates/repo/release/list.tmpl
@@ -58,7 +58,7 @@
{{end}}
</p>
<div class="markup desc">
- {{Str2html $release.Note}}
+ {{$release.RenderedNote}}
</div>
<div class="divider"></div>
<details class="download" {{if eq $idx 0}}open{{end}}>