Skip to content

Commit f27a755

Browse files
GiteaBotwxiaoguang
andauthored
Fix readme path and markdown link paste (#34755) (#34760)
Backport #34755 by wxiaoguang Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 parent 958d0db commit f27a755

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

routers/web/repo/view_readme.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func prepareToRenderReadmeFile(ctx *context.Context, subfolder string, readmeFil
150150
}
151151

152152
ctx.Data["RawFileLink"] = ""
153-
ctx.Data["ReadmeInList"] = true
153+
ctx.Data["ReadmeInList"] = path.Join(subfolder, readmeFile.Name()) // the relative path to the readme file to the current tree path
154154
ctx.Data["ReadmeExist"] = true
155155
ctx.Data["FileIsSymlink"] = readmeFile.IsLink()
156156

@@ -162,7 +162,7 @@ func prepareToRenderReadmeFile(ctx *context.Context, subfolder string, readmeFil
162162
defer dataRc.Close()
163163

164164
ctx.Data["FileIsText"] = fInfo.isTextFile
165-
ctx.Data["FileTreePath"] = path.Join(subfolder, readmeFile.Name())
165+
ctx.Data["FileTreePath"] = path.Join(ctx.Repo.TreePath, subfolder, readmeFile.Name())
166166
ctx.Data["FileSize"] = fInfo.fileSize
167167
ctx.Data["IsLFSFile"] = fInfo.isLFSFile
168168

templates/repo/view_file.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<div class="file-header-left tw-flex tw-items-center tw-py-2 tw-pr-4">
2828
{{if .ReadmeInList}}
2929
{{svg "octicon-book" 16 "tw-mr-2"}}
30-
<strong><a class="muted" href="#readme">{{.FileTreePath}}</a></strong>
30+
<strong><a class="muted" href="#readme">{{.ReadmeInList}}</a></strong>
3131
{{else}}
3232
{{template "repo/file_info" .}}
3333
{{end}}

web_src/js/features/comp/EditorUpload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ function handleClipboardText(textarea: HTMLTextAreaElement, e: ClipboardEvent, p
135135

136136
// when pasting links over selected text, turn it into [text](link)
137137
const pastedAsMarkdown = pasteAsMarkdownLink(textarea, pastedText);
138-
if (pastedText) {
138+
if (pastedAsMarkdown) {
139139
e.preventDefault();
140140
replaceTextareaSelection(textarea, pastedAsMarkdown);
141141
}

0 commit comments

Comments
 (0)