Allow for themes defines in the user repo

This commit is contained in:
Lukasz Janyst 2015-11-15 20:23:53 +01:00
parent 96512011a0
commit bd17b6c039
3 changed files with 19 additions and 7 deletions

View file

@ -26,12 +26,13 @@ in REPO-DIR. Optionally, OLDREV is the revision prior to the last push."
"Compile the blog to a STAGING directory as specified in .coleslawrc." "Compile the blog to a STAGING directory as specified in .coleslawrc."
(ensure-directories-exist staging) (ensure-directories-exist staging)
(with-current-directory staging (with-current-directory staging
(dolist (dir (list (app-path "themes/~a/css" (theme *config*)) (let ((theme-dir (find-theme (theme *config*))))
(app-path "themes/~a/img" (theme *config*)) (dolist (dir (list (merge-pathnames "css" theme-dir)
(app-path "themes/~a/js" (theme *config*)) (merge-pathnames "img" theme-dir)
(merge-pathnames "static" (repo-dir *config*)))) (merge-pathnames "js" theme-dir)
(when (probe-file dir) (repo-path "static")))
(run-program "rsync --delete -raz ~a ." dir))) (when (probe-file dir)
(run-program "rsync --delete -raz ~a ." dir))))
(do-subclasses (ctype content) (do-subclasses (ctype content)
(publish ctype)) (publish ctype))
(do-subclasses (itype index) (do-subclasses (itype index)

View file

@ -30,9 +30,16 @@ function that takes a DOCUMENT and returns NIL or a STRING for template insertio
"Find the symbol NAME inside PACKAGE which defaults to the theme package." "Find the symbol NAME inside PACKAGE which defaults to the theme package."
(find-symbol (princ-to-string name) (theme-package package))) (find-symbol (princ-to-string name) (theme-package package)))
(defun find-theme (theme)
"Find the theme prefering themes in the local repo."
(let ((local-theme (repo-path "themes/~a/" theme)))
(if (probe-file local-theme)
local-theme
(app-path "themes/~a/" theme))))
(defun compile-theme (theme) (defun compile-theme (theme)
"Locate and compile the templates for the given THEME." "Locate and compile the templates for the given THEME."
(do-files (file (app-path "themes/~a/" theme) "tmpl") (do-files (file (find-theme theme) "tmpl")
(compile-template :common-lisp-backend file)) (compile-template :common-lisp-backend file))
(do-files (file (app-path "themes/") "tmpl") (do-files (file (app-path "themes/") "tmpl")
(compile-template :common-lisp-backend file))) (compile-template :common-lisp-backend file)))

View file

@ -71,6 +71,10 @@ If ARGS is provided, use (fmt path args) as the value of PATH."
"Return a relative path beneath coleslaw." "Return a relative path beneath coleslaw."
(apply 'rel-path coleslaw-conf:*basedir* path args)) (apply 'rel-path coleslaw-conf:*basedir* path args))
(defun repo-path (path &rest args)
"Return a relative path beneath the repo being processed."
(apply 'rel-path (repo-dir *config*) path args))
(defun run-program (program &rest args) (defun run-program (program &rest args)
"Take a PROGRAM and execute the corresponding shell command. If ARGS is provided, "Take a PROGRAM and execute the corresponding shell command. If ARGS is provided,
use (fmt program args) as the value of PROGRAM." use (fmt program args) as the value of PROGRAM."