Tentatively factor deploy method into git-hook plugin. TODO follows...
* Deploy :after plugins probably need revision now, and coleslaw-heroku. * README, HACKING need updates. Plugin-api.md too. * NEWS needs a carefully worded entry. Is that what we want?
This commit is contained in:
parent
4630a7a224
commit
567c4473bb
7 changed files with 44 additions and 27 deletions
|
@ -2,12 +2,13 @@
|
|||
:deploy-dir "/home/git/blog/"
|
||||
:domain "http://blog.redlinernotes.com"
|
||||
:feeds ("lisp")
|
||||
:plugins ((mathjax)
|
||||
(sitemap)
|
||||
(static-pages)
|
||||
:plugins ((analytics :tracking-code "foo")
|
||||
(disqus :shortname "my-site-name")
|
||||
(analytics :tracking-code "foo"))
|
||||
:repo "/home/git/tmp/improvedmeans/"
|
||||
; (git-hook) ;; *Remove comment to enable git push deploys.
|
||||
; (incremental) ;; *Remove comment enable incremental builds.
|
||||
(mathjax)
|
||||
(sitemap)
|
||||
(static-pages))
|
||||
:routing ((:post "posts/~a")
|
||||
(:tag-index "tag/~a")
|
||||
(:month-index "date/~a")
|
||||
|
@ -22,3 +23,5 @@
|
|||
:staging-dir "/tmp/coleslaw/"
|
||||
:title "Improved Means for Achieving Deteriorated Ends"
|
||||
:theme "hyde")
|
||||
|
||||
;; * Prerequisites described in plugin docs.
|
|
@ -1,6 +1,5 @@
|
|||
########## CONFIGURATION VALUES ##########
|
||||
|
||||
# TMP_GIT_CLONE _must_ match the :repo argument in your .coleslawrc!
|
||||
TMP_GIT_CLONE=$HOME/tmp/improvedmeans/
|
||||
|
||||
# Set LISP to your preferred implementation. The following
|
||||
|
@ -30,6 +29,7 @@ while read oldrev newrev refname; do
|
|||
elif [ $LISP = ccl ]; then
|
||||
ccl -e "(ql:quickload 'coleslaw) (coleslaw:main \"$TMP_GIT_CLONE\" \"$oldrev\") (coleslaw::exit)"
|
||||
else
|
||||
echo -e "$LISP is not a supported lisp dialect at this time. Exiting.\n"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
|
22
plugins/git-hook.lisp
Normal file
22
plugins/git-hook.lisp
Normal file
|
@ -0,0 +1,22 @@
|
|||
(defpackage :coleslaw-git-hook
|
||||
(:use :cl)
|
||||
(:import-from :coleslaw #:*config*
|
||||
#:deploy-dir
|
||||
#:rel-path
|
||||
#:run-program
|
||||
#:update-symlink))
|
||||
|
||||
(in-package :coleslaw-git-hook)
|
||||
|
||||
(defmethod coleslaw:deploy (staging)
|
||||
(let* ((dest (deploy-dir *config*))
|
||||
(new-build (rel-path dest "generated/~a" (get-universal-time)))
|
||||
(prev (rel-path dest ".prev"))
|
||||
(curr (rel-path dest ".curr")))
|
||||
(ensure-directories-exist new-build)
|
||||
(run-program "mv ~a ~a" staging new-build)
|
||||
(when (and (probe-file prev) (truename prev))
|
||||
(run-program "rm -r ~a" (truename prev)))
|
||||
(when (probe-file curr)
|
||||
(update-symlink prev (truename curr)))
|
||||
(update-symlink curr new-build)))
|
|
@ -3,12 +3,12 @@
|
|||
(defvar *last-revision* nil
|
||||
"The git revision prior to the last push. For use with GET-UPDATED-FILES.")
|
||||
|
||||
(defun main (&optional (repo-dir "") oldrev)
|
||||
"Load the user's config file, then compile and deploy the site. Optionally,
|
||||
REPO-DIR is the location of the blog repo and OLDREV is the revision prior to
|
||||
the last push."
|
||||
(setf *last-revision* oldrev)
|
||||
(defun main (repo-dir &optional oldrev)
|
||||
"Load the user's config file, then compile and deploy the blog stored
|
||||
in REPO-DIR. Optionally, OLDREV is the revision prior to the last push."
|
||||
(load-config repo-dir)
|
||||
(setf (repo *config*) repo-dir
|
||||
*last-revision* oldrev)
|
||||
(load-content)
|
||||
(compile-theme (theme *config*))
|
||||
(let ((dir (staging-dir *config*)))
|
||||
|
@ -40,19 +40,10 @@ the last push."
|
|||
(update-symlink "index.html" "1.html")))
|
||||
|
||||
(defgeneric deploy (staging)
|
||||
(:documentation "Deploy the STAGING dir, updating the .prev and .curr symlinks.")
|
||||
(:documentation "Deploy the STAGING build to the directory specified in the config.")
|
||||
(:method (staging)
|
||||
(let* ((dest (deploy-dir *config*))
|
||||
(new-build (rel-path dest "generated/~a" (get-universal-time)))
|
||||
(prev (rel-path dest ".prev"))
|
||||
(curr (rel-path dest ".curr")))
|
||||
(ensure-directories-exist new-build)
|
||||
(run-program "mv ~a ~a" staging new-build)
|
||||
(when (and (probe-file prev) (truename prev))
|
||||
(run-program "rm -r ~a" (truename prev)))
|
||||
(when (probe-file curr)
|
||||
(update-symlink prev (truename curr)))
|
||||
(update-symlink curr new-build))))
|
||||
(let ((destination (deploy-dir *config*)))
|
||||
(run-program "rsync --delete -avz ~a ~a" staging destination))))
|
||||
|
||||
(defun update-symlink (path target)
|
||||
"Update the symlink at PATH to point to TARGET."
|
||||
|
|
|
@ -61,7 +61,7 @@ doesn't exist, use the .coleslawrc in the home directory."
|
|||
repo-config
|
||||
(rel-path (user-homedir-pathname) ".coleslawrc"))))
|
||||
|
||||
(defun load-config (&optional repo-dir)
|
||||
(defun load-config (&optional (repo-dir ""))
|
||||
"Find and load the coleslaw configuration from .coleslawrc. REPO-DIR will be
|
||||
preferred over the home directory if provided."
|
||||
(with-open-file (in (discover-config-path repo-dir) :external-format '(:utf-8))
|
||||
|
|
|
@ -22,12 +22,13 @@
|
|||
#:title-of
|
||||
#:author-of
|
||||
#:find-content-by-path
|
||||
;; Plugin API + Theming
|
||||
;; Theming + Plugin API
|
||||
#:theme-fn
|
||||
#:plugin-conf-error
|
||||
#:render-text
|
||||
#:add-injection
|
||||
#:get-updated-files
|
||||
#:theme-fn
|
||||
#:deploy
|
||||
;; The Document Protocol
|
||||
#:discover
|
||||
#:publish
|
||||
|
|
|
@ -10,4 +10,4 @@
|
|||
|
||||
(deftest sanity-test
|
||||
"A blog should compile and deploy correctly."
|
||||
(is (zerop (coleslaw:main))))
|
||||
(is (zerop (coleslaw:main ""))))
|
||||
|
|
Loading…
Add table
Reference in a new issue