Clickable links in pull request (and issue) titles (#13695)
* clickable links in pull request (and issue) titles #13658 reuses the existing logic to render clickable links in commit messages * dedicated RenderIssueTitle function applied patch from @mrsdizzie
This commit is contained in:
parent
18712eab79
commit
056b8f5b52
3 changed files with 31 additions and 1 deletions
|
@ -268,6 +268,25 @@ func RenderCommitMessageSubject(
|
||||||
return ctx.postProcess(rawHTML)
|
return ctx.postProcess(rawHTML)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RenderIssueTitle to process title on individual issue/pull page
|
||||||
|
func RenderIssueTitle(
|
||||||
|
rawHTML []byte,
|
||||||
|
urlPrefix string,
|
||||||
|
metas map[string]string,
|
||||||
|
) ([]byte, error) {
|
||||||
|
ctx := &postProcessCtx{
|
||||||
|
metas: metas,
|
||||||
|
urlPrefix: urlPrefix,
|
||||||
|
procs: []processor{
|
||||||
|
issueIndexPatternProcessor,
|
||||||
|
sha1CurrentPatternProcessor,
|
||||||
|
emojiShortCodeProcessor,
|
||||||
|
emojiProcessor,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return ctx.postProcess(rawHTML)
|
||||||
|
}
|
||||||
|
|
||||||
// RenderDescriptionHTML will use similar logic as PostProcess, but will
|
// RenderDescriptionHTML will use similar logic as PostProcess, but will
|
||||||
// use a single special linkProcessor.
|
// use a single special linkProcessor.
|
||||||
func RenderDescriptionHTML(
|
func RenderDescriptionHTML(
|
||||||
|
|
|
@ -154,6 +154,7 @@ func NewFuncMap() []template.FuncMap {
|
||||||
"RenderCommitMessageLink": RenderCommitMessageLink,
|
"RenderCommitMessageLink": RenderCommitMessageLink,
|
||||||
"RenderCommitMessageLinkSubject": RenderCommitMessageLinkSubject,
|
"RenderCommitMessageLinkSubject": RenderCommitMessageLinkSubject,
|
||||||
"RenderCommitBody": RenderCommitBody,
|
"RenderCommitBody": RenderCommitBody,
|
||||||
|
"RenderIssueTitle": RenderIssueTitle,
|
||||||
"RenderEmoji": RenderEmoji,
|
"RenderEmoji": RenderEmoji,
|
||||||
"RenderEmojiPlain": emoji.ReplaceAliases,
|
"RenderEmojiPlain": emoji.ReplaceAliases,
|
||||||
"ReactionToEmoji": ReactionToEmoji,
|
"ReactionToEmoji": ReactionToEmoji,
|
||||||
|
@ -630,6 +631,16 @@ func RenderCommitBody(msg, urlPrefix string, metas map[string]string) template.H
|
||||||
return template.HTML(renderedMessage)
|
return template.HTML(renderedMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RenderIssueTitle renders issue/pull title with defined post processors
|
||||||
|
func RenderIssueTitle(text, urlPrefix string, metas map[string]string) template.HTML {
|
||||||
|
renderedText, err := markup.RenderIssueTitle([]byte(template.HTMLEscapeString(text)), urlPrefix, metas)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("RenderIssueTitle: %v", err)
|
||||||
|
return template.HTML("")
|
||||||
|
}
|
||||||
|
return template.HTML(renderedText)
|
||||||
|
}
|
||||||
|
|
||||||
// RenderEmoji renders html text with emoji post processors
|
// RenderEmoji renders html text with emoji post processors
|
||||||
func RenderEmoji(text string) template.HTML {
|
func RenderEmoji(text string) template.HTML {
|
||||||
renderedText, err := markup.RenderEmoji([]byte(template.HTMLEscapeString(text)))
|
renderedText, err := markup.RenderEmoji([]byte(template.HTMLEscapeString(text)))
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
<h1>
|
<h1>
|
||||||
<span id="issue-title">{{RenderEmoji .Issue.Title}}</span>
|
<span id="issue-title">{{RenderIssueTitle .Issue.Title $.RepoLink $.Repository.ComposeMetas}}</span>
|
||||||
<span class="index">#{{.Issue.Index}}</span>
|
<span class="index">#{{.Issue.Index}}</span>
|
||||||
<div id="edit-title-input" class="ui input" style="display: none">
|
<div id="edit-title-input" class="ui input" style="display: none">
|
||||||
<input value="{{.Issue.Title}}" maxlength="255">
|
<input value="{{.Issue.Title}}" maxlength="255">
|
||||||
|
|
Reference in a new issue