Browse Source

Реализован вывод сохранённых доверительных свойств на соответствующей вкладке проекта #65

pull/120/head
Artur Galyamov 2 years ago
parent
commit
ff3b56acd2
  1. 12
      routers/web/repo/competence.go
  2. 12
      routers/web/repo/resource.go
  3. 8
      routers/web/user/profile.go
  4. 12
      templates/repo/competences/list.tmpl
  5. 12
      templates/repo/resources/list.tmpl

12
routers/web/repo/competence.go

@ -3,6 +3,7 @@ package repo
import (
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/routers/web/user"
"net/http"
)
@ -11,5 +12,16 @@ const (
)
func Competences(ctx *context.Context) {
ctx.Data["PageIsCompetences"] = true
repo := ctx.Data["Repository"]
var err error
ctx.Data["RenderedCompetences"], err = user.GetRenderedTextField(ctx, repo, "Competences")
if err != nil {
ctx.ServerError("Render", err)
return
}
ctx.HTML(http.StatusOK, tplCompetences)
}

12
routers/web/repo/resource.go

@ -3,6 +3,7 @@ package repo
import (
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/routers/web/user"
"net/http"
)
@ -11,5 +12,16 @@ const (
)
func Resources(ctx *context.Context) {
ctx.Data["PageIsResources"] = true
repo := ctx.Data["Repository"]
var err error
ctx.Data["RenderedResources"], err = user.GetRenderedTextField(ctx, repo, "Resources")
if err != nil {
ctx.ServerError("Render", err)
return
}
ctx.HTML(http.StatusOK, tplResources)
}

8
routers/web/user/profile.go

@ -402,16 +402,16 @@ func Action(ctx *context.Context) {
ctx.RedirectToFirst(ctx.FormString("redirect_to"), u.HomeLink())
}
func getTextField(user interface{}, fieldName string) string {
reflectedObj := reflect.ValueOf(user)
func getTextField(obj interface{}, fieldName string) string {
reflectedObj := reflect.ValueOf(obj)
dynamicField := reflect.Indirect(reflectedObj).FieldByName(fieldName)
return dynamicField.String()
}
func GetRenderedTextField(ctx *context.Context, ctxUser interface{}, fieldName string) (string, error) {
func GetRenderedTextField(ctx *context.Context, obj interface{}, fieldName string) (string, error) {
var err error = nil
var content string
fieldVal := getTextField(ctxUser, fieldName)
fieldVal := getTextField(obj, fieldName)
if len(fieldVal) != 0 {
content, err = markdown.RenderString(&markup.RenderContext{
URLPrefix: ctx.Repo.RepoLink,

12
templates/repo/competences/list.tmpl

@ -1 +1,11 @@
<h1>Competences</h1>
{{template "base/head" .}}
<div class="page-content repository">
{{template "repo/header" .}}
<div class="ui container">
<h1>{{.i18n.Tr "repo.competences"}}</h1>
<div>
{{$.RenderedCompetences | Str2html}}
</div>
</div>
</div>
{{template "base/footer" .}}

12
templates/repo/resources/list.tmpl

@ -1 +1,11 @@
<h1>Resources</h1>
{{template "base/head" .}}
<div class="page-content repository">
{{template "repo/header" .}}
<div class="ui container">
<h1>{{.i18n.Tr "repo.resources"}}</h1>
<div>
{{$.RenderedResources | Str2html}}
</div>
</div>
</div>
{{template "base/footer" .}}

Loading…
Cancel
Save