From 49e150447792189dfbbfc5d996f33fa9402f7890 Mon Sep 17 00:00:00 2001 From: Brit Butler Date: Wed, 22 Aug 2012 10:32:30 -0400 Subject: [PATCH] Make deploy location configurable. --- README | 3 +-- coleslaw.asd | 1 - src/coleslaw.lisp | 20 +++++++++++--------- src/config.lisp | 1 + 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/README b/README index 90f7d54..79ec437 100644 --- a/README +++ b/README @@ -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! diff --git a/coleslaw.asd b/coleslaw.asd index 0db7d9f..d10406e 100644 --- a/coleslaw.asd +++ b/coleslaw.asd @@ -9,7 +9,6 @@ :serial t :components ((:file "packages") (:file "config") - (:file "git") (:file "util") (:file "plugins") (:file "themes") diff --git a/src/coleslaw.lisp b/src/coleslaw.lisp index 1724ff7..0b66da2 100644 --- a/src/coleslaw.lisp +++ b/src/coleslaw.lisp @@ -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*))) diff --git a/src/config.lisp b/src/config.lisp index cb3da9d..1670627 100644 --- a/src/config.lisp +++ b/src/config.lisp @@ -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)