Skip to content

Commit 08552f0

Browse files
authored
1 parent eae555f commit 08552f0

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

routers/web/repo/view.go

+4
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,10 @@ func renderReadmeFile(ctx *context.Context, subfolder string, readmeFile *git.Tr
331331

332332
ctx.Data["FileContent"] = buf.String()
333333
}
334+
335+
if !fInfo.isLFSFile && ctx.Repo.CanEnableEditor(ctx, ctx.Doer) {
336+
ctx.Data["CanEditReadmeFile"] = true
337+
}
334338
}
335339

336340
func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink string) {

templates/repo/view_file.tmpl

+3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
<button class="ui mini basic button unescape-button gt-mr-2 gt-hidden">{{ctx.Locale.Tr "repo.unescape_control_characters"}}</button>
6262
<button class="ui mini basic button escape-button gt-mr-2">{{ctx.Locale.Tr "repo.escape_control_characters"}}</button>
6363
{{end}}
64+
{{if and .ReadmeInList .CanEditReadmeFile}}
65+
<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>
66+
{{end}}
6467
</div>
6568
</h4>
6669
<div class="ui attached table unstackable segment">

0 commit comments

Comments
 (0)