summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2023-05-26 08:47:36 -0700
committercolin <colin@cicadas.surf>2023-05-26 08:47:36 -0700
commit660092480b858c2f34cc9c947105361ade233ddb (patch)
treeaeec6db4cfe1b867ceb6dec73a96a6d69dd6459c
parent372e5d1691452d467239bcec39f1441f0204b244 (diff)
refactored images endpoint
-rw-r--r--fussy.lisp21
1 files changed, 11 insertions, 10 deletions
diff --git a/fussy.lisp b/fussy.lisp
index b7c8385..7416378 100644
--- a/fussy.lisp
+++ b/fussy.lisp
@@ -551,18 +551,19 @@ h1 {
(or (uiop:file-exists-p (robots-path-name))
""))
+(defun theme-image-pathname (pkg theme img)
+ (uiop:ensure-pathname
+ (format nil "~a/~a/~a/~a"
+ (full-theme-image-directory)
+ pkg
+ theme
+ img)))
+
(lzb:defendpoint* :get "/images/:pkg:/:theme:/:image:" () ()
"Endpoint for serving theme preview images"
- (let ((file-path
- (pathname
- (format nil "~a/~a/~a/~a"
- (full-theme-image-directory)
- pkg
- theme
- image))))
- (unless (uiop:file-exists-p file-path)
- (lzb:http-err 404 "no such file"))
- file-path))
+ (a:if-let (file-path (theme-image-pathname pkg theme image))
+ file-path
+ (lzb:http-err 404 "No such file")))
(defun a-string (s) s)