Skip to content

Commit

Permalink
Fixed flash bug, it didn't work on redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
html committed Mar 5, 2014
1 parent 6d151bb commit 5e63348
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
28 changes: 28 additions & 0 deletions src/request.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,31 @@ all other parameters. However, none of the callbacks (see
etc."
(string-equal (get-parameter "pure") "true"))

(defvar *redirect-request-p* nil)

(defun redirect-request-p ()
(declare (special *redirect-request-p*))
(or *redirect-request-p*
(webapp-session-value 'redirect-p)))

(defun clear-session-redirect-p ()
(declare (special *redirect-request-p*))
(setf *redirect-request-p* (webapp-session-value 'redirect-p))
(setf (webapp-session-value 'redirect-p) nil))

(defun clear-redirect-var ()
(declare (special *redirect-request-p*))
(setf *redirect-request-p* nil))

(eval-when (:load-toplevel)
(pushnew 'clear-session-redirect-p
(request-hook :application :post-action))
(pushnew 'clear-redirect-var
(request-hook :application :pre-action)))

(defun set-redirect-true ()
(setf (webapp-session-value 'redirect-p) t))

(defun redirect (uri &key (defer (and (boundp '*session*) (boundp '*request-hook*)
:post-render))
new-window-p (window-title uri))
Expand Down Expand Up @@ -69,6 +94,9 @@ NEW-WINDOW functionality will only work when Javascript is enabled."
(abort-request-handler
(format nil "{\"redirect\":\"~A\"}" uri)))
(hunchentoot:redirect uri))))

(set-redirect-true)

(cond
(new-window-p
(send-script
Expand Down
3 changes: 2 additions & 1 deletion src/widgets/flash.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
(push (lambda ()
(when (and (flash-messages obj)
(not (refresh-request-p))
(not (initial-request-p)))
(not (initial-request-p))
(not (redirect-request-p)))
(setf (flash-old-messages obj) (flash-messages obj))
(setf (flash-messages obj) nil)))
(request-hook :session :pre-action))
Expand Down
2 changes: 1 addition & 1 deletion weblocks.asd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

(defsystem weblocks
:name "weblocks"
:version "0.10.7"
:version "0.10.8"
:maintainer "Olexiy Zamkoviy, Scott L. Burson"
:author "Slava Akhmechet"
:licence "LLGPL"
Expand Down

0 comments on commit 5e63348

Please sign in to comment.