浏览代码

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
 -- Hakyll
20
 -- Hakyll
21
 -- Hyde
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
 ; doc themes and plugins
18
 ; doc themes and plugins
19
 ; fix plugins: s3
19
 ; fix plugins: s3
20
 ;; Incremental compile: only "touched" posts+tags+months. By-20 must be redone, of course.
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
 ;; support old URLs via use of post-aliases?
21
 ;; support old URLs via use of post-aliases?
24
 ;;; plugins: analytics, logging/monitoring, crossposting, disqus
22
 ;;; plugins: analytics, logging/monitoring, crossposting, disqus
25
 ;;;; write a proper version of escape considering wild pathnames and valid URL issues
23
 ;;;; write a proper version of escape considering wild pathnames and valid URL issues

+ 1 - 2
example.coleslawrc

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

+ 3 - 5
src/coleslaw.lisp

37
       (render-posts)
37
       (render-posts)
38
       (render-indices)
38
       (render-indices)
39
       (render-feed))
39
       (render-feed))
40
-    (deploy staging)
41
-    (setf (last-published) (last-commit))))
40
+    (deploy staging)))
42
 
41
 
43
 (defun update-symlink (path target)
42
 (defun update-symlink (path target)
44
   "Update the symlink at PATH to point to TARGET."
43
   "Update the symlink at PATH to point to TARGET."
58
         (update-symlink ".curr" new-build)))))
57
         (update-symlink ".curr" new-build)))))
59
 
58
 
60
 (defun main ()
59
 (defun main ()
60
+  "Load the user's config, then compile and deploy the blog."
61
   (load-config)
61
   (load-config)
62
   (compile-theme)
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
 (defclass blog ()
3
 (defclass blog ()
4
   ((author :initarg :author :initform "" :accessor author)
4
   ((author :initarg :author :initform "" :accessor author)
5
    (domain :initarg :domain :initform "" :accessor domain)
5
    (domain :initarg :domain :initform "" :accessor domain)
6
-   (interval :initarg :interval :initform 600 :accessor interval)
7
    (license :initarg :license :initform "CC-BY-SA" :accessor license)
6
    (license :initarg :license :initform "CC-BY-SA" :accessor license)
8
    (plugins :initarg :plugins :initform '() :accessor plugins)
7
    (plugins :initarg :plugins :initform '() :accessor plugins)
9
    (repo :initarg :repo :initform #p"/" :accessor repo)
8
    (repo :initarg :repo :initform #p"/" :accessor repo)

+ 0 - 24
src/git.lisp

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)))