From ffbca5e16292d858e45680d5b4897ff7c42ee15b Mon Sep 17 00:00:00 2001 From: Las Zenow Date: Sun, 5 Feb 2017 01:51:00 +0000 Subject: [PATCH] Return to the previous location when saving/deleting books --- lib/admin.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/admin.go b/lib/admin.go index ac1a31e..67fa00b 100644 --- a/lib/admin.go +++ b/lib/admin.go @@ -47,7 +47,7 @@ func deleteHandler(h handler) { } h.sess.Save(h.w, h.r) if isNew { - http.Redirect(h.w, h.r, "/new/", http.StatusFound) + http.Redirect(h.w, h.r, h.r.Referer(), http.StatusFound) } else { http.Redirect(h.w, h.r, "/", http.StatusFound) } @@ -117,6 +117,7 @@ func saveHandler(h handler) { if h.db.IsBookActive(id) { http.Redirect(h.w, h.r, "/book/"+id, http.StatusFound) } else { + // XXX: I can't use a referer here :( http.Redirect(h.w, h.r, "/new/", http.StatusFound) } } @@ -216,5 +217,5 @@ func storeHandler(h handler) { h.sess.Notify("Store books!", "The books '"+strings.Join(titles, ", ")+"' are stored for public download", "success") } h.sess.Save(h.w, h.r) - http.Redirect(h.w, h.r, "/new/", http.StatusFound) + http.Redirect(h.w, h.r, h.r.Referer(), http.StatusFound) }