浏览代码

Merge pull request #98 from ljanyst/user-themes

Allow for themes defines in the user repo
Brit Butler 9 年之前
父节点
当前提交
44eb77da2c
共有 3 个文件被更改,包括 19 次插入7 次删除
  1. 7 6
      src/coleslaw.lisp
  2. 8 1
      src/themes.lisp
  3. 4 0
      src/util.lisp

+ 7 - 6
src/coleslaw.lisp

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

+ 8 - 1
src/themes.lisp

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

+ 4 - 0
src/util.lisp

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