diff --git a/examples/example.coleslawrc b/examples/example.coleslawrc index 73016af..5db5ee1 100644 --- a/examples/example.coleslawrc +++ b/examples/example.coleslawrc @@ -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. \ No newline at end of file diff --git a/examples/example.post-receive b/examples/example.post-receive index 32398e7..c89c3f4 100644 --- a/examples/example.post-receive +++ b/examples/example.post-receive @@ -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 diff --git a/plugins/git-hook.lisp b/plugins/git-hook.lisp new file mode 100644 index 0000000..a27d6d4 --- /dev/null +++ b/plugins/git-hook.lisp @@ -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))) diff --git a/src/coleslaw.lisp b/src/coleslaw.lisp index e92616e..d65f360 100644 --- a/src/coleslaw.lisp +++ b/src/coleslaw.lisp @@ -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." diff --git a/src/config.lisp b/src/config.lisp index ae30c30..4d61e4c 100644 --- a/src/config.lisp +++ b/src/config.lisp @@ -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)) diff --git a/src/packages.lisp b/src/packages.lisp index a9a3786..7bc0a65 100644 --- a/src/packages.lisp +++ b/src/packages.lisp @@ -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 diff --git a/tests/tests.lisp b/tests/tests.lisp index 50d5071..891c9c4 100644 --- a/tests/tests.lisp +++ b/tests/tests.lisp @@ -10,4 +10,4 @@ (deftest sanity-test "A blog should compile and deploy correctly." - (is (zerop (coleslaw:main)))) + (is (zerop (coleslaw:main ""))))