|
@@ -0,0 +1,47 @@
|
|
1
|
+(eval-when (:compile-toplevel :load-toplevel)
|
|
2
|
+ (ql:quickload 'cl-store))
|
|
3
|
+
|
|
4
|
+(defpackage :coleslaw-incremental
|
|
5
|
+ (:use :cl)
|
|
6
|
+ (:import-from :coleslaw #:get-updated-files
|
|
7
|
+ #:find-content-by-path
|
|
8
|
+ #:write-document)
|
|
9
|
+ (:export #:enable))
|
|
10
|
+
|
|
11
|
+(in-package :coleslaw-incremental)
|
|
12
|
+
|
|
13
|
+;; FIXME: We currently never update the site for config changes.
|
|
14
|
+;; Examples to consider include changing the theme or domain of the site.
|
|
15
|
+
|
|
16
|
+;; NOTE: We're gonna be a bit dirty here and monkey patch. The compilation model
|
|
17
|
+;; still isn't an "exposed" part of Coleslaw. After some experimentation maybe
|
|
18
|
+;; we'll settle on an interface.
|
|
19
|
+
|
|
20
|
+(defvar *changed-content* nil
|
|
21
|
+ "A list of changed content instances to iterate over and write out to disk.")
|
|
22
|
+
|
|
23
|
+(defun coleslaw::load-content ()
|
|
24
|
+ ;; TODO: What if the file doesn't exist?
|
|
25
|
+ (let ((db-file (rel-path (user-homedir-pathname) ".coleslaw.db")))
|
|
26
|
+ (setf coleslaw::*site* (cl-store:restore db-file))
|
|
27
|
+ (loop for (status path) in (get-updated-files)
|
|
28
|
+ do (update-content status path))
|
|
29
|
+ (cl-store:store coleslaw::*site* db-file)))
|
|
30
|
+
|
|
31
|
+(defun update-content (status path)
|
|
32
|
+ (cond ((string= "D" status) (process-change :deleted path))
|
|
33
|
+ ((string= "M" status) (process-change :modified path))
|
|
34
|
+ ((string= "A" status) (process-change :added path))))
|
|
35
|
+
|
|
36
|
+(defgeneric process-change (status path)
|
|
37
|
+ (:documentation "Updates the database as needed for the STATUS change to PATH."))
|
|
38
|
+
|
|
39
|
+(defun coleslaw::compile-blog (staging)
|
|
40
|
+ "lulz. Do it live. DO IT ALL LIVE."
|
|
41
|
+ ;; FIXME: This doesn't cover prev/next links for posts, theme-fn for feeds.
|
|
42
|
+ (mapcar #'write-document *changed-content*))
|
|
43
|
+
|
|
44
|
+;; No-op. We'll be updating in place instead.
|
|
45
|
+(defmethod coleslaw:deploy (staging))
|
|
46
|
+
|
|
47
|
+(defun enable ())
|