Remove RenderEmojiPlain from template helper (#29375)
RenderEmojiPlain(emoji.ReplaceAliases) should be called explicitly for some contents, but not for everything. Actually in modern days, in most cases it doesn't need such "ReplaceAliases". So only keep it for issue/PR titles. If anyone really needs to do ReplaceAliases for some contents, I will propose a following fix. (cherry picked from commit 10c7996b5a5c705964fc6cc9c1817eea1fc436ef) Conflicts: templates/base/head.tmpl context
This commit is contained in:
parent
757567d3bd
commit
f92c3de965
|
@ -14,7 +14,6 @@ import (
|
||||||
|
|
||||||
user_model "code.gitea.io/gitea/models/user"
|
user_model "code.gitea.io/gitea/models/user"
|
||||||
"code.gitea.io/gitea/modules/base"
|
"code.gitea.io/gitea/modules/base"
|
||||||
"code.gitea.io/gitea/modules/emoji"
|
|
||||||
"code.gitea.io/gitea/modules/markup"
|
"code.gitea.io/gitea/modules/markup"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
"code.gitea.io/gitea/modules/svg"
|
"code.gitea.io/gitea/modules/svg"
|
||||||
|
@ -162,7 +161,6 @@ func NewFuncMap() template.FuncMap {
|
||||||
"RenderCodeBlock": RenderCodeBlock,
|
"RenderCodeBlock": RenderCodeBlock,
|
||||||
"RenderIssueTitle": RenderIssueTitle,
|
"RenderIssueTitle": RenderIssueTitle,
|
||||||
"RenderEmoji": RenderEmoji,
|
"RenderEmoji": RenderEmoji,
|
||||||
"RenderEmojiPlain": RenderEmojiPlain,
|
|
||||||
"ReactionToEmoji": ReactionToEmoji,
|
"ReactionToEmoji": ReactionToEmoji,
|
||||||
|
|
||||||
"RenderMarkdownToHtml": RenderMarkdownToHtml,
|
"RenderMarkdownToHtml": RenderMarkdownToHtml,
|
||||||
|
@ -218,16 +216,6 @@ func JSEscapeSafe(s string) template.HTML {
|
||||||
return template.HTML(template.JSEscapeString(s))
|
return template.HTML(template.JSEscapeString(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
func RenderEmojiPlain(s any) any {
|
|
||||||
switch v := s.(type) {
|
|
||||||
case string:
|
|
||||||
return emoji.ReplaceAliases(v)
|
|
||||||
case template.HTML:
|
|
||||||
return template.HTML(emoji.ReplaceAliases(string(v)))
|
|
||||||
}
|
|
||||||
panic(fmt.Sprintf("unexpected type %T", s))
|
|
||||||
}
|
|
||||||
|
|
||||||
// DotEscape wraps a dots in names with ZWJ [U+200D] in order to prevent autolinkers from detecting these as urls
|
// DotEscape wraps a dots in names with ZWJ [U+200D] in order to prevent autolinkers from detecting these as urls
|
||||||
func DotEscape(raw string) string {
|
func DotEscape(raw string) string {
|
||||||
return strings.ReplaceAll(raw, ".", "\u200d.\u200d")
|
return strings.ReplaceAll(raw, ".", "\u200d.\u200d")
|
||||||
|
|
|
@ -32,6 +32,7 @@ import (
|
||||||
"code.gitea.io/gitea/modules/base"
|
"code.gitea.io/gitea/modules/base"
|
||||||
"code.gitea.io/gitea/modules/container"
|
"code.gitea.io/gitea/modules/container"
|
||||||
"code.gitea.io/gitea/modules/context"
|
"code.gitea.io/gitea/modules/context"
|
||||||
|
"code.gitea.io/gitea/modules/emoji"
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
issue_indexer "code.gitea.io/gitea/modules/indexer/issues"
|
issue_indexer "code.gitea.io/gitea/modules/indexer/issues"
|
||||||
issue_template "code.gitea.io/gitea/modules/issue/template"
|
issue_template "code.gitea.io/gitea/modules/issue/template"
|
||||||
|
@ -1444,7 +1445,7 @@ func ViewIssue(ctx *context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Data["Title"] = fmt.Sprintf("#%d - %s", issue.Index, issue.Title)
|
ctx.Data["Title"] = fmt.Sprintf("#%d - %s", issue.Index, emoji.ReplaceAliases(issue.Title))
|
||||||
|
|
||||||
iw := new(issues_model.IssueWatch)
|
iw := new(issues_model.IssueWatch)
|
||||||
if ctx.Doer != nil {
|
if ctx.Doer != nil {
|
||||||
|
|
|
@ -29,6 +29,7 @@ import (
|
||||||
user_model "code.gitea.io/gitea/models/user"
|
user_model "code.gitea.io/gitea/models/user"
|
||||||
"code.gitea.io/gitea/modules/base"
|
"code.gitea.io/gitea/modules/base"
|
||||||
"code.gitea.io/gitea/modules/context"
|
"code.gitea.io/gitea/modules/context"
|
||||||
|
"code.gitea.io/gitea/modules/emoji"
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
"code.gitea.io/gitea/modules/gitrepo"
|
"code.gitea.io/gitea/modules/gitrepo"
|
||||||
issue_template "code.gitea.io/gitea/modules/issue/template"
|
issue_template "code.gitea.io/gitea/modules/issue/template"
|
||||||
|
@ -346,7 +347,7 @@ func getPullInfo(ctx *context.Context) (issue *issues_model.Issue, ok bool) {
|
||||||
ctx.ServerError("LoadRepo", err)
|
ctx.ServerError("LoadRepo", err)
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
ctx.Data["Title"] = fmt.Sprintf("#%d - %s", issue.Index, issue.Title)
|
ctx.Data["Title"] = fmt.Sprintf("#%d - %s", issue.Index, emoji.ReplaceAliases(issue.Title))
|
||||||
ctx.Data["Issue"] = issue
|
ctx.Data["Issue"] = issue
|
||||||
|
|
||||||
if !issue.IsPull {
|
if !issue.IsPull {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
{{/* Display `- .Repsository.FullName` only if `.Title` does not already start with that. */}}
|
{{/* Display `- .Repsository.FullName` only if `.Title` does not already start with that. */}}
|
||||||
<title>{{if .Title}}{{.Title | RenderEmojiPlain}} - {{end}}{{if and (.Repository.Name) (not (StringUtils.HasPrefix .Title .Repository.FullName))}}{{.Repository.FullName}} - {{end}}{{AppName}}</title>
|
<title>{{if .Title}}{{.Title}} - {{end}}{{if and (.Repository.Name) (not (StringUtils.HasPrefix .Title .Repository.FullName))}}{{.Repository.FullName}} - {{end}}{{AppName}}</title>
|
||||||
{{if .ManifestData}}<link rel="manifest" href="data:{{.ManifestData}}">{{end}}
|
{{if .ManifestData}}<link rel="manifest" href="data:{{.ManifestData}}">{{end}}
|
||||||
<meta name="author" content="{{if .Repository}}{{.Owner.Name}}{{else}}{{MetaAuthor}}{{end}}">
|
<meta name="author" content="{{if .Repository}}{{.Owner.Name}}{{else}}{{MetaAuthor}}{{end}}">
|
||||||
<meta name="description" content="{{if .Repository}}{{.Repository.Name}}{{if .Repository.Description}} - {{.Repository.Description}}{{end}}{{else}}{{MetaDescription}}{{end}}">
|
<meta name="description" content="{{if .Repository}}{{.Repository.Name}}{{if .Repository.Description}} - {{.Repository.Description}}{{end}}{{else}}{{MetaDescription}}{{end}}">
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
<div class="ui attached segment">
|
<div class="ui attached segment">
|
||||||
<div class="ui two column grid">
|
<div class="ui two column grid">
|
||||||
<div class="column left aligned">
|
<div class="column left aligned">
|
||||||
<strong>{{.Name | RenderEmojiPlain}}</strong>
|
<strong>{{.Name}}</strong>
|
||||||
<br>{{.About | RenderEmojiPlain}}
|
<br>{{.About}}
|
||||||
</div>
|
</div>
|
||||||
<div class="column right aligned">
|
<div class="column right aligned">
|
||||||
<a href="{{$.RepoLink}}/issues/new?template={{.FileName}}{{if $.milestone}}&milestone={{$.milestone}}{{end}}{{if $.project}}&project={{$.project}}{{end}}" class="ui primary button">{{ctx.Locale.Tr "repo.issues.choose.get_started"}}</a>
|
<a href="{{$.RepoLink}}/issues/new?template={{.FileName}}{{if $.milestone}}&milestone={{$.milestone}}{{end}}{{if $.project}}&project={{$.project}}{{end}}" class="ui primary button">{{ctx.Locale.Tr "repo.issues.choose.get_started"}}</a>
|
||||||
|
@ -24,8 +24,8 @@
|
||||||
<div class="ui attached segment">
|
<div class="ui attached segment">
|
||||||
<div class="ui two column grid">
|
<div class="ui two column grid">
|
||||||
<div class="column left aligned">
|
<div class="column left aligned">
|
||||||
<strong>{{.Name | RenderEmojiPlain}}</strong>
|
<strong>{{.Name}}</strong>
|
||||||
<br>{{.About | RenderEmojiPlain}}
|
<br>{{.About}}
|
||||||
</div>
|
</div>
|
||||||
<div class="column right aligned">
|
<div class="column right aligned">
|
||||||
<a href="{{.URL}}" class="ui primary button">{{svg "octicon-link-external"}} {{ctx.Locale.Tr "repo.issues.choose.open_external_link"}}</a>
|
<a href="{{.URL}}" class="ui primary button">{{svg "octicon-link-external"}} {{ctx.Locale.Tr "repo.issues.choose.open_external_link"}}</a>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
</td>
|
</td>
|
||||||
<td class="message">
|
<td class="message">
|
||||||
<span class="truncate">
|
<span class="truncate">
|
||||||
<a href="{{$.RepoLink}}/commit/{{.SHA}}" title="{{.Summary | RenderEmojiPlain}}">
|
<a href="{{$.RepoLink}}/commit/{{.SHA}}" title="{{.Summary}}">
|
||||||
{{.Summary | RenderEmoji $.Context}}
|
{{.Summary | RenderEmoji $.Context}}
|
||||||
</a>
|
</a>
|
||||||
</span>
|
</span>
|
||||||
|
|
Loading…
Reference in New Issue