瀏覽代碼

A serverside commithook should kick off the compile.

Brit Butler 13 年之前
父節點
當前提交
37d6b3ccd7
共有 6 個文件被更改,包括 20 次插入34 次删除
  1. 16 0
      README
  2. 0 2
      TODO
  3. 1 2
      example.coleslawrc
  4. 3 5
      src/coleslaw.lisp
  5. 0 1
      src/config.lisp
  6. 0 24
      src/git.lisp

+ 16 - 0
README

@@ -20,3 +20,19 @@ References:
20 20
 -- Hakyll
21 21
 -- Hyde
22 22
 
23
+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.
24
+Server side setup:
25
+* Clone or create the git repo for your blog.
26
+* Install Lisp and Quicklisp.
27
+* For now, git clone https://github.com/redline6561/coleslaw.git and add
28
+           (push "/path/to/coleslaw/" asdf:*central-registry*) to your lisp's init file. (e.g. ~/.sbclrc for SBCL)
29
+             -- You may need to (require 'asdf) in that file first or even create it! (Don't panic.)
30
+      This is only temporarily necessary until coleslaw is in quicklisp.
31
+* cp coleslaw/example.coleslawrc ~/.coleslawrc # and edit as necessary for your repo location, etc
32
+* Edit your-blog/.git/hooks/post-receieve and insert:
33
+#!/bin/sh
34
+sbcl --eval "(progn (ql:quickload :coleslaw) (coleslaw:main) (sb-ext:quit))" # or (sb-ext:exit) on SBCL >= 1.0.57
35
+* chmod +x your-blog/.git/hooks/post-receive
36
+Now whenever you push a new commit to the server, coleslaw will update your blog automatically!
37
+The only thing left to do is point a web server of your choice at the symlink /path/to/coleslaw/.curr
38
+

+ 0 - 2
TODO

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

+ 1 - 2
example.coleslawrc

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

+ 3 - 5
src/coleslaw.lisp

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

+ 0 - 1
src/config.lisp

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

+ 0 - 24
src/git.lisp

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