diff --git a/ui/amcontext.go b/ui/amcontext.go index cf1bad0..26ec7fc 100644 --- a/ui/amcontext.go +++ b/ui/amcontext.go @@ -15,6 +15,7 @@ import ( "fmt" "mime/multipart" "net/http" + "net/url" "strconv" "time" @@ -59,6 +60,7 @@ type AmContext interface { IsMember() bool IsMemberLocked() bool LeftMenu() string + Locator() string OutputType() string Parameter(string) string QueryParamInt(string, int) int @@ -239,11 +241,14 @@ func (c *amContext) FormFile(name string) (*multipart.FileHeader, error) { return c.echoContext.FormFile(name) } +// emptyMap is the return from FrameMetadata if the specified selector is not present. +var emptyMap map[string]string = make(map[string]string) + // FrameMetadata returns the frame metadata for a specified type. func (c *amContext) FrameMetadata(selector int) map[string]string { rmap, ok := c.frameMeta[selector] if !ok { - rmap = make(map[string]string) + rmap = emptyMap } return rmap } @@ -296,6 +301,18 @@ func (c *amContext) LeftMenu() string { } } +// Locator returns the current URL path minus the scheme and host, so it's a site-relative locator. +func (c *amContext) Locator() string { + tmp := url.URL{ + Path: c.echoContext.Request().URL.Path, + RawPath: c.echoContext.Request().URL.RawPath, + RawQuery: c.echoContext.Request().URL.RawQuery, + Fragment: c.echoContext.Request().URL.Fragment, + RawFragment: c.echoContext.Request().URL.RawFragment, + } + return tmp.String() +} + // OutputType returns the MIME output type set for the current operation. func (c *amContext) OutputType() string { return c.outputType diff --git a/ui/render_wrap.go b/ui/render_wrap.go index e1fb51a..a59bc48 100644 --- a/ui/render_wrap.go +++ b/ui/render_wrap.go @@ -70,6 +70,9 @@ func AmSendPageData(ctxt echo.Context, amctxt AmContext, command string, data an } amctxt.SetFrameTitle("Internal Server Error") amctxt.VarMap().Set("error", message) + if tmp := amctxt.GetSession("lastKnownGood"); tmp != nil { + amctxt.VarMap().Set("recovery", tmp) + } command = "framed" data = "error.jet" case "ipban": @@ -148,6 +151,9 @@ func AmWrap(myfunc PageFunc) echo.HandlerFunc { // Exec the wrapped function. command, arg := myfunc(ctxt) + if command != "error" && command != "ipban" { + ctxt.SetSession("lastKnownGood", ctxt.Locator()) + } if err := ctxt.SaveSession(); err != nil { c.Logger().Errorf("Session save error: %v", err) return err diff --git a/ui/views/dialog.jet b/ui/views/dialog.jet index d9bdede..cd5e580 100644 --- a/ui/views/dialog.jet +++ b/ui/views/dialog.jet @@ -9,7 +9,7 @@
- You are about to unjoin the {{ comm.Name }} community. - {{ if comm.MembersOnly }} - You will lose access to all content of the community, as well as the ability to interact with - the community as a whole. - {{ else }} - You will lose the ability to interact with the community's members and content. - {{ end }} -
-Please confirm if you wish to proceed.
-+ You are about to unjoin the {{ comm.Name }} community. + {{ if comm.MembersOnly }} + You will lose access to all content of the community, as well as the ability to interact with + the community as a whole. + {{ else }} + You will lose the ability to interact with the community's members and content. + {{ end }} +
+Are you sure you want to do this?
+