ui: improve error pages (#7274)
* add testing * make each page accessible via `/devtest/error` * allow translating the `Page not found` part of the title * code: improve consistency, remove unused * devtest: put index page in a container to fix alignment * 500: make navbar more like the real one, remove fake menu button * deadcode: remove unused `func NotFound`: it was added inbdd32f152d
and the only usage was removed in1bfb0a24d8
Preview: https://codeberg.org/attachments/1b75afb3-e898-410f-be02-f036a5400143 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7274 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Reviewed-by: Beowulf <beowulf@beocode.eu>
This commit is contained in:
parent
683eb5bf78
commit
51ff4970ec
11 changed files with 106 additions and 32 deletions
|
@ -1,4 +1,5 @@
|
|||
// Copyright 2023 The Gitea Authors. All rights reserved.
|
||||
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package context
|
||||
|
@ -66,7 +67,10 @@ func (ctx *Context) RedirectToFirst(location ...string) string {
|
|||
return setting.AppSubURL + "/"
|
||||
}
|
||||
|
||||
const tplStatus500 base.TplName = "status/500"
|
||||
const (
|
||||
tplStatus404 base.TplName = "status/404"
|
||||
tplStatus500 base.TplName = "status/500"
|
||||
)
|
||||
|
||||
// HTML calls Context.HTML and renders the template to HTTP response
|
||||
func (ctx *Context) HTML(status int, name base.TplName) {
|
||||
|
@ -153,8 +157,8 @@ func (ctx *Context) notFoundInternal(logMsg string, logErr error) {
|
|||
}
|
||||
|
||||
ctx.Data["IsRepo"] = ctx.Repo.Repository != nil
|
||||
ctx.Data["Title"] = "Page Not Found"
|
||||
ctx.HTML(http.StatusNotFound, base.TplName("status/404"))
|
||||
ctx.Data["Title"] = ctx.Locale.TrString("error.not_found.title")
|
||||
ctx.HTML(http.StatusNotFound, tplStatus404)
|
||||
}
|
||||
|
||||
// ServerError displays a 500 (Internal Server Error) page and prints the given error, if any.
|
||||
|
@ -177,7 +181,6 @@ func (ctx *Context) serverErrorInternal(logMsg string, logErr error) {
|
|||
}
|
||||
}
|
||||
|
||||
ctx.Data["Title"] = "Internal Server Error"
|
||||
ctx.HTML(http.StatusInternalServerError, tplStatus500)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue