diff --git a/routers/web/repo/competence.go b/routers/web/repo/competence.go index 14fa178ccd..fb97c86b8a 100644 --- a/routers/web/repo/competence.go +++ b/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) } diff --git a/routers/web/repo/resource.go b/routers/web/repo/resource.go index 95e75c0818..fbc825cdc4 100644 --- a/routers/web/repo/resource.go +++ b/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) } diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go index 90fafb871e..8cdfac9578 100644 --- a/routers/web/user/profile.go +++ b/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, diff --git a/templates/repo/competences/list.tmpl b/templates/repo/competences/list.tmpl index 15bd99afda..8fa2c9cb8a 100644 --- a/templates/repo/competences/list.tmpl +++ b/templates/repo/competences/list.tmpl @@ -1 +1,11 @@ -