Browse Source

add optional parameter to set-alert function in utils package.

This is so I can define what type of alert message I want the server
to send... and include the cat images I found.
stable
Craig Oates 2 years ago
parent
commit
a7eb3240bf
  1. 18
      src/utils.lisp

18
src/utils.lisp

@ -76,11 +76,25 @@ name. Just specify it in this function's `REQUEST-VALUE' argument."
(string= request-value (car item)))
collect item))
(defun set-alert (message)
(defun set-alert (message &optional alert-type)
"Sets the alert `MESSAGE' stored in session, provide info. to users.
The intention is store a `MESSAGE' across a redirect during a HTTP
POST request."
(setf (gethash :alert ningle:*session*) message))
(cond ((string= "error" alert-type)
(setf (gethash :alert ningle:*session*)
(build-alert-string alert-type "vomit-cat.png" message)))
((string= "success" alert-type)
(setf (gethash :alert ningle:*session*)
(build-alert-string alert-type "disco-cat.png" message)))
(t (setf (gethash :alert ningle:*session*) message))))
(defun build-alert-string (alt-text src-image message)
(format nil
"<p class=\"~a\"><img alt=\"~a\" src=\"/images/alerts/~a\">~a</p>"
alt-text
alt-text
src-image
message))
(defun get-alert ()
"Get alert message from session data."

Loading…
Cancel
Save