From a41ca9f8992edc50629c02fe3aa5ecaf443fae35 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Tue, 2 Nov 2021 16:52:32 +0800 Subject: [PATCH 1/4] fix issue #497 --- templates/repo/view_file.tmpl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl index 1216b5f40..7c98420d9 100644 --- a/templates/repo/view_file.tmpl +++ b/templates/repo/view_file.tmpl @@ -34,6 +34,21 @@ {{end}} + + {{if .ReadmeInList}} +
+
+ {{if .Repository.CanEnableEditor}} + {{if .CanEditFile}} + {{svg "octicon-pencil" 16}} + {{else}} + {{svg "octicon-pencil" 16}} + {{end}} + {{end}} +
+
+ {{end}} + {{if not .ReadmeInList}}
From 9ca3ea4b52d8e35ce2a1d981d4cbea86a4463e1f Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Tue, 2 Nov 2021 17:45:29 +0800 Subject: [PATCH 2/4] fix issue --- templates/repo/view_file.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl index 7c98420d9..60777b5dd 100644 --- a/templates/repo/view_file.tmpl +++ b/templates/repo/view_file.tmpl @@ -63,7 +63,7 @@ {{.i18n.Tr "repo.file_history"}}
{{if .Repository.CanEnableEditor}} - {{if .CanEditFile}} + {{.CanEditFile}}{{if .CanEditFile}} {{svg "octicon-pencil" 16}} {{else}} {{svg "octicon-pencil" 16}} From d41a804d3b3474049d407921fcc1d761f425b9b9 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Mon, 8 Nov 2021 11:19:54 +0800 Subject: [PATCH 3/4] add caneditfile --- routers/repo/view.go | 5 +++++ templates/repo/view_file.tmpl | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) mode change 100644 => 100755 routers/repo/view.go mode change 100644 => 100755 templates/repo/view_file.tmpl diff --git a/routers/repo/view.go b/routers/repo/view.go old mode 100644 new mode 100755 index 9477b27dd..f85ab07cf --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -243,6 +243,11 @@ func renderDirectory(ctx *context.Context, treeLink string) { ctx.Data["ReadmeInList"] = true ctx.Data["ReadmeExist"] = true ctx.Data["FileIsSymlink"] = readmeFile.isSymlink + ctx.Data["ReadmeName"] = readmeFile.name + + if ctx.Repo.CanEnableEditor() { + ctx.Data["CanEditFile"] = true + } dataRc, err := readmeFile.blob.DataAsync() if err != nil { diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl old mode 100644 new mode 100755 index 60777b5dd..aef8e728e --- a/templates/repo/view_file.tmpl +++ b/templates/repo/view_file.tmpl @@ -40,7 +40,7 @@
{{if .Repository.CanEnableEditor}} {{if .CanEditFile}} - {{svg "octicon-pencil" 16}} + {{svg "octicon-pencil" 16}} {{else}} {{svg "octicon-pencil" 16}} {{end}} From ff3aee8639aa45420f4d05eeab12f04a6e15150a Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Mon, 8 Nov 2021 16:31:11 +0800 Subject: [PATCH 4/4] fix issue --- templates/repo/view_file.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl index aef8e728e..a0cae31f3 100755 --- a/templates/repo/view_file.tmpl +++ b/templates/repo/view_file.tmpl @@ -63,7 +63,7 @@ {{.i18n.Tr "repo.file_history"}}
{{if .Repository.CanEnableEditor}} - {{.CanEditFile}}{{if .CanEditFile}} + {{if .CanEditFile}} {{svg "octicon-pencil" 16}} {{else}} {{svg "octicon-pencil" 16}}