Skip to content

Commit 2872a04

Browse files
6543zeripath
andauthored
UserProfile Page: Render Description (go-gitea#12415)
* If Description contain more that one line render it * simpler ... * only render if description exists * Fix NPE in tests * Update routers/user/profile.go Co-authored-by: zeripath <[email protected]>
1 parent 6ab4d76 commit 2872a04

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

routers/user/profile.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
"code.gitea.io/gitea/models"
1414
"code.gitea.io/gitea/modules/context"
15+
"code.gitea.io/gitea/modules/markup/markdown"
1516
"code.gitea.io/gitea/modules/setting"
1617
"code.gitea.io/gitea/modules/util"
1718
"code.gitea.io/gitea/routers/org"
@@ -97,6 +98,10 @@ func Profile(ctx *context.Context) {
9798
// so everyone would get the same empty heatmap
9899
ctx.Data["EnableHeatmap"] = setting.Service.EnableUserHeatmap && !ctxUser.KeepActivityPrivate
99100
ctx.Data["HeatmapUser"] = ctxUser.Name
101+
if len(ctxUser.Description) != 0 {
102+
ctx.Data["RenderedDescription"] = string(markdown.Render([]byte(ctxUser.Description), ctx.Repo.RepoLink, map[string]string{"mode": "document"}))
103+
}
104+
100105
showPrivate := ctx.IsSigned && (ctx.User.IsAdmin || ctx.User.ID == ctxUser.ID)
101106

102107
orgs, err := models.GetOrgsByUserID(ctxUser.ID, showPrivate)

templates/user/profile.tmpl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@
3434
<a target="_blank" rel="noopener noreferrer me" href="{{.Owner.Website}}">{{.Owner.Website}}</a>
3535
</li>
3636
{{end}}
37-
{{if .Owner.Description}}
37+
{{if $.RenderedDescription}}
3838
<li>
39-
{{svg "octicon-info" 16}}
40-
<span>{{.Owner.Description}}</span>
39+
<div class="render-content markdown">{{$.RenderedDescription|Str2html}}</div>
4140
</li>
4241
{{end}}
4342
{{range .OpenIDs}}

0 commit comments

Comments
 (0)