Browse Source

Выводятся компетенции в форматированном виде #106

pull/118/head
Artur Galyamov 2 years ago
parent
commit
219cf41f12
  1. 16
      routers/web/explore/user.go
  2. 4
      templates/explore/competences.tmpl

16
routers/web/explore/user.go

@ -6,6 +6,8 @@ package explore
import ( import (
"bytes" "bytes"
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup/markdown"
"net/http" "net/http"
"code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/db"
@ -78,6 +80,20 @@ func RenderUserSearch(ctx *context.Context, opts *user_model.SearchUserOptions,
ctx.Data["Keyword"] = opts.Keyword ctx.Data["Keyword"] = opts.Keyword
ctx.Data["Total"] = count ctx.Data["Total"] = count
ctx.Data["Users"] = users ctx.Data["Users"] = users
var renderedCompetences = make(map[int64]string)
for _, user := range users {
renderedCompetences[user.ID], err = markdown.RenderString(&markup.RenderContext{
URLPrefix: ctx.Repo.RepoLink,
Metas: map[string]string{"mode": "document"},
GitRepo: ctx.Repo.GitRepo,
Ctx: ctx,
}, user.Competences)
if err != nil {
ctx.ServerError("RenderCompetences", err)
return
}
}
ctx.Data["RenderedCompetences"] = renderedCompetences
ctx.Data["UsersTwoFaStatus"] = user_model.UserList(users).GetTwoFaStatus() ctx.Data["UsersTwoFaStatus"] = user_model.UserList(users).GetTwoFaStatus()
ctx.Data["ShowUserEmail"] = setting.UI.ShowUserEmail ctx.Data["ShowUserEmail"] = setting.UI.ShowUserEmail
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled

4
templates/explore/competences.tmpl

@ -20,6 +20,10 @@
<a href="mailto:{{.Email}}" rel="nofollow">{{.Email}}</a> <a href="mailto:{{.Email}}" rel="nofollow">{{.Email}}</a>
{{end}} {{end}}
{{svg "octicon-clock"}} {{$.i18n.Tr "user.join_on"}} {{.CreatedUnix.FormatShort}} {{svg "octicon-clock"}} {{$.i18n.Tr "user.join_on"}} {{.CreatedUnix.FormatShort}}
{{if .Competences}}
<h4>Компетенции:</h4>
<div>{{(index $.RenderedCompetences .ID)|Str2html}}</div>
{{end}}
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save