From d8322f878c19ef7bc84a232e0a4fbcd7a57ea28f Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Tue, 7 Nov 2023 19:55:22 +0100
Subject: [PATCH 1/7] update docs
---
docs/content/usage/profile-readme.en-us.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/docs/content/usage/profile-readme.en-us.md b/docs/content/usage/profile-readme.en-us.md
index 045d33d1c1776..41bbcaaff9558 100644
--- a/docs/content/usage/profile-readme.en-us.md
+++ b/docs/content/usage/profile-readme.en-us.md
@@ -15,6 +15,7 @@ menu:
# Profile READMEs
-To display a Markdown file in your Gitea profile page, simply create a repository named `.profile` and add a new file called `README.md`. Gitea will automatically display the contents of the file on your profile, above your repositories.
+To display a Markdown file in your Gitea user / organization profile page, simply create a repository named `.profile` and add a new file called `README.md`.
+Gitea will automatically display the contents of the file on your profile, in a new "Overview" above your repositories.
Making the `.profile` repository private will hide the Profile README.
From 342bcdf630d37713cb6bb47ac24525eb14de698c Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Tue, 7 Nov 2023 21:45:48 +0100
Subject: [PATCH 2/7] .ProfileReadme for org
---
routers/web/org/home.go | 28 ++++++++++++++++++++++++++++
templates/org/home.tmpl | 4 ++++
2 files changed, 32 insertions(+)
diff --git a/routers/web/org/home.go b/routers/web/org/home.go
index ec866eb6b3ba1..01ef88ffeb467 100644
--- a/routers/web/org/home.go
+++ b/routers/web/org/home.go
@@ -13,6 +13,8 @@ import (
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
+ "code.gitea.io/gitea/modules/git"
+ "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup/markdown"
"code.gitea.io/gitea/modules/setting"
@@ -155,5 +157,31 @@ func Home(ctx *context.Context) {
ctx.Data["ShowMemberAndTeamTab"] = ctx.Org.IsMember || len(members) > 0
+ profileGitRepo, profileReadmeBlob, profileClose := shared_user.FindUserProfileReadme(ctx)
+ defer profileClose()
+ calcOrgProfileReadme(ctx, profileGitRepo, profileReadmeBlob)
+
ctx.HTML(http.StatusOK, tplOrgHome)
}
+
+func calcOrgProfileReadme(ctx *context.Context, profileGitRepo *git.Repository, profileReadme *git.Blob) {
+ if profileGitRepo == nil || profileReadme == nil {
+ ctx.Data["HasProfileReadme"] = false
+ return
+ }
+
+ if bytes, err := profileReadme.GetBlobContent(setting.UI.MaxDisplayFileSize); err != nil {
+ log.Error("failed to GetBlobContent: %v", err)
+ } else {
+ if profileContent, err := markdown.RenderString(&markup.RenderContext{
+ Ctx: ctx,
+ GitRepo: profileGitRepo,
+ Metas: map[string]string{"mode": "document"},
+ }, bytes); err != nil {
+ log.Error("failed to RenderString: %v", err)
+ } else {
+ ctx.Data["ProfileReadme"] = profileContent
+ ctx.Data["HasProfileReadme"] = true
+ }
+ }
+}
diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl
index ee3237d45b02d..cda674df02dd6 100644
--- a/templates/org/home.tmpl
+++ b/templates/org/home.tmpl
@@ -38,6 +38,10 @@
+ {{if .HasProfileReadme}}
+
{{.ProfileReadme | Str2html}}
+ {{end}}
+
{{template "explore/repo_search" .}}
{{template "explore/repo_list" .}}
{{template "base/paginate" .}}
From 4e7ac56d52ed0b0277e6c7094aff6b00ddd192c6 Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Wed, 8 Nov 2023 01:52:06 +0100
Subject: [PATCH 3/7] Update docs/content/usage/profile-readme.en-us.md
Co-authored-by: silverwind
---
docs/content/usage/profile-readme.en-us.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/content/usage/profile-readme.en-us.md b/docs/content/usage/profile-readme.en-us.md
index 41bbcaaff9558..339176f7d4a7f 100644
--- a/docs/content/usage/profile-readme.en-us.md
+++ b/docs/content/usage/profile-readme.en-us.md
@@ -15,7 +15,7 @@ menu:
# Profile READMEs
-To display a Markdown file in your Gitea user / organization profile page, simply create a repository named `.profile` and add a new file called `README.md`.
+To display a Markdown file in your Gitea user or organization profile page, create a repository named `.profile` and add a new file named `README.md` to it.
Gitea will automatically display the contents of the file on your profile, in a new "Overview" above your repositories.
Making the `.profile` repository private will hide the Profile README.
From 09eedc44aeddf35434bb1ff1a122cee9944251e1 Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Wed, 8 Nov 2023 01:53:26 +0100
Subject: [PATCH 4/7] prepareOrgProfileReadme
---
routers/web/org/home.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/routers/web/org/home.go b/routers/web/org/home.go
index 01ef88ffeb467..e2351eafdcef9 100644
--- a/routers/web/org/home.go
+++ b/routers/web/org/home.go
@@ -159,12 +159,12 @@ func Home(ctx *context.Context) {
profileGitRepo, profileReadmeBlob, profileClose := shared_user.FindUserProfileReadme(ctx)
defer profileClose()
- calcOrgProfileReadme(ctx, profileGitRepo, profileReadmeBlob)
+ prepareOrgProfileReadme(ctx, profileGitRepo, profileReadmeBlob)
ctx.HTML(http.StatusOK, tplOrgHome)
}
-func calcOrgProfileReadme(ctx *context.Context, profileGitRepo *git.Repository, profileReadme *git.Blob) {
+func prepareOrgProfileReadme(ctx *context.Context, profileGitRepo *git.Repository, profileReadme *git.Blob) {
if profileGitRepo == nil || profileReadme == nil {
ctx.Data["HasProfileReadme"] = false
return
From 3705b91d031bb7da75589c3a2b3d25419454e8a6 Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Wed, 8 Nov 2023 01:53:58 +0100
Subject: [PATCH 5/7] rm
---
routers/web/org/home.go | 2 --
1 file changed, 2 deletions(-)
diff --git a/routers/web/org/home.go b/routers/web/org/home.go
index e2351eafdcef9..4a8ebb670a745 100644
--- a/routers/web/org/home.go
+++ b/routers/web/org/home.go
@@ -166,7 +166,6 @@ func Home(ctx *context.Context) {
func prepareOrgProfileReadme(ctx *context.Context, profileGitRepo *git.Repository, profileReadme *git.Blob) {
if profileGitRepo == nil || profileReadme == nil {
- ctx.Data["HasProfileReadme"] = false
return
}
@@ -181,7 +180,6 @@ func prepareOrgProfileReadme(ctx *context.Context, profileGitRepo *git.Repositor
log.Error("failed to RenderString: %v", err)
} else {
ctx.Data["ProfileReadme"] = profileContent
- ctx.Data["HasProfileReadme"] = true
}
}
}
From 4dddda72b2574819fa58b6c57fdaecd7be7bba92 Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Wed, 8 Nov 2023 01:54:12 +0100
Subject: [PATCH 6/7] Update templates/org/home.tmpl
Co-authored-by: KN4CK3R
---
templates/org/home.tmpl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl
index cda674df02dd6..c740b4d7bd18b 100644
--- a/templates/org/home.tmpl
+++ b/templates/org/home.tmpl
@@ -38,7 +38,7 @@
- {{if .HasProfileReadme}}
+ {{if .ProfileReadme}}
{{.ProfileReadme | Str2html}}
{{end}}
From 3239a624cb699c9fa58a9ba2e8775498732dab03 Mon Sep 17 00:00:00 2001
From: silverwind
Date: Thu, 9 Nov 2023 01:56:51 +0100
Subject: [PATCH 7/7] Update templates/org/home.tmpl
---
templates/org/home.tmpl | 1 -
1 file changed, 1 deletion(-)
diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl
index c740b4d7bd18b..2bebcc0f87d7d 100644
--- a/templates/org/home.tmpl
+++ b/templates/org/home.tmpl
@@ -41,7 +41,6 @@
{{if .ProfileReadme}}
{{.ProfileReadme | Str2html}}
{{end}}
-
{{template "explore/repo_search" .}}
{{template "explore/repo_list" .}}
{{template "base/paginate" .}}