Add DO-FILES and refactor COMPILE-THEME.
This commit is contained in:
parent
a88b2b2979
commit
4b264e2587
2 changed files with 14 additions and 6 deletions
|
@ -5,6 +5,16 @@
|
|||
If ARGS is provided, use (apply 'format nil PATH ARGS) as the value of PATH."
|
||||
(merge-pathnames (apply 'format nil path args) coleslaw-conf:*basedir*))
|
||||
|
||||
(defun to-pathname (file parent)
|
||||
"Convert an iolib file-path back to a pathname."
|
||||
(merge-pathnames (file-path-namestring file) parent))
|
||||
|
||||
(defmacro do-files ((var path) &body body)
|
||||
"For each file under PATH, run BODY."
|
||||
`(iolib.os:mapdir (lambda (x)
|
||||
(let ((,var (to-pathname x ,path)))
|
||||
,@body)) ,path))
|
||||
|
||||
(defun compile-blog ()
|
||||
(let ((staging #p"/tmp/coleslaw/"))
|
||||
; TODO: More incremental compilation? Don't regen whole blog unnecessarily.
|
||||
|
|
|
@ -10,12 +10,10 @@
|
|||
(find-package (string-upcase (concatenate 'string "coleslaw.theme." name))))
|
||||
|
||||
(defun compile-theme (&key (theme-dir (app-path "themes/~a/" (theme *config*))))
|
||||
(flet ((maybe-compile (file)
|
||||
(let* ((path (merge-pathnames (file-path-namestring file) theme-dir))
|
||||
(extension (pathname-type path)))
|
||||
(do-files (file theme-dir)
|
||||
(let ((extension (pathname-type file)))
|
||||
(when (and extension (string= extension "tmpl"))
|
||||
(compile-template :common-lisp-backend path)))))
|
||||
(iolib.os:mapdir #'maybe-compile theme-dir)))
|
||||
(compile-template :common-lisp-backend file)))))
|
||||
|
||||
;; DOCUMENTATION
|
||||
;; A theme directory should be named after the theme and contain *.tmpl files
|
||||
|
|
Loading…
Add table
Reference in a new issue