Browse Source

UserProfile Page: Render Description (#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 <art27@cantab.net>
for-closed-social
6543 4 years ago
committed by GitHub
parent
commit
2872a04f27
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions
  1. +5
    -0
      routers/user/profile.go
  2. +2
    -3
      templates/user/profile.tmpl

+ 5
- 0
routers/user/profile.go View File

@ -12,6 +12,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/markup/markdown"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/routers/org"
@ -97,6 +98,10 @@ func Profile(ctx *context.Context) {
// so everyone would get the same empty heatmap
ctx.Data["EnableHeatmap"] = setting.Service.EnableUserHeatmap && !ctxUser.KeepActivityPrivate
ctx.Data["HeatmapUser"] = ctxUser.Name
if len(ctxUser.Description) != 0 {
ctx.Data["RenderedDescription"] = string(markdown.Render([]byte(ctxUser.Description), ctx.Repo.RepoLink, map[string]string{"mode": "document"}))
}
showPrivate := ctx.IsSigned && (ctx.User.IsAdmin || ctx.User.ID == ctxUser.ID)
orgs, err := models.GetOrgsByUserID(ctxUser.ID, showPrivate)

+ 2
- 3
templates/user/profile.tmpl View File

@ -34,10 +34,9 @@
<a target="_blank" rel="noopener noreferrer me" href="{{.Owner.Website}}">{{.Owner.Website}}</a>
</li>
{{end}}
{{if .Owner.Description}}
{{if $.RenderedDescription}}
<li>
{{svg "octicon-info" 16}}
<span>{{.Owner.Description}}</span>
<div class="render-content markdown">{{$.RenderedDescription|Str2html}}</div>
</li>
{{end}}
{{range .OpenIDs}}

Loading…
Cancel
Save