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