Procházet zdrojové kódy

Add staging config option. Tweak defaults.

Brit Butler před 13 roky
rodič
revize
43501458c1
2 změnil soubory, kde provedl 22 přidání a 20 odebrání
  1. 20 19
      src/coleslaw.lisp
  2. 2 1
      src/config.lisp

+ 20 - 19
src/coleslaw.lisp

@@ -23,33 +23,34 @@ on files that match the given extension."
23 23
 
24 24
 (defun render-page (path html)
25 25
   "Populate the base template with the provided HTML and write it out to PATH."
26
-  (ensure-directories-exist path)
27
-  (with-open-file (out path
28
-                   :direction :output
29
-                   :if-does-not-exist :create)
30
-    (let ((content (funcall (theme-fn "BASE")
31
-                            (list :title (title *config*)
32
-                                  :siteroot (domain *config*)
33
-                                  :navigation (sitenav *config*)
34
-                                  :content html
35
-                                  :head-inject (apply #'concatenate 'string
36
-                                                      (gethash :head *injections*))
37
-                                  :body-inject (apply #'concatenate 'string
38
-                                                      (gethash :body *injections*))
39
-                                  :license (license *config*)
40
-                                  :credits (author *config*)))))
41
-      (write-line content out))))
26
+  (let ((filepath (merge-pathnames path (staging *config*))))
27
+    (ensure-directories-exist filepath)
28
+    (with-open-file (out path
29
+                         :direction :output
30
+                         :if-does-not-exist :create)
31
+      (let ((content (funcall (theme-fn "BASE")
32
+                              (list :title (title *config*)
33
+                                    :siteroot (domain *config*)
34
+                                    :navigation (sitenav *config*)
35
+                                    :content html
36
+                                    :head-inject (apply #'concatenate 'string
37
+                                                        (gethash :head *injections*))
38
+                                    :body-inject (apply #'concatenate 'string
39
+                                                        (gethash :body *injections*))
40
+                                    :license (license *config*)
41
+                                    :credits (author *config*)))))
42
+        (write-line content out)))))
42 43
 
43 44
 (defun compile-blog ()
44 45
   "Compile the blog to a staging directory in /tmp."
45
-  (let ((staging #p"/tmp/coleslaw/"))
46
+  (let ((staging (staging *config*)))
46 47
     ; TODO: More incremental compilation? Don't regen whole blog unnecessarily.
47 48
     (when (probe-file staging)
48 49
       (delete-directory-and-files staging))
49 50
     (ensure-directories-exist staging)
50 51
     (with-current-directory staging
51
-      (let ((css-dir (app-path "themes/~a/css/" (theme *config*)))
52
-            (static-dir (merge-pathnames "static/" (repo *config*))))
52
+      (let ((css-dir (app-path "themes/~a/css" (theme *config*)))
53
+            (static-dir (merge-pathnames "static" (repo *config*))))
53 54
         (dolist (dir (list css-dir static-dir))
54 55
           (when (probe-file dir)
55 56
             (run-program "cp" `("-R" ,(namestring dir) ".")))))

+ 2 - 1
src/config.lisp

@@ -4,10 +4,11 @@
4 4
   ((author :initarg :author :initform "" :accessor author)
5 5
    (domain :initarg :domain :initform "" :accessor domain)
6 6
    (interval :initarg :interval :initform 600 :accessor interval)
7
-   (license :initarg :license :initform "" :accessor license)
7
+   (license :initarg :license :initform "CC-BY-SA" :accessor license)
8 8
    (plugins :initarg :plugins :initform '() :accessor plugins)
9 9
    (repo :initarg :repo :initform #p"/" :accessor repo)
10 10
    (sitenav :initarg :sitenav :initform "" :accessor sitenav)
11
+   (staging :initarg :staging :initform #p"/tmp/coleslaw/" :accessor staging)
11 12
    (title :initarg :title :initform "" :accessor title)
12 13
    (theme :initarg :theme :initform "hyde" :accessor theme)))
13 14