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/"
|
:deploy-dir "/home/git/blog/"
|
||||||
:domain "http://blog.redlinernotes.com"
|
:domain "http://blog.redlinernotes.com"
|
||||||
:feeds ("lisp")
|
:feeds ("lisp")
|
||||||
:plugins ((mathjax)
|
:plugins ((analytics :tracking-code "foo")
|
||||||
(sitemap)
|
|
||||||
(static-pages)
|
|
||||||
(disqus :shortname "my-site-name")
|
(disqus :shortname "my-site-name")
|
||||||
(analytics :tracking-code "foo"))
|
; (git-hook) ;; *Remove comment to enable git push deploys.
|
||||||
:repo "/home/git/tmp/improvedmeans/"
|
; (incremental) ;; *Remove comment enable incremental builds.
|
||||||
|
(mathjax)
|
||||||
|
(sitemap)
|
||||||
|
(static-pages))
|
||||||
:routing ((:post "posts/~a")
|
:routing ((:post "posts/~a")
|
||||||
(:tag-index "tag/~a")
|
(:tag-index "tag/~a")
|
||||||
(:month-index "date/~a")
|
(:month-index "date/~a")
|
||||||
|
@ -22,3 +23,5 @@
|
||||||
:staging-dir "/tmp/coleslaw/"
|
:staging-dir "/tmp/coleslaw/"
|
||||||
:title "Improved Means for Achieving Deteriorated Ends"
|
:title "Improved Means for Achieving Deteriorated Ends"
|
||||||
:theme "hyde")
|
:theme "hyde")
|
||||||
|
|
||||||
|
;; * Prerequisites described in plugin docs.
|
|
@ -1,6 +1,5 @@
|
||||||
########## CONFIGURATION VALUES ##########
|
########## CONFIGURATION VALUES ##########
|
||||||
|
|
||||||
# TMP_GIT_CLONE _must_ match the :repo argument in your .coleslawrc!
|
|
||||||
TMP_GIT_CLONE=$HOME/tmp/improvedmeans/
|
TMP_GIT_CLONE=$HOME/tmp/improvedmeans/
|
||||||
|
|
||||||
# Set LISP to your preferred implementation. The following
|
# Set LISP to your preferred implementation. The following
|
||||||
|
@ -30,6 +29,7 @@ while read oldrev newrev refname; do
|
||||||
elif [ $LISP = ccl ]; then
|
elif [ $LISP = ccl ]; then
|
||||||
ccl -e "(ql:quickload 'coleslaw) (coleslaw:main \"$TMP_GIT_CLONE\" \"$oldrev\") (coleslaw::exit)"
|
ccl -e "(ql:quickload 'coleslaw) (coleslaw:main \"$TMP_GIT_CLONE\" \"$oldrev\") (coleslaw::exit)"
|
||||||
else
|
else
|
||||||
|
echo -e "$LISP is not a supported lisp dialect at this time. Exiting.\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
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
|
(defvar *last-revision* nil
|
||||||
"The git revision prior to the last push. For use with GET-UPDATED-FILES.")
|
"The git revision prior to the last push. For use with GET-UPDATED-FILES.")
|
||||||
|
|
||||||
(defun main (&optional (repo-dir "") oldrev)
|
(defun main (repo-dir &optional oldrev)
|
||||||
"Load the user's config file, then compile and deploy the site. Optionally,
|
"Load the user's config file, then compile and deploy the blog stored
|
||||||
REPO-DIR is the location of the blog repo and OLDREV is the revision prior to
|
in REPO-DIR. Optionally, OLDREV is the revision prior to the last push."
|
||||||
the last push."
|
|
||||||
(setf *last-revision* oldrev)
|
|
||||||
(load-config repo-dir)
|
(load-config repo-dir)
|
||||||
|
(setf (repo *config*) repo-dir
|
||||||
|
*last-revision* oldrev)
|
||||||
(load-content)
|
(load-content)
|
||||||
(compile-theme (theme *config*))
|
(compile-theme (theme *config*))
|
||||||
(let ((dir (staging-dir *config*)))
|
(let ((dir (staging-dir *config*)))
|
||||||
|
@ -40,19 +40,10 @@ the last push."
|
||||||
(update-symlink "index.html" "1.html")))
|
(update-symlink "index.html" "1.html")))
|
||||||
|
|
||||||
(defgeneric deploy (staging)
|
(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)
|
(:method (staging)
|
||||||
(let* ((dest (deploy-dir *config*))
|
(let ((destination (deploy-dir *config*)))
|
||||||
(new-build (rel-path dest "generated/~a" (get-universal-time)))
|
(run-program "rsync --delete -avz ~a ~a" staging destination))))
|
||||||
(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))))
|
|
||||||
|
|
||||||
(defun update-symlink (path target)
|
(defun update-symlink (path target)
|
||||||
"Update the symlink at PATH to point to 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
|
repo-config
|
||||||
(rel-path (user-homedir-pathname) ".coleslawrc"))))
|
(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
|
"Find and load the coleslaw configuration from .coleslawrc. REPO-DIR will be
|
||||||
preferred over the home directory if provided."
|
preferred over the home directory if provided."
|
||||||
(with-open-file (in (discover-config-path repo-dir) :external-format '(:utf-8))
|
(with-open-file (in (discover-config-path repo-dir) :external-format '(:utf-8))
|
||||||
|
|
|
@ -22,12 +22,13 @@
|
||||||
#:title-of
|
#:title-of
|
||||||
#:author-of
|
#:author-of
|
||||||
#:find-content-by-path
|
#:find-content-by-path
|
||||||
;; Plugin API + Theming
|
;; Theming + Plugin API
|
||||||
|
#:theme-fn
|
||||||
#:plugin-conf-error
|
#:plugin-conf-error
|
||||||
#:render-text
|
#:render-text
|
||||||
#:add-injection
|
#:add-injection
|
||||||
#:get-updated-files
|
#:get-updated-files
|
||||||
#:theme-fn
|
#:deploy
|
||||||
;; The Document Protocol
|
;; The Document Protocol
|
||||||
#:discover
|
#:discover
|
||||||
#:publish
|
#:publish
|
||||||
|
|
|
@ -10,4 +10,4 @@
|
||||||
|
|
||||||
(deftest sanity-test
|
(deftest sanity-test
|
||||||
"A blog should compile and deploy correctly."
|
"A blog should compile and deploy correctly."
|
||||||
(is (zerop (coleslaw:main))))
|
(is (zerop (coleslaw:main ""))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue