|
|
@ -1,21 +1,21 @@ |
|
|
|
|
|
|
|
(in-package #:cl-user) |
|
|
|
(defpackage #:utils |
|
|
|
(defpackage #:utils |
|
|
|
(:use #:cl |
|
|
|
(:use #:cl |
|
|
|
|
|
|
|
#:caveman2 |
|
|
|
#:log4cl) |
|
|
|
#:log4cl) |
|
|
|
(:export #:format-date |
|
|
|
(:export #:i18n-load |
|
|
|
#:i18n-load |
|
|
|
|
|
|
|
#:_ |
|
|
|
#:_ |
|
|
|
#:parse-iso-date |
|
|
|
#:parse-iso-date |
|
|
|
#:request-params |
|
|
|
#:request-params |
|
|
|
#:string-is-nil-or-empty-p |
|
|
|
#:string-is-nil-or-empty? |
|
|
|
#:separate-files-in-web-request) |
|
|
|
#:separate-files-in-web-request |
|
|
|
|
|
|
|
#:set-alert |
|
|
|
|
|
|
|
#:get-alert |
|
|
|
|
|
|
|
#:get-and-reset-alert) |
|
|
|
(:documentation "Utilities that do not depend on models.")) |
|
|
|
(:documentation "Utilities that do not depend on models.")) |
|
|
|
|
|
|
|
|
|
|
|
(in-package #:utils) |
|
|
|
(in-package #:utils) |
|
|
|
|
|
|
|
|
|
|
|
(defun format-date (date) |
|
|
|
|
|
|
|
"Format the given date with the default date format (yyyy-mm-dd). Return a string." |
|
|
|
|
|
|
|
(local-time:format-timestring nil date :format +date-y-m-d+)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun asciify (string) |
|
|
|
(defun asciify (string) |
|
|
|
(str:downcase (slug:asciify string))) |
|
|
|
(str:downcase (slug:asciify string))) |
|
|
|
|
|
|
|
|
|
|
@ -25,7 +25,7 @@ |
|
|
|
(read-from-string key)) |
|
|
|
(read-from-string key)) |
|
|
|
:collect value)) |
|
|
|
:collect value)) |
|
|
|
|
|
|
|
|
|
|
|
(defun string-is-nil-or-empty-p (string-to-test) |
|
|
|
(defun string-is-nil-or-empty? (string-to-test) |
|
|
|
"Tests to see if `STRING-TO-TEST' is empty of just whitespace. |
|
|
|
"Tests to see if `STRING-TO-TEST' is empty of just whitespace. |
|
|
|
This is essentially the 'IsNullOrWhiteSpace' function I use in C#. It |
|
|
|
This is essentially the 'IsNullOrWhiteSpace' function I use in C#. It |
|
|
|
expands the 'empty string' check to include a check to see if there is |
|
|
|
expands the 'empty string' check to include a check to see if there is |
|
|
@ -46,3 +46,19 @@ name. Just specify it in this function's `REQUEST-VALUE' argument." |
|
|
|
if (or (string= "CONTENT-FILES" (car item)) |
|
|
|
if (or (string= "CONTENT-FILES" (car item)) |
|
|
|
(string= request-value (car item))) |
|
|
|
(string= request-value (car item))) |
|
|
|
collect item)) |
|
|
|
collect item)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun set-alert (message) |
|
|
|
|
|
|
|
"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)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun get-alert () |
|
|
|
|
|
|
|
"Get alert message from session data." |
|
|
|
|
|
|
|
(gethash :alert ningle:*session*)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun get-and-reset-alert () |
|
|
|
|
|
|
|
"Returns the `ALERT' message and clears its content from the session hash." |
|
|
|
|
|
|
|
(let ((message (get-alert))) |
|
|
|
|
|
|
|
(set-alert nil) |
|
|
|
|
|
|
|
message)) |
|
|
|