diff --git a/src/utils.lisp b/src/utils.lisp index 54a629e..c4bf195 100644 --- a/src/utils.lisp +++ b/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 + "

\"~a\"~a

" + alt-text + alt-text + src-image + message)) (defun get-alert () "Get alert message from session data."