diff --git a/handlers.go b/handlers.go index d10f9cf..f354261 100644 --- a/handlers.go +++ b/handlers.go @@ -67,6 +67,7 @@ type RenderPageArgs struct { type ErrorPageArgs struct { CommonPageArgs ShowLoginForm bool + OldPageTitle string } type RenamePageArgs struct { diff --git a/middleware.go b/middleware.go index 647473d..9595f7c 100644 --- a/middleware.go +++ b/middleware.go @@ -212,7 +212,10 @@ func PageErrorHandler(templateFs fs.FS) func(http.Handler) http.Handler { if strings.HasPrefix(r.RequestURI, "/view/") || strings.HasPrefix(r.RequestURI, "/history") { isWiki = true } - + oldPageTitle := "" + if strings.HasPrefix(r.RequestURI, "/view/") { + oldPageTitle = strings.TrimPrefix(r.RequestURI, "/view/") + } renderTemplate(templateFs, NotFound, http.StatusNotFound, w, &ErrorPageArgs{ CommonPageArgs{ Session: getSessionArgs(w, r), @@ -221,6 +224,7 @@ func PageErrorHandler(templateFs fs.FS) func(http.Handler) http.Handler { IsError: true, }, false, + oldPageTitle, }) } if fakeWriter.status == http.StatusUnauthorized { @@ -231,6 +235,7 @@ func PageErrorHandler(templateFs fs.FS) func(http.Handler) http.Handler { IsError: true, }, true, + "", }) } if fakeWriter.status == http.StatusForbidden { @@ -241,6 +246,7 @@ func PageErrorHandler(templateFs fs.FS) func(http.Handler) http.Handler { IsError: true, }, false, + "", }) } if fakeWriter.status == http.StatusInternalServerError { @@ -251,6 +257,7 @@ func PageErrorHandler(templateFs fs.FS) func(http.Handler) http.Handler { IsError: true, }, false, + "", }) } }) diff --git a/templates/404.gohtml b/templates/404.gohtml index fddde73..7c31015 100644 --- a/templates/404.gohtml +++ b/templates/404.gohtml @@ -1,7 +1,7 @@ -{{- /*gotype: github.com/mdbot/wiki.NotFoundPageArgs*/ -}} +{{- /*gotype: github.com/mdbot/wiki.ErrorPageArgs*/ -}} {{template "header" .CommonPageArgs}}

Page not found

{{if and .CommonPageArgs.IsWikiPage .CommonPageArgs.Session.CanEdit}} -

Create it

+

Create it

{{end}} {{template "footer" .CommonPageArgs}}