mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-25 11:22:16 +00:00
Improve Wiki TOC (#24137)
The old code has a lot of technical debts, eg: `repo/wiki/view.tmpl` / `Iterate` This PR improves the Wiki TOC display and improves the code. --------- Co-authored-by: delvh <dev.lh@web.de>
This commit is contained in:
parent
f045e58cc7
commit
1ab16e48cc
12 changed files with 129 additions and 118 deletions
|
@ -143,31 +143,29 @@ func Recovery(ctx goctx.Context) func(next http.Handler) http.Handler {
|
|||
"locale": lc,
|
||||
}
|
||||
|
||||
user := context.GetContextUser(req)
|
||||
// TODO: this recovery handler is usually called without Gitea's web context, so we shouldn't touch that context too much
|
||||
// Otherwise, the 500 page may cause new panics, eg: cache.GetContextWithData, it makes the developer&users couldn't find the original panic
|
||||
user := context.GetContextUser(req) // almost always nil
|
||||
if user == nil {
|
||||
// Get user from session if logged in - do not attempt to sign-in
|
||||
user = auth.SessionUser(sessionStore)
|
||||
}
|
||||
if user != nil {
|
||||
store["IsSigned"] = true
|
||||
store["SignedUser"] = user
|
||||
store["SignedUserID"] = user.ID
|
||||
store["SignedUserName"] = user.Name
|
||||
store["IsAdmin"] = user.IsAdmin
|
||||
} else {
|
||||
store["SignedUserID"] = int64(0)
|
||||
store["SignedUserName"] = ""
|
||||
}
|
||||
|
||||
httpcache.SetCacheControlInHeader(w.Header(), 0, "no-transform")
|
||||
w.Header().Set(`X-Frame-Options`, setting.CORSConfig.XFrameOptions)
|
||||
|
||||
if !setting.IsProd {
|
||||
if !setting.IsProd || (user != nil && user.IsAdmin) {
|
||||
store["ErrorMsg"] = combinedErr
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
log.Error("HTML render in Recovery handler panics again: %v", err)
|
||||
}
|
||||
}()
|
||||
err = rnd.HTML(w, http.StatusInternalServerError, "status/500", templates.BaseVars().Merge(store))
|
||||
if err != nil {
|
||||
log.Error("%v", err)
|
||||
log.Error("HTML render in Recovery handler fails again: %v", err)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue