Преглед на файлове

Make deploy location configurable.

Brit Butler преди 13 години
родител
ревизия
49e1504477
променени са 4 файла, в които са добавени 13 реда и са изтрити 12 реда
  1. 1 2
      README
  2. 0 1
      coleslaw.asd
  3. 11 9
      src/coleslaw.lisp
  4. 1 0
      src/config.lisp

+ 1 - 2
README

@@ -28,9 +28,8 @@ Server side setup:
28 28
            (push "/path/to/coleslaw/" asdf:*central-registry*) to your lisp's init file. (e.g. ~/.sbclrc for SBCL)
29 29
              -- You may need to (require 'asdf) in that file first or even create it! (Don't panic.)
30 30
       This is only temporarily necessary until coleslaw is in quicklisp.
31
-* cp coleslaw/example.coleslawrc ~/.coleslawrc # and edit as necessary for your repo location, etc
31
+* cp coleslaw/example.coleslawrc ~/.coleslawrc # and edit as necessary for your repo location, deploy location, etc
32 32
 * Edit your-blog/.git/hooks/post-receieve and insert:
33
-#!/bin/sh
34 33
 sbcl --eval "(progn (ql:quickload :coleslaw) (coleslaw:main) (sb-ext:quit))" # or (sb-ext:exit) on SBCL >= 1.0.57
35 34
 * chmod +x your-blog/.git/hooks/post-receive
36 35
 Now whenever you push a new commit to the server, coleslaw will update your blog automatically!

+ 0 - 1
coleslaw.asd

@@ -9,7 +9,6 @@
9 9
   :serial t
10 10
   :components ((:file "packages")
11 11
                (:file "config")
12
-               (:file "git")
13 12
                (:file "util")
14 13
                (:file "plugins")
15 14
                (:file "themes")

+ 11 - 9
src/coleslaw.lisp

@@ -36,8 +36,7 @@ If RAW is non-nil, write the content without wrapping it in the base template."
36 36
             (run-program "cp" `("-R" ,(namestring dir) ".")))))
37 37
       (render-posts)
38 38
       (render-indices)
39
-      (render-feed))
40
-    (deploy staging)))
39
+      (render-feed))))
41 40
 
42 41
 (defun update-symlink (path target)
43 42
   "Update the symlink at PATH to point to TARGET."
@@ -46,18 +45,21 @@ If RAW is non-nil, write the content without wrapping it in the base template."
46 45
 (defgeneric deploy (dir)
47 46
   (:documentation "Deploy DIR, updating the .prev and .curr symlinks.")
48 47
   (:method (dir)
49
-    (let ((new-build (app-path "generated/~a" (get-universal-time))))
48
+    (let ((new-build (app-path "generated/~a" (get-universal-time)))
49
+          (prev (merge-pathnames ".prev" (deploy *config*)))
50
+          (curr (merge-pathnames ".curr" (deploy *config*))))
50 51
       (ensure-directories-exist new-build)
51 52
       (with-current-directory coleslaw-conf:*basedir*
52 53
         (run-program "mv" (mapcar #'namestring (list dir new-build)))
53
-        (when (probe-file (app-path ".prev"))
54
-          (delete-directory-and-files (read-symlink (app-path ".prev"))))
55
-        (when (probe-file (app-path ".curr"))
56
-          (update-symlink ".prev" (read-symlink (app-path ".curr"))))
57
-        (update-symlink ".curr" new-build)))))
54
+        (when (probe-file prev)
55
+          (delete-directory-and-files (read-symlink prev)))
56
+        (when (probe-file curr)
57
+          (update-symlink prev (read-symlink curr)))
58
+        (update-symlink curr new-build)))))
58 59
 
59 60
 (defun main ()
60 61
   "Load the user's config, then compile and deploy the blog."
61 62
   (load-config)
62 63
   (compile-theme)
63
-  (compile-blog))
64
+  (compile-blog)
65
+  (deploy (staging *config*)))

+ 1 - 0
src/config.lisp

@@ -2,6 +2,7 @@
2 2
 
3 3
 (defclass blog ()
4 4
   ((author :initarg :author :initform "" :accessor author)
5
+   (deploy :initarg :deploy :initform nil :accessor deploy)
5 6
    (domain :initarg :domain :initform "" :accessor domain)
6 7
    (license :initarg :license :initform "CC-BY-SA" :accessor license)
7 8
    (plugins :initarg :plugins :initform '() :accessor plugins)