Skip to content

Commit

Permalink
Add edit option for README.md (go-gitea#28071)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobDev authored and fuxiaohei committed Jan 17, 2024
1 parent 2e26f33 commit a1dd678
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions routers/web/repo/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions templates/repo/view_file.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down

0 comments on commit a1dd678

Please sign in to comment.