|
|
|
@ -15,7 +15,9 @@
|
|
|
|
|
#:get-and-reset-alert |
|
|
|
|
#:checkbox-to-bool |
|
|
|
|
#:asciify |
|
|
|
|
#:slugify) |
|
|
|
|
#:slugify |
|
|
|
|
#:get-image-dimensions |
|
|
|
|
#:run-bash-command) |
|
|
|
|
(:documentation "Utilities that do not depend on models.")) |
|
|
|
|
|
|
|
|
|
(in-package #:utils) |
|
|
|
@ -33,6 +35,7 @@
|
|
|
|
|
(read-from-string key)) |
|
|
|
|
:collect value)) |
|
|
|
|
|
|
|
|
|
;; PORT CODE TO NO LONGER CALL THIS VERSION OF THE FUNCTION (MOVED TO VALIDATION PACKAGE). |
|
|
|
|
(defun string-is-nil-or-empty? (string-to-test) |
|
|
|
|
"Tests to see if `STRING-TO-TEST' is empty of just whitespace. |
|
|
|
|
This is essentially the 'IsNullOrWhiteSpace' function I use in C#. It |
|
|
|
@ -80,3 +83,20 @@ THIS FUNCTION."
|
|
|
|
|
(cond ((or (string= "checked" value) (string= "on" value)) +true+) |
|
|
|
|
((or (string= "off" value) (null value)) +false+) |
|
|
|
|
((null value) +false+))) |
|
|
|
|
|
|
|
|
|
(defun get-image-dimensions (filepath) |
|
|
|
|
"Uses Image Magick (via Bash) to get the resolution of an image as 'WxH'. |
|
|
|
|
The `FILEPATH' must be already merged with |
|
|
|
|
`ritherdon-archive.config::*application-root*' before you call this function." |
|
|
|
|
(let* ((command |
|
|
|
|
(format nil "identify -format \"%wx%h\" ~a" filepath)) |
|
|
|
|
(out-message (uiop:run-program command :output :string |
|
|
|
|
:ignore-error-status t |
|
|
|
|
:error-output :string))) |
|
|
|
|
out-message)) |
|
|
|
|
|
|
|
|
|
(defun run-bash-command (command) |
|
|
|
|
"Runs the Bash command." |
|
|
|
|
(uiop:run-program command :output :string |
|
|
|
|
:ignore-error-status t |
|
|
|
|
:error-output :string)) |
|
|
|
|