Make deploy location configurable.

This commit is contained in:
Brit Butler 2012-08-22 10:32:30 -04:00
parent 37d6b3ccd7
commit 49e1504477
4 changed files with 13 additions and 12 deletions

3
README
View file

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

View file

@ -9,7 +9,6 @@
:serial t
:components ((:file "packages")
(:file "config")
(:file "git")
(:file "util")
(:file "plugins")
(:file "themes")

View file

@ -36,8 +36,7 @@ If RAW is non-nil, write the content without wrapping it in the base template."
(run-program "cp" `("-R" ,(namestring dir) ".")))))
(render-posts)
(render-indices)
(render-feed))
(deploy staging)))
(render-feed))))
(defun update-symlink (path target)
"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."
(defgeneric deploy (dir)
(:documentation "Deploy DIR, updating the .prev and .curr symlinks.")
(:method (dir)
(let ((new-build (app-path "generated/~a" (get-universal-time))))
(let ((new-build (app-path "generated/~a" (get-universal-time)))
(prev (merge-pathnames ".prev" (deploy *config*)))
(curr (merge-pathnames ".curr" (deploy *config*))))
(ensure-directories-exist new-build)
(with-current-directory coleslaw-conf:*basedir*
(run-program "mv" (mapcar #'namestring (list dir new-build)))
(when (probe-file (app-path ".prev"))
(delete-directory-and-files (read-symlink (app-path ".prev"))))
(when (probe-file (app-path ".curr"))
(update-symlink ".prev" (read-symlink (app-path ".curr"))))
(update-symlink ".curr" new-build)))))
(when (probe-file prev)
(delete-directory-and-files (read-symlink prev)))
(when (probe-file curr)
(update-symlink prev (read-symlink curr)))
(update-symlink curr new-build)))))
(defun main ()
"Load the user's config, then compile and deploy the blog."
(load-config)
(compile-theme)
(compile-blog))
(compile-blog)
(deploy (staging *config*)))

View file

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