-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Improve tree not found page #26570
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- bugs:
{{.locale.Tr "repo.tree_not_found" .BranchName .RepoName .TreePath | Safe}}
=> XSS - design: I do not think it's maintainable to fill the "404.tmpl" with more and more
if
blocks. IMO either:- Use a dedicate page for "tree path not found"
- Use a general approach for 404 page, eg: "NotFoundPrompt" + "NotFoundGoBackURL"
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
e401506
to
4f10f70
Compare
Agree to a dedicated rendering without the big 404. Maybe just conditionally remove the logo in such a case. |
routers/web/repo/helper.go
Outdated
refType := "" | ||
switch { | ||
case ctx.Repo.IsViewBranch: | ||
refType = "branch" | ||
case ctx.Repo.IsViewTag: | ||
refType = "tag" | ||
case ctx.Repo.IsViewCommit: | ||
refType = "commit" | ||
} | ||
ctx.Data["NotFoundPrompt"] = ctx.Locale.Tr("repo.tree_path_not_found_" + refType, ctx.Repo.TreePath, url.PathEscape(ctx.Repo.RefName)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@delvh
There's a risk when refType is empty? I'm not sure what will happen when the key word not exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, in that case, the user will see the message repo.tree_path_not_found_
instead of Path <path> is not contained within <type> <name>
.
In which case, we then know that we need to adapt this switch…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I don't even know how a user would trigger something like that.
What other ref types are there except branches, commits, and tags?
Before: ![before](https://github.com/go-gitea/gitea/assets/18380374/383822d5-7d77-4ec3-b49b-4ab1e8b167ce) After: ![after](https://github.com/go-gitea/gitea/assets/18380374/32afa0a3-fa05-4087-b96e-7d067f0ed756) In Github: https://github.com/yp05327/test/blob/main/test.drawio Updated: UI changed ![image](https://github.com/go-gitea/gitea/assets/18380374/41ed07ff-b815-4b4e-9779-5ab36b5f3980) ![image](https://github.com/go-gitea/gitea/assets/18380374/5d7b28d6-a2fc-4d4c-8d6d-d93f9c9a270b) --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Backport #26570 by @yp05327 Before: ![before](https://github.com/go-gitea/gitea/assets/18380374/383822d5-7d77-4ec3-b49b-4ab1e8b167ce) After: ![after](https://github.com/go-gitea/gitea/assets/18380374/32afa0a3-fa05-4087-b96e-7d067f0ed756) In Github: https://github.com/yp05327/test/blob/main/test.drawio Updated: UI changed ![image](https://github.com/go-gitea/gitea/assets/18380374/41ed07ff-b815-4b4e-9779-5ab36b5f3980) ![image](https://github.com/go-gitea/gitea/assets/18380374/5d7b28d6-a2fc-4d4c-8d6d-d93f9c9a270b) Co-authored-by: yp05327 <576951401@qq.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Before:
After:
In Github:
https://github.com/yp05327/test/blob/main/test.drawio
Updated:
UI changed