Quellcode durchsuchen

APP-PATH tweaks, COMPILE-THEME fix.

Brit Butler vor 13 Jahren
Ursprung
Commit
65d4f349da
4 geänderte Dateien mit 27 neuen und 53 gelöschten Zeilen
  1. 7 16
      src/coleslaw.lisp
  2. 11 0
      src/config.lisp
  3. 2 32
      src/packages.lisp
  4. 7 5
      src/themes.lisp

+ 7 - 16
src/coleslaw.lisp

@@ -1,19 +1,9 @@
1 1
 (in-package :coleslaw)
2 2
 
3
-(defclass blog ()
4
-  ((author :initarg :author :initform "" :accessor author)
5
-   (domain :initarg :domain :initform "" :accessor domain)
6
-   (interval :initarg :interval :initform 600 :accessor interval)
7
-   (license :initarg :license :initform "" :accessor license)
8
-   (plugins :initarg :plugins :initform '() :accessor plugins)
9
-   (repo :initarg :repo :initform #p"/" :accessor repo)
10
-   (sitenav :initarg :sitenav :initform "" :accessor sitenav)
11
-   (title :initarg :title :initform "" :accessor title)
12
-   (theme :initarg :theme :initform "hyde" :accessor theme)))
13
-
14
-(defun app-path (path)
15
-  "Take a relative PATH and return the corresponding pathname beneath coleslaw."
16
-  (merge-pathnames path coleslaw-conf:*basedir*))
3
+(defun app-path (path &rest args)
4
+  "Take a relative PATH and return the corresponding pathname beneath coleslaw.
5
+If ARGS is provided, use (apply 'format nil PATH ARGS) as the value of PATH."
6
+  (merge-pathnames (apply 'format nil path args) coleslaw-conf:*basedir*))
17 7
 
18 8
 (defun compile-blog ()
19 9
   (let ((staging #p"/tmp/coleslaw/"))
@@ -22,7 +12,7 @@
22 12
         (delete-files staging :recursive t)
23 13
         (ensure-directories-exist staging))
24 14
     (with-current-directory staging
25
-      (let ((css-dir (app-path (format nil "themes/~a/css/" (theme *config*))))
15
+      (let ((css-dir (app-path "themes/~a/css/" (theme *config*)))
26 16
             (static-dir (merge-pathnames "static/" (repo *config*))))
27 17
         (dolist (dir (list css-dir static-dir))
28 18
           (run-program "cp" `("-R" ,dir "."))))
@@ -36,7 +26,7 @@
36 26
 
37 27
 (defun deploy (dir)
38 28
   "Deploy DIR, updating the .prev and .curr symlinks."
39
-  (let ((new-build (app-path (format nil "generated/~a" (get-universal-time)))))
29
+  (let ((new-build (app-path "generated/~a" (get-universal-time))))
40 30
     (run-program "mv" (list dir (namestring new-build)))
41 31
     (when (probe-file (app-path ".prev"))
42 32
       (delete-files (read-symlink (app-path ".prev")) :recursive t))
@@ -47,6 +37,7 @@
47 37
 
48 38
 (defun main ()
49 39
   (load-config)
40
+  (compile-theme)
50 41
   (loop do (if (blog-update-p)
51 42
                (compile-blog)
52 43
                (sleep (interval *config*)))))

+ 11 - 0
src/config.lisp

@@ -1,5 +1,16 @@
1 1
 (in-package :coleslaw)
2 2
 
3
+(defclass blog ()
4
+  ((author :initarg :author :initform "" :accessor author)
5
+   (domain :initarg :domain :initform "" :accessor domain)
6
+   (interval :initarg :interval :initform 600 :accessor interval)
7
+   (license :initarg :license :initform "" :accessor license)
8
+   (plugins :initarg :plugins :initform '() :accessor plugins)
9
+   (repo :initarg :repo :initform #p"/" :accessor repo)
10
+   (sitenav :initarg :sitenav :initform "" :accessor sitenav)
11
+   (title :initarg :title :initform "" :accessor title)
12
+   (theme :initarg :theme :initform "hyde" :accessor theme)))
13
+
3 14
 (defparameter *config* nil
4 15
   "A variable to store the blog configuration and plugin settings.")
5 16
 

+ 2 - 32
src/packages.lisp

@@ -4,35 +4,5 @@
4 4
                           #:delete-files
5 5
                           #:read-symlink
6 6
                           #:run-program)
7
-  (:export ;; themes
8
-           #:add-injection
9
-           #:remove-injection
10
-
11
-           ;; plugins
12
-           #:load-plugins
13
-
14
-           ;; posts
15
-           #:make-post
16
-           #:add-post
17
-           #:remove-post
18
-           #:render-post
19
-           #:find-post
20
-           #:post-url
21
-
22
-           #:post-id
23
-           #:post-title
24
-           #:post-tags
25
-           #:post-date
26
-           #:post-content
27
-           #:post-aliases
28
-
29
-           ;; indices
30
-           #:make-index
31
-           #:add-to-index
32
-           #:remove-from-index
33
-           #:render-index
34
-           #:find-index
35
-           #:index-url
36
-
37
-           #:index-id
38
-           #:index-posts))
7
+  (:import-from :iolib.pathnames #:file-path-namestring)
8
+  (:export #:main))

+ 7 - 5
src/themes.lisp

@@ -9,11 +9,13 @@
9 9
 (defun theme-package (&key (name (theme *config*)))
10 10
   (find-package (string-upcase (concatenate 'string "coleslaw.theme." name))))
11 11
 
12
-(defun compile-theme (&key (theme-dir (app-path (theme *config*))))
13
-  (loop for file in (iolib.os:list-directory theme-dir)
14
-     do (let ((extension (pathname-type file)))
15
-          (when (and extension (string= extension "tmpl"))
16
-            (compile-template :common-lisp-backend file)))))
12
+(defun compile-theme (&key (theme-dir (app-path "themes/~a/" (theme *config*))))
13
+  (flet ((maybe-compile (file)
14
+           (let* ((path (merge-pathnames (file-path-namestring file) theme-dir))
15
+                  (extension (pathname-type path)))
16
+             (when (and extension (string= extension "tmpl"))
17
+               (compile-template :common-lisp-backend path)))))
18
+    (iolib.os:mapdir #'maybe-compile theme-dir)))
17 19
 
18 20
 ;; DOCUMENTATION
19 21
 ;; A theme directory should be named after the theme and contain *.tmpl files