mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Fix incorrect file links (#34189)
Fix #34188 The name "FileName" is ambiguous: sometimes it is "base name without path", sometimes it is "full name with path". The ambiguous name causes various problems. This PR clarifies the usage: `FileTreePath`: the full name with path.
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
<div class="{{TabSizeClass .Editorconfig .FileName}} non-diff-file-content">
|
||||
<div class="{{TabSizeClass .Editorconfig .FileTreePath}} non-diff-file-content">
|
||||
<h4 class="file-header ui top attached header tw-flex tw-items-center tw-justify-between tw-flex-wrap">
|
||||
<div class="file-header-left tw-flex tw-items-center tw-py-2 tw-pr-4">
|
||||
{{template "repo/file_info" .}}
|
||||
|
@@ -70,15 +70,15 @@
|
||||
{{/* at the moment, wiki doesn't support these "view" links like "view at history point" */}}
|
||||
{{if not $.PageIsWiki}}
|
||||
{{/* view single file diff */}}
|
||||
{{if $.FileName}}
|
||||
{{if $.FileTreePath}}
|
||||
<a class="btn interact-bg tw-p-2 view-single-diff" data-tooltip-content="{{ctx.Locale.Tr "repo.commits.view_file_diff"}}"
|
||||
href="{{$commitRepoLink}}/commit/{{.ID.String}}?files={{$.FileName}}"
|
||||
href="{{$commitRepoLink}}/commit/{{.ID.String}}?files={{$.FileTreePath}}"
|
||||
>{{svg "octicon-file-diff"}}</a>
|
||||
{{end}}
|
||||
|
||||
{{/* view at history point */}}
|
||||
{{$viewCommitLink := printf "%s/src/commit/%s" $commitRepoLink (PathEscape .ID.String)}}
|
||||
{{if $.FileName}}{{$viewCommitLink = printf "%s/%s" $viewCommitLink (PathEscapeSegments $.FileName)}}{{end}}
|
||||
{{if $.FileTreePath}}{{$viewCommitLink = printf "%s/%s" $viewCommitLink (PathEscapeSegments $.FileTreePath)}}{{end}}
|
||||
<a class="btn interact-bg tw-p-2 view-commit-path" data-tooltip-content="{{ctx.Locale.Tr "repo.commits.view_path"}}" href="{{$viewCommitLink}}">{{svg "octicon-file-code"}}</a>
|
||||
{{end}}
|
||||
</td>
|
||||
|
@@ -45,7 +45,7 @@
|
||||
{{end}}
|
||||
|
||||
{{if .ReadmeExist}}
|
||||
<a class="flex-text-block muted" href="{{.TreeLink}}/{{.FileName}}">
|
||||
<a class="flex-text-block muted" href="{{.RepoLink}}/src/{{.RefTypeNameSubURL}}/{{PathEscapeSegments .FileTreePath}}">
|
||||
{{svg "octicon-book"}} {{ctx.Locale.Tr "readme"}}
|
||||
</a>
|
||||
{{end}}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<div {{if .ReadmeInList}}id="readme" {{end}}class="{{TabSizeClass .Editorconfig .FileName}} non-diff-file-content">
|
||||
<div {{if .ReadmeInList}}id="readme" {{end}}class="{{TabSizeClass .Editorconfig .FileTreePath}} non-diff-file-content">
|
||||
{{- if .FileError}}
|
||||
<div class="ui error message">
|
||||
<div class="text left tw-whitespace-pre">{{.FileError}}</div>
|
||||
@@ -27,7 +27,7 @@
|
||||
<div class="file-header-left tw-flex tw-items-center tw-py-2 tw-pr-4">
|
||||
{{if .ReadmeInList}}
|
||||
{{svg "octicon-book" 16 "tw-mr-2"}}
|
||||
<strong><a class="muted" href="#readme">{{.FileName}}</a></strong>
|
||||
<strong><a class="muted" href="#readme">{{.FileTreePath}}</a></strong>
|
||||
{{else}}
|
||||
{{template "repo/file_info" .}}
|
||||
{{end}}
|
||||
@@ -78,7 +78,7 @@
|
||||
<button class="ui mini basic button escape-button tw-mr-1">{{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>
|
||||
<a class="btn-octicon" data-tooltip-content="{{ctx.Locale.Tr "repo.editor.edit_this_file"}}" href="{{.RepoLink}}/_edit/{{PathEscapeSegments .BranchName}}/{{PathEscapeSegments .FileTreePath}}">{{svg "octicon-pencil"}}</a>
|
||||
{{end}}
|
||||
</div>
|
||||
</h4>
|
||||
|
Reference in New Issue
Block a user