Skip to content

Commit 8126566

Browse files
committed
improve
1 parent 9057b19 commit 8126566

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

modules/context/context_response.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,11 @@ func (ctx *Context) notFoundInternal(logMsg string, logErr error) {
137137

138138
ctx.Data["IsRepo"] = ctx.Repo.Repository != nil
139139
ctx.Data["Title"] = "Page Not Found"
140-
ctx.Data["IsTreeNotFound"] = git.IsErrNotExist(logErr)
140+
141+
if git.IsErrNotExist(logErr) {
142+
ctx.Data["NotFoundPrompt"] = ctx.Locale.Tr("repo.tree_not_found", ctx.Repo.BranchName, ctx.Repo.Repository.Name, ctx.Repo.TreePath)
143+
ctx.Data["NotFoundGoBackURL"] = ctx.Repo.RepoLink + "/src/branch/" + url.PathEscape(ctx.Repo.BranchName)
144+
}
141145
ctx.HTML(http.StatusNotFound, base.TplName("status/404"))
142146
}
143147

options/locale/locale_en-US.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ step2 = Step 2:
112112

113113
error = Error
114114
error404 = The page you are trying to reach either <strong>does not exist</strong> or <strong>you are not authorized</strong> to view it.
115+
back = Back
115116

116117
never = Never
117118
unknown = Unknown
@@ -1007,8 +1008,7 @@ delete_preexisting_success = Deleted unadopted files in %s
10071008
blame_prior = View blame prior to this change
10081009
author_search_tooltip = Shows a maximum of 30 users
10091010
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
1011+
tree_not_found = The %s branch of %s does not contain the path %s
10121012
10131013
transfer.accept = Accept Transfer
10141014
transfer.accept_desc = Transfer to "%s"

templates/status/404.tmpl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
{{if .IsRepo}}{{template "repo/header" .}}{{end}}
44
<div class="ui container center">
55
<p style="margin-top: 100px"><img src="{{AssetUrlPrefix}}/img/404.png" alt="404"></p>
6+
<p>{{if .NotFoundPrompt}}{{.NotFoundPrompt}}{{else}}{{.locale.Tr "error404" | Safe}}{{end}}</p>
7+
{{if .NotFoundGoBackURL}}<a class="ui button green" href="{{.NotFoundGoBackURL}}">{{.locale.Tr "back"}}</a>{{end}}
8+
69
<div class="divider"></div>
710
<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}}
12-
<p>{{.locale.Tr "error404" | Safe}}</p>
11+
1312
{{if .ShowFooterVersion}}<p>{{.locale.Tr "admin.config.app_ver"}}: {{AppVer}}</p>{{end}}
14-
{{end}}
1513
</div>
1614
</div>
1715
{{template "base/footer" .}}

0 commit comments

Comments
 (0)