Commit 11d4db3d authored by Erik Huelsmann's avatar Erik Huelsmann

Integrate static asset deployment into Lisp code

parent 47316678
......@@ -5,7 +5,7 @@ serve:
mkdir -p output/static
cp -rf content/static/* output/static
# cp -rf content/static/* output/static
cp content/favicon.ico output/
......@@ -28,7 +28,7 @@
"A list of strings representing relative filenames.")
;; General static files - images etc
(defparameter *STATIC-DIR* (asdf:system-relative-pathname :cl-site "layout/static/")
(defparameter *STATIC-DIR* (asdf:system-relative-pathname :cl-site "content/static/")
"Pathname for location of static files.")
;; The only REQUIRED field is :content which must be the filename of the page content
......@@ -16,23 +16,19 @@
(defun process-scripts () nil)
;; Copies/renders static assets (imgs, etc)
(defun process-static ())
(defun process-static ()
((static-output-dir (merge-pathnames #P"static/" *OUTPUT-DIR*))
(static-list (mapcar
(lambda (s) (progn
(uiop:copy-file (make-path *STATIC-DIR* s)
(make-path static-output-dir s))
(cons :location s)))
(lambda (p) (file-namestring p))
(directory (make-pathname :defaults *STATIC-DIR*
:name :wild
:type :wild))))))
(push (cons :static static-list) *GLOBAL-CONTEXT*)))
(let ((destination-root (merge-pathnames #P"static/" *output-dir*))
(sources (directory (merge-pathnames "**/*.*" *static-dir*)))
(dolist (source sources)
(let* ((relative-path (enough-namestring source *static-dir*))
(destination (merge-pathnames relative-path destination-root)))
(when (pathname-name destination) ;; ignore directories
(ensure-directories-exist destination)
(uiop:copy-file source destination)
(push (cons :location relative-path) static-list))))
(push (cons :static (nreverse static-list))
;; process-pages : Copies/renders pages - called last
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment