A serverside commithook should kick off the compile.

This commit is contained in:
Brit Butler 2012-08-22 10:05:02 -04:00
parent 5df157b368
commit 37d6b3ccd7
6 changed files with 20 additions and 34 deletions

16
README
View file

@ -20,3 +20,19 @@ References:
-- Hakyll -- Hakyll
-- Hyde -- Hyde
This software should be portable to any conforming Common Lisp implementation but this guide will assume SBCL is installed. Testing has also been done on CCL.
Server side setup:
* Clone or create the git repo for your blog.
* Install Lisp and Quicklisp.
* For now, git clone https://github.com/redline6561/coleslaw.git and add
(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
* 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!
The only thing left to do is point a web server of your choice at the symlink /path/to/coleslaw/.curr

2
TODO
View file

@ -18,8 +18,6 @@ TODO:
; doc themes and plugins ; doc themes and plugins
; fix plugins: s3 ; fix plugins: s3
;; Incremental compile: only "touched" posts+tags+months. By-20 must be redone, of course. ;; Incremental compile: only "touched" posts+tags+months. By-20 must be redone, of course.
;; ^^ Long as we're overhauling, maybe come up with a commithook scheme that runs main
;; and main becomes load-config, compile-theme, compile-blog?
;; support old URLs via use of post-aliases? ;; support old URLs via use of post-aliases?
;;; plugins: analytics, logging/monitoring, crossposting, disqus ;;; plugins: analytics, logging/monitoring, crossposting, disqus
;;;; write a proper version of escape considering wild pathnames and valid URL issues ;;;; write a proper version of escape considering wild pathnames and valid URL issues

View file

@ -1,6 +1,5 @@
(:author "Brit Butler" (:author "Brit Butler"
:domain "http://redlinernotes.com" :domain "http://blog.redlinernotes.com"
:interval 600
:license "CC-BY-SA" :license "CC-BY-SA"
:plugins nil :plugins nil
:repo "/home/redline/projects/coleslaw/ignore/input/" :repo "/home/redline/projects/coleslaw/ignore/input/"

View file

@ -37,8 +37,7 @@ If RAW is non-nil, write the content without wrapping it in the base template."
(render-posts) (render-posts)
(render-indices) (render-indices)
(render-feed)) (render-feed))
(deploy staging) (deploy staging)))
(setf (last-published) (last-commit))))
(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."
@ -58,8 +57,7 @@ If RAW is non-nil, write the content without wrapping it in the base template."
(update-symlink ".curr" new-build))))) (update-symlink ".curr" new-build)))))
(defun main () (defun main ()
"Load the user's config, then compile and deploy the blog."
(load-config) (load-config)
(compile-theme) (compile-theme)
(loop do (if (blog-update-p) (compile-blog))
(compile-blog)
(sleep (interval *config*)))))

View file

@ -3,7 +3,6 @@
(defclass blog () (defclass blog ()
((author :initarg :author :initform "" :accessor author) ((author :initarg :author :initform "" :accessor author)
(domain :initarg :domain :initform "" :accessor domain) (domain :initarg :domain :initform "" :accessor domain)
(interval :initarg :interval :initform 600 :accessor interval)
(license :initarg :license :initform "CC-BY-SA" :accessor license) (license :initarg :license :initform "CC-BY-SA" :accessor license)
(plugins :initarg :plugins :initform '() :accessor plugins) (plugins :initarg :plugins :initform '() :accessor plugins)
(repo :initarg :repo :initform #p"/" :accessor repo) (repo :initarg :repo :initform #p"/" :accessor repo)

View file

@ -1,24 +0,0 @@
(in-package :coleslaw)
(defun last-commit ()
"Retrieve the SHA1 hash of the most recent blog commit."
(multiple-value-bind (pid stdout stderr)
(with-current-directory (repo *config*)
(run-program "git" '("log" "-n 1")))
(cl-ppcre:scan-to-strings "[0-9a-f]{40}" stdout)))
(defun last-published ()
"Retrieve the SHA1 hash of the most recent published blog."
(with-open-file (in "/home/redline/.coleslaw" :if-does-not-exist :create)
(read-line in nil)))
(defun (setf last-published) (new-val)
(with-open-file (out "/home/redline/.coleslaw"
:direction :output
:if-exists :supersede
:if-does-not-exist :create)
(write-line new-val out)))
(defun blog-update-p ()
"Returns a non-nil value if the blog needs to be regenerated."
(mismatch (last-commit) (last-published)))