Selaa lähdekoodia

Merge pull request #98 from ljanyst/user-themes

Allow for themes defines in the user repo
Brit Butler 9 vuotta sitten
vanhempi
commit
44eb77da2c
3 muutettua tiedostoa jossa 19 lisäystä ja 7 poistoa
  1. 7 6
      src/coleslaw.lisp
  2. 8 1
      src/themes.lisp
  3. 4 0
      src/util.lisp

+ 7 - 6
src/coleslaw.lisp

26
   "Compile the blog to a STAGING directory as specified in .coleslawrc."
26
   "Compile the blog to a STAGING directory as specified in .coleslawrc."
27
   (ensure-directories-exist staging)
27
   (ensure-directories-exist staging)
28
   (with-current-directory staging
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
     (do-subclasses (ctype content)
36
     (do-subclasses (ctype content)
36
       (publish ctype))
37
       (publish ctype))
37
     (do-subclasses (itype index)
38
     (do-subclasses (itype index)

+ 8 - 1
src/themes.lisp

30
   "Find the symbol NAME inside PACKAGE which defaults to the theme package."
30
   "Find the symbol NAME inside PACKAGE which defaults to the theme package."
31
   (find-symbol (princ-to-string name) (theme-package package)))
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
 (defun compile-theme (theme)
40
 (defun compile-theme (theme)
34
   "Locate and compile the templates for the given THEME."
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
     (compile-template :common-lisp-backend file))
43
     (compile-template :common-lisp-backend file))
37
   (do-files (file (app-path "themes/") "tmpl")
44
   (do-files (file (app-path "themes/") "tmpl")
38
     (compile-template :common-lisp-backend file)))
45
     (compile-template :common-lisp-backend file)))

+ 4 - 0
src/util.lisp

71
   "Return a relative path beneath coleslaw."
71
   "Return a relative path beneath coleslaw."
72
   (apply 'rel-path coleslaw-conf:*basedir* path args))
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
 (defun run-program (program &rest args)
78
 (defun run-program (program &rest args)
75
   "Take a PROGRAM and execute the corresponding shell command. If ARGS is provided,
79
   "Take a PROGRAM and execute the corresponding shell command. If ARGS is provided,
76
 use (fmt program args) as the value of PROGRAM."
80
 use (fmt program args) as the value of PROGRAM."