- Actually define *static-dir* at build time, to get the search.png in the search box - Better logging for migration running at startup time - Fix and-where to properly exclude nil clauses - fix looking up build-time vars in the :build package Change-Id: Ia2ef3b2715d4c2efb62bbb2c72084f0f0ad09562 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11325 Autosubmit: aspen <root@gws.fyi> Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
		
			
				
	
	
		
			39 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			Common Lisp
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			Common Lisp
		
	
	
	
	
	
(in-package :panettone.util)
 | 
						|
 | 
						|
(defun integer-env (var &key default)
 | 
						|
  (or
 | 
						|
   (when-let ((str (uiop:getenvp var)))
 | 
						|
     (try-parse-integer str))
 | 
						|
   default))
 | 
						|
 | 
						|
(defun add-missing-base64-padding (s)
 | 
						|
  "Add any missing padding characters to the (un-padded) base64 string `S', such
 | 
						|
that it can be successfully decoded by the `BASE64' package"
 | 
						|
  ;; I apologize
 | 
						|
  (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"
 | 
						|
  (let ((clauses (remove nil clauses)))
 | 
						|
    (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) package)))
 | 
						|
             (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 "/")))
 |