Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for themes defines in the user repo #98

Merged
merged 1 commit into from Nov 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/coleslaw.lisp
Expand Up @@ -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."
(ensure-directories-exist staging)
(with-current-directory staging
(dolist (dir (list (app-path "themes/~a/css" (theme *config*))
(app-path "themes/~a/img" (theme *config*))
(app-path "themes/~a/js" (theme *config*))
(merge-pathnames "static" (repo-dir *config*))))
(when (probe-file dir)
(run-program "rsync --delete -raz ~a ." dir)))
(let ((theme-dir (find-theme (theme *config*))))
(dolist (dir (list (merge-pathnames "css" theme-dir)
(merge-pathnames "img" theme-dir)
(merge-pathnames "js" theme-dir)
(repo-path "static")))
(when (probe-file dir)
(run-program "rsync --delete -raz ~a ." dir))))
(do-subclasses (ctype content)
(publish ctype))
(do-subclasses (itype index)
Expand Down
9 changes: 8 additions & 1 deletion src/themes.lisp
Expand Up @@ -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-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)
"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))
(do-files (file (app-path "themes/") "tmpl")
(compile-template :common-lisp-backend file)))
4 changes: 4 additions & 0 deletions src/util.lisp
Expand Up @@ -71,6 +71,10 @@ If ARGS is provided, use (fmt path args) as the value of PATH."
"Return a relative path beneath coleslaw."
(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)
"Take a PROGRAM and execute the corresponding shell command. If ARGS is provided,
use (fmt program args) as the value of PROGRAM."
Expand Down