From ff3b56acd217ae7217d5244f5b3a4c593b8c6921 Mon Sep 17 00:00:00 2001 From: Artur Galyamov Date: Thu, 15 Sep 2022 19:16:20 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=20=D1=81?= =?UTF-8?q?=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D1=91=D0=BD=D0=BD=D1=8B=D1=85=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B2=D0=B5=D1=80=D0=B8=D1=82=D0=B5=D0=BB=D1=8C?= =?UTF-8?q?=D0=BD=D1=8B=D1=85=20=D1=81=D0=B2=D0=BE=D0=B9=D1=81=D1=82=D0=B2?= =?UTF-8?q?=20=D0=BD=D0=B0=20=D1=81=D0=BE=D0=BE=D1=82=D0=B2=D0=B5=D1=82?= =?UTF-8?q?=D1=81=D1=82=D0=B2=D1=83=D1=8E=D1=89=D0=B5=D0=B9=20=D0=B2=D0=BA?= =?UTF-8?q?=D0=BB=D0=B0=D0=B4=D0=BA=D0=B5=20=D0=BF=D1=80=D0=BE=D0=B5=D0=BA?= =?UTF-8?q?=D1=82=D0=B0=20#65?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/web/repo/competence.go | 12 ++++++++++++ routers/web/repo/resource.go | 12 ++++++++++++ routers/web/user/profile.go | 8 ++++---- templates/repo/competences/list.tmpl | 12 +++++++++++- templates/repo/resources/list.tmpl | 12 +++++++++++- 5 files changed, 50 insertions(+), 6 deletions(-) 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 @@ -

Competences

+{{template "base/head" .}} +
+ {{template "repo/header" .}} +
+

{{.i18n.Tr "repo.competences"}}

+
+ {{$.RenderedCompetences | Str2html}} +
+
+
+{{template "base/footer" .}} diff --git a/templates/repo/resources/list.tmpl b/templates/repo/resources/list.tmpl index 81f8fc8e69..125cb62d85 100644 --- a/templates/repo/resources/list.tmpl +++ b/templates/repo/resources/list.tmpl @@ -1 +1,11 @@ -

Resources

+{{template "base/head" .}} +
+ {{template "repo/header" .}} +
+

{{.i18n.Tr "repo.resources"}}

+
+ {{$.RenderedResources | Str2html}} +
+
+
+{{template "base/footer" .}}