Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tree not found page #26570

Merged
merged 27 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9057b19
improve
yp05327 Aug 18, 2023
8126566
improve
yp05327 Aug 18, 2023
514f5f6
Update options/locale/locale_en-US.ini
yp05327 Aug 18, 2023
4f10f70
improve
yp05327 Aug 18, 2023
927b41a
Update modules/context/context_response.go
wxiaoguang Aug 18, 2023
1e6be71
improve
yp05327 Aug 18, 2023
99de298
improve
yp05327 Aug 21, 2023
56cfc57
improve
yp05327 Aug 22, 2023
b3a1ffd
Merge branch 'main' into improve-tree-not-found
yp05327 Sep 25, 2023
d532eab
support different ref type redirect
yp05327 Sep 25, 2023
ae103ab
improve
yp05327 Sep 25, 2023
8a12915
Merge branch 'main' into improve-tree-not-found
delvh Sep 27, 2023
842e41f
Update routers/web/repo/helper.go
yp05327 Sep 28, 2023
865742c
Update options/locale/locale_en-US.ini
yp05327 Sep 28, 2023
ea92ea2
Use the new `ctx.Locale.Tr` instead of `.locale.Tr`
delvh Sep 28, 2023
bb0fcf8
Merge branch 'main' into improve-tree-not-found
GiteaBot Sep 28, 2023
a04e9b8
Merge branch 'main' into improve-tree-not-found
GiteaBot Sep 28, 2023
9438a4c
Merge branch 'main' into improve-tree-not-found
GiteaBot Sep 28, 2023
01179ad
Merge branch 'main' into improve-tree-not-found
GiteaBot Sep 28, 2023
096262e
Merge branch 'main' into improve-tree-not-found
GiteaBot Sep 28, 2023
2491af3
Merge branch 'main' into improve-tree-not-found
GiteaBot Sep 28, 2023
ca53832
Merge branch 'main' into improve-tree-not-found
GiteaBot Sep 28, 2023
88a32c9
Merge branch 'main' into improve-tree-not-found
GiteaBot Sep 29, 2023
d3a9d96
Merge branch 'main' into improve-tree-not-found
GiteaBot Sep 29, 2023
871e47b
Merge branch 'main' into improve-tree-not-found
GiteaBot Sep 29, 2023
c682f0b
Fix lint
lunny Sep 29, 2023
36a8f2b
Merge branch 'main' into improve-tree-not-found
lunny Sep 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions modules/context/context_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/httplib"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
Expand Down Expand Up @@ -136,6 +137,11 @@ func (ctx *Context) notFoundInternal(logMsg string, logErr error) {

ctx.Data["IsRepo"] = ctx.Repo.Repository != nil
ctx.Data["Title"] = "Page Not Found"

if git.IsErrNotExist(logErr) {
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
ctx.Data["NotFoundPrompt"] = ctx.Locale.Tr("repo.tree_not_found", ctx.Repo.BranchName, ctx.Repo.Repository.Name, ctx.Repo.TreePath)
ctx.Data["NotFoundGoBackURL"] = ctx.Repo.RepoLink + "/src/branch/" + url.PathEscape(ctx.Repo.BranchName)
}
ctx.HTML(http.StatusNotFound, base.TplName("status/404"))
}

Expand Down
3 changes: 3 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ step2 = Step 2:

error = Error
error404 = The page you are trying to reach either <strong>does not exist</strong> or <strong>you are not authorized</strong> to view it.
back = Back
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved

never = Never
unknown = Unknown
Expand Down Expand Up @@ -1007,6 +1008,8 @@ delete_preexisting_success = Deleted unadopted files in %s
blame_prior = View blame prior to this change
author_search_tooltip = Shows a maximum of 30 users

tree_not_found = The %s branch of %s does not contain the path %s
yp05327 marked this conversation as resolved.
Show resolved Hide resolved

transfer.accept = Accept Transfer
transfer.accept_desc = Transfer to "%s"
transfer.reject = Reject Transfer
Expand Down
5 changes: 4 additions & 1 deletion templates/status/404.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
{{if .IsRepo}}{{template "repo/header" .}}{{end}}
<div class="ui container center">
<p style="margin-top: 100px"><img src="{{AssetUrlPrefix}}/img/404.png" alt="404"></p>
<p>{{if .NotFoundPrompt}}{{.NotFoundPrompt}}{{else}}{{.locale.Tr "error404" | Safe}}{{end}}</p>
{{if .NotFoundGoBackURL}}<a class="ui button green" href="{{.NotFoundGoBackURL}}">{{.locale.Tr "back"}}</a>{{end}}

<div class="divider"></div>
<br>
<p>{{.locale.Tr "error404" | Safe}}</p>

{{if .ShowFooterVersion}}<p>{{.locale.Tr "admin.config.app_ver"}}: {{AppVer}}</p>{{end}}
</div>
</div>
Expand Down