From 08552f0076204b99258f9135c77a962c302521dc Mon Sep 17 00:00:00 2001 From: JakobDev Date: Mon, 20 Nov 2023 12:47:55 +0100 Subject: [PATCH] Add edit option for README.md (#28071) Fix #28059 ![grafik](https://github.com/go-gitea/gitea/assets/15185051/07adc216-954e-486b-bfda-df3bc15f2089) --- routers/web/repo/view.go | 4 ++++ templates/repo/view_file.tmpl | 3 +++ 2 files changed, 7 insertions(+) diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index 89bb1839e..ba2ac3af1 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -331,6 +331,10 @@ func renderReadmeFile(ctx *context.Context, subfolder string, readmeFile *git.Tr ctx.Data["FileContent"] = buf.String() } + + if !fInfo.isLFSFile && ctx.Repo.CanEnableEditor(ctx, ctx.Doer) { + ctx.Data["CanEditReadmeFile"] = true + } } func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink string) { diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl index 53e889fef..983491f97 100644 --- a/templates/repo/view_file.tmpl +++ b/templates/repo/view_file.tmpl @@ -61,6 +61,9 @@ {{end}} + {{if and .ReadmeInList .CanEditReadmeFile}} + {{svg "octicon-pencil"}} + {{end}}