about summary refs log tree commit diff
path: root/web/panettone/src/util.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'web/panettone/src/util.lisp')
-rw-r--r--web/panettone/src/util.lisp23
1 files changed, 23 insertions, 0 deletions
diff --git a/web/panettone/src/util.lisp b/web/panettone/src/util.lisp
index 2abedf7b8fbb..c9d86cbfb32d 100644
--- a/web/panettone/src/util.lisp
+++ b/web/panettone/src/util.lisp
@@ -13,3 +13,26 @@ that it can be successfully decoded by the `BASE64' package"
   (let* ((needed-padding (mod (length s) 4))
          (pad-chars (if (zerop needed-padding) 0 (- 4 needed-padding))))
     (format nil "~A~v@{~A~:*~}" s pad-chars "=")))
+
+(defun and-where (clauses)
+  "Combine all non-nil clauses in CLAUSES into a single S-SQL WHERE form"
+  (if (null clauses) t
+      (reduce (lambda (x y) `(:and ,x ,y)) clauses)))
+
+(defun and-where* (&rest clauses)
+  "Combine all non-nil clauses in CLAUSES into a single S-SQL WHERE form"
+  (and-where clauses))
+
+(defmacro define-build-time-var
+    (name value-if-not-in-build &optional (doc nil))
+  `(defvar ,name
+     (or (when-let ((package (find-package :build)))
+           (let ((sym (find-symbol ,(symbol-name name))))
+             (when (boundp sym) (symbol-value sym))))
+         ,value-if-not-in-build)
+     ,doc))
+
+(defun ->dir (dir)
+  (if (char-equal (uiop:last-char dir) #\/)
+      dir
+      (concatenate 'string dir "/")))