diff options
-rw-r--r-- | routers/web/repo/view.go | 4 | ||||
-rw-r--r-- | templates/repo/view_file.tmpl | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index 89bb1839e1..ba2ac3af11 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 53e889fefc..983491f97d 100644 --- a/templates/repo/view_file.tmpl +++ b/templates/repo/view_file.tmpl @@ -61,6 +61,9 @@ <button class="ui mini basic button unescape-button gt-mr-2 gt-hidden">{{ctx.Locale.Tr "repo.unescape_control_characters"}}</button> <button class="ui mini basic button escape-button gt-mr-2">{{ctx.Locale.Tr "repo.escape_control_characters"}}</button> {{end}} + {{if and .ReadmeInList .CanEditReadmeFile}} + <a class="btn-octicon" data-tooltip-content="{{ctx.Locale.Tr "repo.editor.edit_this_file"}}" href="{{.RepoLink}}/_edit/{{PathEscapeSegments .BranchName}}/{{PathEscapeSegments .TreePath}}/{{PathEscapeSegments .FileName}}">{{svg "octicon-pencil"}}</a> + {{end}} </div> </h4> <div class="ui attached table unstackable segment"> |