Skip to content

Commit 9057b19

Browse files
committed
improve
1 parent 445dbda commit 9057b19

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

modules/context/context_response.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616

1717
user_model "code.gitea.io/gitea/models/user"
1818
"code.gitea.io/gitea/modules/base"
19+
"code.gitea.io/gitea/modules/git"
1920
"code.gitea.io/gitea/modules/httplib"
2021
"code.gitea.io/gitea/modules/log"
2122
"code.gitea.io/gitea/modules/setting"
@@ -136,6 +137,7 @@ func (ctx *Context) notFoundInternal(logMsg string, logErr error) {
136137

137138
ctx.Data["IsRepo"] = ctx.Repo.Repository != nil
138139
ctx.Data["Title"] = "Page Not Found"
140+
ctx.Data["IsTreeNotFound"] = git.IsErrNotExist(logErr)
139141
ctx.HTML(http.StatusNotFound, base.TplName("status/404"))
140142
}
141143

options/locale/locale_en-US.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,9 @@ delete_preexisting_success = Deleted unadopted files in %s
10071007
blame_prior = View blame prior to this change
10081008
author_search_tooltip = Shows a maximum of 30 users
10091009
1010+
tree_not_found = The <span class="ui label">%s</span> branch of %s does not contain the path %s
1011+
return_to_repository = Return to the repository
1012+
10101013
transfer.accept = Accept Transfer
10111014
transfer.accept_desc = Transfer to "%s"
10121015
transfer.reject = Reject Transfer

templates/status/404.tmpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55
<p style="margin-top: 100px"><img src="{{AssetUrlPrefix}}/img/404.png" alt="404"></p>
66
<div class="divider"></div>
77
<br>
8+
{{if and .IsRepo .IsTreeNotFound}}
9+
<p>{{.locale.Tr "repo.tree_not_found" .BranchName .RepoName .TreePath | Safe}}</p>
10+
<a class="ui button green" href="{{.Repository.Link}}/src/branch/{{.BranchName | PathEscape}}">{{.locale.Tr "repo.return_to_repository"}}</a>
11+
{{else}}
812
<p>{{.locale.Tr "error404" | Safe}}</p>
913
{{if .ShowFooterVersion}}<p>{{.locale.Tr "admin.config.app_ver"}}: {{AppVer}}</p>{{end}}
14+
{{end}}
1015
</div>
1116
</div>
1217
{{template "base/footer" .}}

0 commit comments

Comments
 (0)