Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UserProfile Page: Render Description #12415

Merged
merged 10 commits into from
Aug 5, 2020
5 changes: 5 additions & 0 deletions routers/user/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 ctx.User != nil && len(ctx.User.Description) != 0 {
6543 marked this conversation as resolved.
Show resolved Hide resolved
lunny marked this conversation as resolved.
Show resolved Hide resolved
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)
Expand Down
5 changes: 2 additions & 3 deletions templates/user/profile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down